From patchwork Tue Mar 28 03:48:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 22476 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B3621D14E; Tue, 28 Mar 2017 05:50:02 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (lpdvrndsmtp01.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 28D2E3277 for ; Tue, 28 Mar 2017 05:49:18 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.224.233]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 2F69430D2A9; Mon, 27 Mar 2017 20:49:17 -0700 (PDT) Received: from C02PT1RBG8WP.vpn.broadcom.net (unknown [10.10.115.230]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 210BA81E9C; Mon, 27 Mar 2017 20:49:17 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: Stephen Hurd Date: Mon, 27 Mar 2017 22:48:52 -0500 Message-Id: <20170328034903.41482-18-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170328034903.41482-1-ajit.khaparde@broadcom.com> References: <20170328034903.41482-1-ajit.khaparde@broadcom.com> Subject: [dpdk-dev] [PATCH 17/28] bnxt: implement VF VLAN stripq functionality X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Signed-off-by: Ajit Khaparde --- 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; };