Page MenuHomeFreeBSD

D58742.1795932567.diff
No OneTemporary

Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None

D58742.1795932567.diff

diff --git a/sys/dev/qlnx/qlnxe/qlnx_def.h b/sys/dev/qlnx/qlnxe/qlnx_def.h
--- a/sys/dev/qlnx/qlnxe/qlnx_def.h
+++ b/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 {
diff --git a/sys/dev/qlnx/qlnxe/qlnx_os.c b/sys/dev/qlnx/qlnxe/qlnx_os.c
--- a/sys/dev/qlnx/qlnxe/qlnx_os.c
+++ b/sys/dev/qlnx/qlnxe/qlnx_os.c
@@ -70,6 +70,7 @@
#include <sys/nv.h>
#include <sys/iov_schema.h>
#include <dev/pci/pci_iov.h>
+#include <net/if_vf_status.h>
#endif /* #ifdef CONFIG_ECORE_SRIOV */
#include <sys/smp.h>
@@ -172,6 +173,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(if_t ifp, struct if_vf_status **statusp);
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);
@@ -2311,6 +2313,11 @@
if_setsoftc(ifp, ha);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setioctlfn(ifp, qlnx_ioctl);
+#ifndef QLNX_VF
+#ifdef CONFIG_ECORE_SRIOV
+ if_setvfstatusfn(ifp, qlnx_vf_status);
+#endif
+#endif
if_settransmitfn(ifp, qlnx_transmit);
if_setqflushfn(ifp, qlnx_qflush);
@@ -7835,11 +7842,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 +7871,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 +7909,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 +7933,7 @@
qlnx_iov_init_err0:
qlnx_destroy_pf_taskqueues(ha);
- ha->num_vfs = 0;
+ free(vf_attrs, M_QLNXBUF);
return (-1);
}
@@ -7923,6 +7942,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 +7954,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 +7971,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 +7983,94 @@
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(if_t ifp, struct if_vf_status **statusp)
+{
+ qlnx_vf_attr_t *snapshot;
+ struct if_vf_info *vf;
+ struct if_vf_status *status;
+ qlnx_host_t *ha;
+ uint16_t num_vfs;
+ int i;
+
+ ha = if_getsoftc(ifp);
+ 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);
+
+ status = if_vf_status_alloc(num_vfs);
+ if (status == NULL) {
+ free(snapshot, M_QLNXBUF);
+ return (ENOMEM);
+ }
+ for (i = 0; i < num_vfs; i++) {
+ vf = &status->vfs[i];
+ vf->fields = IFVF_F_CONFIGURED;
+ vf->index = i;
+ vf->configured = snapshot[i].configured;
+ if (!ETHER_IS_ZERO(snapshot[i].mac_addr)) {
+ memcpy(vf->mac, snapshot[i].mac_addr, sizeof(vf->mac));
+ vf->fields |= IFVF_F_MAC;
+ }
+ if (snapshot[i].num_rings != 0) {
+ vf->num_queues = snapshot[i].num_rings;
+ vf->fields |= IFVF_F_NUM_QUEUES;
+ }
+ }
+ free(snapshot, M_QLNXBUF);
+ *statusp = status;
+ return (0);
+}
+
static void
qlnx_handle_vf_msg(qlnx_host_t *ha, struct ecore_hwfn *p_hwfn)
{

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 29, 6:09 AM (2 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42085176
Default Alt Text
D58742.1795932567.diff (6 KB)

Event Timeline