[dpdk-dev] [PATCH 17/28] bnxt: implement VF VLAN stripq functionality
Ajit Khaparde
ajit.khaparde at broadcom.com
Tue Mar 28 05:48:52 CEST 2017
This patch adds code to configure VF VLAN stripping feature.
Reorganize the bnxt_hwrm_func_vf_stall() to bnxt_hwrm_func_vf_vnic_cfg_do
which will take a callback and use that for configuring with a VFs VNICs.
Signed-off-by: Stephen Hurd <stephen.hurd at broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 107 ++++++++++++++++--------------
drivers/net/bnxt/bnxt_hwrm.h | 4 +-
drivers/net/bnxt/rte_pmd_bnxt.c | 49 +++++++++++++-
drivers/net/bnxt/rte_pmd_bnxt.h | 20 ++++++
drivers/net/bnxt/rte_pmd_bnxt_version.map | 1 +
5 files changed, 129 insertions(+), 52 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 7247cdc..a840683 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1030,56 +1030,6 @@ int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp,
return rc;
}
-int bnxt_hwrm_func_vf_stall(struct bnxt *bp, uint16_t vf, uint8_t on)
-{
- struct hwrm_func_vf_vnic_ids_query_input req = {0};
- struct hwrm_func_vf_vnic_ids_query_output *resp =
- bp->hwrm_cmd_resp_addr;
- struct bnxt_vnic_info vnic;
- int rc;
- uint32_t i, num_vnic_ids;
- uint16_t *vnic_ids;
-
- /* First query all VNIC ids */
-
- vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query",
- bp->pf.total_vnics * sizeof(*vnic_ids),
- RTE_CACHE_LINE_SIZE);
- if (vnic_ids == NULL)
- return -ENOMEM;
-
- HWRM_PREP(req, FUNC_VF_VNIC_IDS_QUERY, -1, resp_vf_vnic_ids);
-
- req.vf_id = rte_cpu_to_le_16(bp->pf.first_vf_id + vf);
- req.max_vnic_id_cnt = rte_cpu_to_le_32(bp->pf.total_vnics);
- req.vnic_id_tbl_addr = rte_malloc_virt2phy(vnic_ids);
-
- rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
- HWRM_CHECK_RESULT;
-
- num_vnic_ids = rte_le_to_cpu_32(resp->vnic_id_cnt);
-
- /* Retrieve VNIC, update bd_stall then update */
-
- for (i = 0; i < num_vnic_ids; i++) {
- memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
- vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
- rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf.first_vf_id + vf);
- if (rc)
- break;
-
- vnic.bd_stall = on;
-
- rc = bnxt_hwrm_vnic_cfg(bp, &vnic);
- if (rc)
- break;
- }
-
- rte_free(vnic_ids);
-
- return rc;
-}
-
int bnxt_hwrm_func_vf_mac(struct bnxt *bp, uint16_t vf, uint8_t *mac_addr)
{
struct hwrm_func_cfg_input req = {0};
@@ -2194,3 +2144,60 @@ int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf)
return rc;
}
+
+int bnxt_hwrm_func_vf_vnic_cfg_do(struct bnxt *bp, uint16_t vf,
+ void (*vnic_cb)(struct bnxt_vnic_info *,
+ void *), void *cbdata)
+{
+ struct hwrm_func_vf_vnic_ids_query_input req = {0};
+ struct hwrm_func_vf_vnic_ids_query_output *resp =
+ bp->hwrm_cmd_resp_addr;
+ struct bnxt_vnic_info vnic;
+ int rc;
+ uint32_t i, num_vnic_ids;
+ uint16_t *vnic_ids;
+ size_t vnic_id_sz;
+
+ /* First query all VNIC ids */
+
+ vnic_id_sz = bp->pf.total_vnics * sizeof(*vnic_ids);
+ vnic_ids = rte_malloc("bnxt_hwrm_vf_vnic_ids_query", vnic_id_sz,
+ RTE_CACHE_LINE_SIZE);
+ if (vnic_ids == NULL) {
+ rc = -ENOMEM;
+ return rc;
+ }
+ for (i = 0; i < vnic_id_sz; i += rte_eal_get_physmem_size())
+ rte_mem_lock_page(((char *)vnic_ids) + i);
+
+ HWRM_PREP(req, FUNC_VF_VNIC_IDS_QUERY, -1, resp_vf_vnic_ids);
+
+ req.vf_id = rte_cpu_to_le_16(bp->pf.first_vf_id + vf);
+ req.max_vnic_id_cnt = rte_cpu_to_le_32(bp->pf.total_vnics);
+ req.vnic_id_tbl_addr = rte_mem_virt2phy(vnic_ids);
+
+ rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
+ HWRM_CHECK_RESULT;
+
+ num_vnic_ids = rte_le_to_cpu_32(resp->vnic_id_cnt);
+
+ /* Retrieve VNIC, update bd_stall then update */
+
+ for (i = 0; i < num_vnic_ids; i++) {
+ memset(&vnic, 0, sizeof(struct bnxt_vnic_info));
+ vnic.fw_vnic_id = rte_le_to_cpu_16(vnic_ids[i]);
+ rc = bnxt_hwrm_vnic_qcfg(bp, &vnic, bp->pf.first_vf_id + vf);
+ if (rc)
+ break;
+
+ vnic_cb(&vnic, cbdata);
+
+ rc = bnxt_hwrm_vnic_cfg(bp, &vnic);
+ if (rc)
+ break;
+ }
+
+ rte_free(vnic_ids);
+
+ return rc;
+}
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 636ac13..b6c73ec 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -109,7 +109,6 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up);
int bnxt_hwrm_func_qcfg(struct bnxt *bp);
int bnxt_hwrm_allocate_pf_only(struct bnxt *bp);
int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs);
-int bnxt_hwrm_func_vf_stall(struct bnxt *bp, uint16_t vf, uint8_t on);
int bnxt_hwrm_func_vf_mac(struct bnxt *bp, uint16_t vf, uint8_t *mac_addr);
int bnxt_hwrm_pf_evb_mode(struct bnxt *bp);
int bnxt_hwrm_set_vf_vlan(struct bnxt *bp, int vf, uint16_t vlan);
@@ -121,4 +120,7 @@ int bnxt_hwrm_tunnel_dst_port_free(struct bnxt *bp, uint16_t port,
uint8_t tunnel_type);
void bnxt_free_tunnel_ports(struct bnxt *bp);
int bnxt_hwrm_func_cfg_vf_set_flags(struct bnxt *bp, uint16_t vf);
+int bnxt_hwrm_func_vf_vnic_cfg_do(struct bnxt *bp, uint16_t vf,
+ void (*vnic_cb)(struct bnxt_vnic_info *,
+ void *), void *cbdata);
#endif
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
index d2a8532..afefe3a 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.c
+++ b/drivers/net/bnxt/rte_pmd_bnxt.c
@@ -78,6 +78,13 @@ int rte_pmd_bnxt_set_tx_loopback(uint8_t port, uint8_t on)
return rc;
}
+static void
+rte_pmd_bnxt_set_all_queues_drop_en_cb(struct bnxt_vnic_info *vnic, void *onptr)
+{
+ uint8_t *on = onptr;
+ vnic->bd_stall = !(*on);
+}
+
int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on)
{
struct rte_eth_dev *eth_dev;
@@ -114,7 +121,8 @@ int rte_pmd_bnxt_set_all_queues_drop_en(uint8_t port, uint8_t on)
/* Stall all active VFs */
for (i = 0; i < bp->pf.active_vfs; i++) {
- rc = bnxt_hwrm_func_vf_stall(bp, i, !on);
+ rc = bnxt_hwrm_func_vf_vnic_cfg_do(bp, i,
+ rte_pmd_bnxt_set_all_queues_drop_en_cb, &on);
if (rc) {
RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", i);
break;
@@ -299,3 +307,42 @@ int rte_pmd_bnxt_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
return rc;
}
+static void
+rte_pmd_bnxt_set_vf_vlan_stripq_cb(struct bnxt_vnic_info *vnic, void *onptr)
+{
+ uint8_t *on = onptr;
+ vnic->vlan_strip = *on;
+}
+
+int
+rte_pmd_bnxt_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on)
+{
+ struct rte_eth_dev *dev;
+ struct rte_eth_dev_info dev_info;
+ struct bnxt *bp;
+ int rc;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+ rte_eth_dev_info_get(port, &dev_info);
+ bp = (struct bnxt *)dev->data->dev_private;
+
+ if (vf >= dev_info.max_vfs)
+ return -EINVAL;
+
+ if (!BNXT_PF(bp)) {
+ RTE_LOG(ERR, PMD,
+ "Attempt to set VF %d stripq on non-PF port %d!\n",
+ vf, port);
+ return -ENOTSUP;
+ }
+
+ rc = bnxt_hwrm_func_vf_vnic_cfg_do(bp, vf,
+ rte_pmd_bnxt_set_vf_vlan_stripq_cb,
+ &on);
+ if (rc)
+ RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", vf);
+
+ return rc;
+}
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.h b/drivers/net/bnxt/rte_pmd_bnxt.h
index 40e68ee..a17be1d 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.h
+++ b/drivers/net/bnxt/rte_pmd_bnxt.h
@@ -54,6 +54,26 @@ int rte_pmd_bnxt_set_vf_mac_addr(uint8_t port, uint16_t vf,
struct ether_addr *mac_addr);
/**
+ * Enable/Disable vf vlan strip for all queues in a pool
+ *
+ * @param port
+ * The port identifier of the Ethernet device.
+ * @param vf
+ * ID specifying VF.
+ * @param on
+ * 1 - Enable VF's vlan strip on RX queues.
+ * 0 - Disable VF's vlan strip on RX queues.
+ *
+ * @return
+ * - (0) if successful.
+ * - (-ENOTSUP) if hardware doesn't support this feature.
+ * - (-ENODEV) if *port* invalid.
+ * - (-EINVAL) if bad parameter.
+ */
+int
+rte_pmd_bnxt_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
+
+/**
* Response sent back to bnxt driver from user app after callback
*/
enum rte_pmd_bnxt_mb_event_rsp {
diff --git a/drivers/net/bnxt/rte_pmd_bnxt_version.map b/drivers/net/bnxt/rte_pmd_bnxt_version.map
index 955903b..f8effff 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt_version.map
+++ b/drivers/net/bnxt/rte_pmd_bnxt_version.map
@@ -6,5 +6,6 @@ DPDK_17.05 {
rte_pmd_bnxt_set_vf_mac_addr;
rte_pmd_bnxt_set_vf_vlan_filter;
rte_pmd_bnxt_set_vf_mac_anti_spoof;
+ rte_pmd_bnxt_set_vf_vlan_stripq;
};
--
2.10.1 (Apple Git-78)
More information about the dev
mailing list