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 +=