svn commit: r324766 - stable/9/sys/dev/qlxgbe

2017-10-19 Thread David C Somayajulu
Author: davidcs
Date: Thu Oct 19 17:57:38 2017
New Revision: 324766
URL: https://svnweb.freebsd.org/changeset/base/324766

Log:
  MFC r324538
  Added support driver state capture/retrieval

Modified:
  stable/9/sys/dev/qlxgbe/ql_def.h
  stable/9/sys/dev/qlxgbe/ql_glbl.h
  stable/9/sys/dev/qlxgbe/ql_hw.h
  stable/9/sys/dev/qlxgbe/ql_ioctl.c
  stable/9/sys/dev/qlxgbe/ql_ioctl.h
  stable/9/sys/dev/qlxgbe/ql_os.c
  stable/9/sys/dev/qlxgbe/ql_ver.h
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/qlxgbe/ql_def.h
==
--- stable/9/sys/dev/qlxgbe/ql_def.hThu Oct 19 17:40:51 2017
(r324765)
+++ stable/9/sys/dev/qlxgbe/ql_def.hThu Oct 19 17:57:38 2017
(r324766)
@@ -201,7 +201,6 @@ struct qla_host {
 
qla_rx_buf_t*rxb_free;
uint32_trxb_free_count;
-   volatile uint32_t   posting;
 
/* stats */
uint32_terr_m_getcl;
@@ -264,7 +263,7 @@ struct qla_host {
 typedef struct qla_host qla_host_t;
 
 /* note that align has to be a power of 2 */
-#define QL_ALIGN(size, align) (size + (align - 1)) & ~(align - 1);
+#define QL_ALIGN(size, align) (((size) + ((align) - 1)) & (~((align) - 1)));
 #define QL_MIN(x, y) ((x < y) ? x : y)
 
 #define QL_RUNNING(ifp) (ifp->if_drv_flags & IFF_DRV_RUNNING)

Modified: stable/9/sys/dev/qlxgbe/ql_glbl.h
==
--- stable/9/sys/dev/qlxgbe/ql_glbl.h   Thu Oct 19 17:40:51 2017
(r324765)
+++ stable/9/sys/dev/qlxgbe/ql_glbl.h   Thu Oct 19 17:57:38 2017
(r324766)
@@ -112,4 +112,8 @@ extern unsigned int ql83xx_resetseq_len;
 extern unsigned char ql83xx_minidump[];
 extern unsigned int ql83xx_minidump_len;
 
+extern void ql_alloc_drvr_state_buffer(qla_host_t *ha);
+extern void ql_free_drvr_state_buffer(qla_host_t *ha);
+extern void ql_capture_drvr_state(qla_host_t *ha);
+
 #endif /* #ifndef_QL_GLBL_H_ */

Modified: stable/9/sys/dev/qlxgbe/ql_hw.h
==
--- stable/9/sys/dev/qlxgbe/ql_hw.h Thu Oct 19 17:40:51 2017
(r324765)
+++ stable/9/sys/dev/qlxgbe/ql_hw.h Thu Oct 19 17:57:38 2017
(r324766)
@@ -1703,6 +1703,9 @@ typedef struct _qla_hw {
uint32_tmdump_buffer_size;
void*mdump_template;
uint32_tmdump_template_size;
+
+   /* driver state related */
+   void*drvr_state;
 } qla_hw_t;
 
 #define QL_UPDATE_RDS_PRODUCER_INDEX(ha, prod_reg, val) \

Modified: stable/9/sys/dev/qlxgbe/ql_ioctl.c
==
--- stable/9/sys/dev/qlxgbe/ql_ioctl.c  Thu Oct 19 17:40:51 2017
(r324765)
+++ stable/9/sys/dev/qlxgbe/ql_ioctl.c  Thu Oct 19 17:57:38 2017
(r324766)
@@ -39,7 +39,11 @@ __FBSDID("$FreeBSD$");
 #include "ql_inline.h"
 #include "ql_glbl.h"
 #include "ql_ioctl.h"
+#include "ql_ver.h"
+#include "ql_dbg.h"
 
+static int ql_drvr_state(qla_host_t *ha, qla_driver_state_t *drvr_state);
+static uint32_t ql_drvr_state_size(qla_host_t *ha);
 static int ql_eioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
struct thread *td);
 
@@ -279,6 +283,10 @@ ql_eioctl(struct cdev *dev, u_long cmd, caddr_t data, 
rval = ENXIO;
break;
 
+   case QLA_RD_DRVR_STATE:
+   rval = ql_drvr_state(ha, (qla_driver_state_t *)data);
+   break;
+
case QLA_RD_PCI_IDS:
pci_ids = (qla_rd_pci_ids_t *)data;
pci_ids->ven_id = pci_get_vendor(pci_dev);
@@ -293,5 +301,225 @@ ql_eioctl(struct cdev *dev, u_long cmd, caddr_t data, 
 }
 
 return rval;
+}
+
+
+static int
+ql_drvr_state(qla_host_t *ha, qla_driver_state_t *state)
+{
+   int rval = 0;
+   uint32_t drvr_state_size;
+   qla_drvr_state_hdr_t *hdr;
+
+   drvr_state_size = ql_drvr_state_size(ha);
+
+   if (state->buffer == NULL) {
+   state->size = drvr_state_size;
+   return (0);
+   }
+   
+   if (state->size < drvr_state_size)
+   return (ENXIO);
+
+   if (ha->hw.drvr_state == NULL)
+   return (ENOMEM);
+
+   hdr = ha->hw.drvr_state;
+
+   if (!hdr->drvr_version_major)
+   ql_capture_drvr_state(ha);
+
+   rval = copyout(ha->hw.drvr_state, state->buffer, drvr_state_size);
+
+   bzero(ha->hw.drvr_state, drvr_state_size);
+
+   return (rval);
+}
+
+static uint32_t
+ql_drvr_state_size(qla_host_t *ha)
+{
+   uint32_t drvr_state_size;
+   uint32_t size;
+
+   size = sizeof (qla_drvr_state_hdr_t);
+   drvr_state_size = QL_ALIGN(size, 64);
+
+   size =  ha->hw.num_tx_rings * (sizeof (qla_drvr_state_tx_t));
+   drvr_state_size += 

svn commit: r324765 - stable/9/sys/dev/qlxgbe

2017-10-19 Thread David C Somayajulu
Author: davidcs
Date: Thu Oct 19 17:40:51 2017
New Revision: 324765
URL: https://svnweb.freebsd.org/changeset/base/324765

Log:
  MFC r324535
  Add sanity checks in ql_hw_send() qla_send() to ensure that empty slots
  in Tx Ring map to empty slot in Tx_buf array before Transmits. If the
  checks fail further Transmission on that Tx Ring is prevented.

Modified:
  stable/9/sys/dev/qlxgbe/ql_hw.c
  stable/9/sys/dev/qlxgbe/ql_os.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/qlxgbe/ql_hw.c
==
--- stable/9/sys/dev/qlxgbe/ql_hw.c Thu Oct 19 17:37:33 2017
(r324764)
+++ stable/9/sys/dev/qlxgbe/ql_hw.c Thu Oct 19 17:40:51 2017
(r324765)
@@ -2374,6 +2374,20 @@ ql_hw_send(qla_host_t *ha, bus_dma_segment_t *segs, in
}
}
 
+   for (i = 0; i < num_tx_cmds; i++) {
+   int j;
+
+   j = (tx_idx+i) & (NUM_TX_DESCRIPTORS - 1);
+
+   if (NULL != ha->tx_ring[txr_idx].tx_buf[j].m_head) {
+   QL_ASSERT(ha, 0, \
+   ("%s [%d]: txr_idx = %d tx_idx = %d mbuf = 
%p\n",\
+   __func__, __LINE__, txr_idx, j,\
+   ha->tx_ring[txr_idx].tx_buf[j].m_head));
+   return (EINVAL);
+   }
+   }
+
tx_cmd = >tx_cntxt[txr_idx].tx_ring_base[tx_idx];
 
 if (!(mp->m_pkthdr.csum_flags & CSUM_TSO)) {

Modified: stable/9/sys/dev/qlxgbe/ql_os.c
==
--- stable/9/sys/dev/qlxgbe/ql_os.c Thu Oct 19 17:37:33 2017
(r324764)
+++ stable/9/sys/dev/qlxgbe/ql_os.c Thu Oct 19 17:40:51 2017
(r324765)
@@ -1253,6 +1253,17 @@ qla_send(qla_host_t *ha, struct mbuf **m_headp, uint32
 
 
tx_idx = ha->hw.tx_cntxt[txr_idx].txr_next;
+
+   if (NULL != ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head) {
+   QL_ASSERT(ha, 0, ("%s [%d]: txr_idx = %d tx_idx = %d "\
+   "mbuf = %p\n", __func__, __LINE__, txr_idx, tx_idx,\
+   ha->tx_ring[txr_idx].tx_buf[tx_idx].m_head));
+   if (m_head)
+   m_freem(m_head);
+   *m_headp = NULL;
+   return (ret);
+   }
+
map = ha->tx_ring[txr_idx].tx_buf[tx_idx].map;
 
ret = bus_dmamap_load_mbuf_sg(ha->tx_tag, map, m_head, segs, ,
___
svn-src-stable-9@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"