Page MenuHomeFreeBSD

D58742.id183720.diff
No OneTemporary

D58742.id183720.diff

Index: sys/dev/qlnx/qlnxe/qlnx_def.h
===================================================================
--- sys/dev/qlnx/qlnxe/qlnx_def.h
+++ sys/dev/qlnx/qlnxe/qlnx_def.h
@@ -327,6 +327,7 @@
typedef struct _qlnx_vf_attr {
uint8_t mac_addr[ETHER_ADDR_LEN];
uint32_t num_rings;
+ bool configured;
} qlnx_vf_attr_t;
typedef struct _qlnx_sriov_task {
Index: sys/dev/qlnx/qlnxe/qlnx_os.c
===================================================================
--- sys/dev/qlnx/qlnxe/qlnx_os.c
+++ sys/dev/qlnx/qlnxe/qlnx_os.c
@@ -172,6 +172,7 @@
static int qlnx_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *params);
static void qlnx_iov_uninit(device_t dev);
static int qlnx_iov_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *params);
+static int qlnx_vf_status(qlnx_host_t *ha, nvlist_t *status);
static void qlnx_initialize_sriov(qlnx_host_t *ha);
static void qlnx_pf_taskqueue(void *context, int pending);
static int qlnx_create_pf_taskqueues(qlnx_host_t *ha);
@@ -2677,6 +2678,14 @@
break;
}
+#ifndef QLNX_VF
+#ifdef CONFIG_ECORE_SRIOV
+ case SIOCGIFVFSTATUS:
+ ret = qlnx_vf_status(ha, (nvlist_t *)data);
+ break;
+#endif
+#endif
+
default:
QL_DPRINT4(ha, "default (0x%lx)\n", cmd);
ret = ether_ioctl(ifp, cmd, data);
@@ -7835,11 +7844,14 @@
qlnx_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *nvlist_params)
{
qlnx_host_t *ha;
+ qlnx_vf_attr_t *vf_attrs;
struct ecore_dev *cdev;
struct ecore_iov_vf_init_params params;
int ret, j, i;
uint32_t max_vfs;
+ vf_attrs = NULL;
+
if ((ha = device_get_softc(dev)) == NULL) {
device_printf(dev, "%s: cannot get softc\n", __func__);
return (-1);
@@ -7861,10 +7873,10 @@
goto qlnx_iov_init_err0;
}
- ha->vf_attr = malloc(((sizeof (qlnx_vf_attr_t) * num_vfs)), M_QLNXBUF,
- M_NOWAIT);
+ vf_attrs = mallocarray(num_vfs, sizeof(*vf_attrs), M_QLNXBUF,
+ M_NOWAIT | M_ZERO);
- if (ha->vf_attr == NULL)
+ if (vf_attrs == NULL)
goto qlnx_iov_init_err0;
memset(&params, 0, sizeof(params));
@@ -7899,10 +7911,19 @@
}
}
- ecore_ptt_release(hwfn, ptt);
- }
+ ecore_ptt_release(hwfn, ptt);
+ }
+ for (i = 0; i < num_vfs; i++) {
+ for_each_hwfn(cdev, j)
+ vf_attrs[i].num_rings += ecore_iov_get_vf_num_rxqs(
+ &cdev->hwfns[j], i);
+ }
+
+ QLNX_LOCK(ha);
+ ha->vf_attr = vf_attrs;
ha->num_vfs = num_vfs;
+ QLNX_UNLOCK(ha);
qlnx_inform_vf_link_state(&cdev->hwfns[0], ha);
QL_DPRINT2(ha," dev = %p exit num_vfs = %d\n", dev, num_vfs);
@@ -7914,7 +7935,7 @@
qlnx_iov_init_err0:
qlnx_destroy_pf_taskqueues(ha);
- ha->num_vfs = 0;
+ free(vf_attrs, M_QLNXBUF);
return (-1);
}
@@ -7923,6 +7944,7 @@
qlnx_iov_uninit(device_t dev)
{
qlnx_host_t *ha;
+ qlnx_vf_attr_t *vf_attrs;
if ((ha = device_get_softc(dev)) == NULL) {
device_printf(dev, "%s: cannot get softc\n", __func__);
@@ -7934,10 +7956,12 @@
qlnx_sriov_disable(ha);
qlnx_destroy_pf_taskqueues(ha);
- free(ha->vf_attr, M_QLNXBUF);
+ QLNX_LOCK(ha);
+ vf_attrs = ha->vf_attr;
ha->vf_attr = NULL;
-
ha->num_vfs = 0;
+ QLNX_UNLOCK(ha);
+ free(vf_attrs, M_QLNXBUF);
QL_DPRINT2(ha," dev = %p exit\n", dev);
return;
@@ -7949,8 +7973,10 @@
qlnx_host_t *ha;
qlnx_vf_attr_t *vf_attr;
unsigned const char *mac;
+ uint8_t mac_addr[ETHER_ADDR_LEN];
size_t size;
struct ecore_hwfn *p_hwfn;
+ enum _ecore_status_t rc;
if ((ha = device_get_softc(dev)) == NULL) {
device_printf(dev, "%s: cannot get softc\n", __func__);
@@ -7959,31 +7985,91 @@
QL_DPRINT2(ha," dev = %p enter vfnum = %d\n", dev, vfnum);
- if (vfnum > (ha->num_vfs - 1)) {
- QL_DPRINT1(ha, " VF[%d] is greater than max allowed [%d]\n",
- vfnum, (ha->num_vfs - 1));
+ QLNX_LOCK(ha);
+ if (ha->vf_attr == NULL || vfnum >= ha->num_vfs) {
+ QL_DPRINT1(ha, "VF[%u] is not configured\n", vfnum);
+ QLNX_UNLOCK(ha);
+ return (EINVAL);
}
-
- vf_attr = &ha->vf_attr[vfnum];
+ QLNX_UNLOCK(ha);
+ bzero(mac_addr, sizeof(mac_addr));
if (nvlist_exists_binary(params, "mac-addr")) {
mac = nvlist_get_binary(params, "mac-addr", &size);
- bcopy(mac, vf_attr->mac_addr, ETHER_ADDR_LEN);
+ if (size != ETHER_ADDR_LEN)
+ return (EINVAL);
+ bcopy(mac, mac_addr, ETHER_ADDR_LEN);
device_printf(dev,
"%s: mac_addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
- __func__, vf_attr->mac_addr[0],
- vf_attr->mac_addr[1], vf_attr->mac_addr[2],
- vf_attr->mac_addr[3], vf_attr->mac_addr[4],
- vf_attr->mac_addr[5]);
+ __func__, mac_addr[0], mac_addr[1], mac_addr[2],
+ mac_addr[3], mac_addr[4], mac_addr[5]);
p_hwfn = &ha->cdev.hwfns[0];
- ecore_iov_bulletin_set_mac(p_hwfn, vf_attr->mac_addr,
- vfnum);
+ rc = ecore_iov_bulletin_set_mac(p_hwfn, mac_addr, vfnum);
+ if (rc != ECORE_SUCCESS)
+ return (EIO);
}
+ QLNX_LOCK(ha);
+ if (ha->vf_attr == NULL || vfnum >= ha->num_vfs) {
+ QLNX_UNLOCK(ha);
+ return (ENXIO);
+ }
+ vf_attr = &ha->vf_attr[vfnum];
+ bcopy(mac_addr, vf_attr->mac_addr, ETHER_ADDR_LEN);
+ vf_attr->configured = true;
+ QLNX_UNLOCK(ha);
+
QL_DPRINT2(ha," dev = %p exit vfnum = %d\n", dev, vfnum);
return (0);
}
+static int
+qlnx_vf_status(qlnx_host_t *ha, nvlist_t *status)
+{
+ qlnx_vf_attr_t *snapshot;
+ nvlist_t **vfs;
+ uint16_t num_vfs;
+ int error, i;
+
+ QLNX_LOCK(ha);
+ num_vfs = ha->num_vfs;
+ if (num_vfs == 0 || ha->vf_attr == NULL) {
+ QLNX_UNLOCK(ha);
+ return (ENXIO);
+ }
+ snapshot = mallocarray(num_vfs, sizeof(*snapshot), M_QLNXBUF,
+ M_NOWAIT);
+ if (snapshot == NULL) {
+ QLNX_UNLOCK(ha);
+ return (ENOMEM);
+ }
+ bcopy(ha->vf_attr, snapshot, num_vfs * sizeof(*snapshot));
+ QLNX_UNLOCK(ha);
+
+ vfs = mallocarray(num_vfs, sizeof(*vfs), M_QLNXBUF,
+ M_WAITOK | M_ZERO);
+ for (i = 0; i < num_vfs; i++) {
+ vfs[i] = nvlist_create(0);
+ nvlist_add_number(vfs[i], IFVF_STATUS_INDEX, i);
+ nvlist_add_bool(vfs[i], IFVF_STATUS_CONFIGURED,
+ snapshot[i].configured);
+ if (!ETHER_IS_ZERO(snapshot[i].mac_addr))
+ nvlist_add_binary(vfs[i], IFVF_STATUS_MAC,
+ snapshot[i].mac_addr, ETHER_ADDR_LEN);
+ if (snapshot[i].num_rings != 0)
+ nvlist_add_number(vfs[i], IFVF_STATUS_NUM_QUEUES,
+ snapshot[i].num_rings);
+ }
+ free(snapshot, M_QLNXBUF);
+ nvlist_add_nvlist_array(status, IFVF_STATUS_VFS,
+ (const nvlist_t * const *)vfs, num_vfs);
+ error = nvlist_error(status);
+ for (i = 0; i < num_vfs; i++)
+ nvlist_destroy(vfs[i]);
+ free(vfs, M_QLNXBUF);
+ return (error);
+}
+
static void
qlnx_handle_vf_msg(qlnx_host_t *ha, struct ecore_hwfn *p_hwfn)
{

File Metadata

Mime Type
text/plain
Expires
Sat, Aug 22, 2:50 PM (2 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36990942
Default Alt Text
D58742.id183720.diff (6 KB)

Event Timeline