Re: [dpdk-dev] [PATCH v2 2/8] net/bnxt: fix to avoid a segfault
So the only change was replacing a nesting level with a continue? Yeah, looks good. On Thu, Jul 20, 2017 at 8:22 PM, Ajit Khaparde wrote: > Fix use of local variable to avoid segfault. > cnt was incorrectly tested and decremented in the loop that removes > a VLAN from the table. > > Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof") > > Signed-off-by: Stephen Hurd > Signed-off-by: Ajit Khaparde > > -- > v1->v2: incorporate review feedback. > --- > drivers/net/bnxt/rte_pmd_bnxt.c | 101 +++--- > -- > 1 file changed, 49 insertions(+), 52 deletions(-) > > diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_ > bnxt.c > index 0a8fb1e..ec5855d 100644 > --- a/drivers/net/bnxt/rte_pmd_bnxt.c > +++ b/drivers/net/bnxt/rte_pmd_bnxt.c > @@ -473,62 +473,59 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, > uint16_t vlan, > > for (i = 0; vf_mask; i++, vf_mask >>= 1) { > cnt = bp->pf.vf_info[i].vlan_count; > - if (vf_mask & 1) { > - if (bp->pf.vf_info[i].vlan_table == NULL) { > - rc = -1; > - continue; > + if ((vf_mask & 1) == 0) > + continue; > + > + if (bp->pf.vf_info[i].vlan_table == NULL) { > + rc = -1; > + continue; > + } > + if (vlan_on) { > + /* First, search for a duplicate... */ > + for (j = 0; j < cnt; j++) { > + if (rte_be_to_cpu_16( > + bp->pf.vf_info[i].vlan_table[j].vid) > == vlan) > + break; > } > - if (vlan_on) { > - /* First, search for a duplicate... */ > - for (j = 0; j < cnt; j++) { > - if (rte_be_to_cpu_16( > -bp->pf.vf_info[i].vlan_table[j].vid) > == > - vlan) > - break; > - } > - if (j == cnt) { > - /* Now check that there's space */ > - if (cnt == getpagesize() / > -sizeof(struct > bnxt_vlan_table_entry)) { > - RTE_LOG(ERR, PMD, > - "VF %d VLAN table is > full\n", > - i); > - RTE_LOG(ERR, PMD, > - "cannot add VLAN > %u\n", > - vlan); > - rc = -1; > - continue; > - } > - > - cnt = > bp->pf.vf_info[i].vlan_count++; > - /* > -* And finally, add to the > -* end of the table > -*/ > - ve = &bp->pf.vf_info[i].vlan_table[ > cnt]; > - /* TODO: Hardcoded TPID */ > - ve->tpid = > rte_cpu_to_be_16(0x8100); > - ve->vid = rte_cpu_to_be_16(vlan); > - } > - } else { > - for (j = 0; cnt; j++) { > - if (rte_be_to_cpu_16( > - bp->pf.vf_info[i].vlan_table[j].vid) > != > - vlan) > - continue; > - memmove( > -&bp->pf.vf_info[i].vlan_table[j], > -&bp->pf.vf_info[i].vlan_table[j > + 1], > -getpagesize() - > -((j + 1) * > -sizeof(struct > bnxt_vlan_table_entry))); > -
[dpdk-dev] [PATCH] bnxt: Update MAINTAINERS file for bnxt driver
On Wed, Sep 21, 2016 at 3:27 PM, Ajit Khaparde wrote: > Add Ajit Khaparde as the maintainer of the bnxt PMD > > CC: Stephen Hurd > Signed-off-by: Ajit Khaparde > Reviewed-by: David Christensen > --- > MAINTAINERS | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/MAINTAINERS b/MAINTAINERS > index 7c33ad4..32df457 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -279,6 +279,7 @@ F: doc/guides/nics/ena.rst > > Broadcom bnxt > M: Stephen Hurd > +M: Ajit Khaparde > F: drivers/net/bnxt/ > F: doc/guides/nics/bnxt.rst > > -- > 2.8.4 (Apple Git-73) > Ack.
[dpdk-dev] [PATCH] app/test-pmd: Detect NUMA socket count
Currently, there is a MAX_SOCKET macro which artificially limits the number of NUMA sockets testpmd can use. Anything on a higher socket ends up using socket zero. This patch replaces this with a variable set during set_default_fwd_lcores_config() and uses RTE_MAX_NUMA_NODES where a hard-coded max number of sockets is required. Signed-off-by: Stephen Hurd --- app/test-pmd/parameters.c | 12 ++-- app/test-pmd/testpmd.c| 17 + app/test-pmd/testpmd.h| 3 +-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index f1daa6e..fe78723 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -398,9 +398,9 @@ parse_portnuma_config(const char *q_arg) return -1; } socket_id = (uint8_t)int_fld[FLD_SOCKET]; - if(socket_id >= MAX_SOCKET) { + if(socket_id >= max_socket) { printf("Invalid socket id, range is [0, %d]\n", -MAX_SOCKET - 1); +max_socket - 1); return -1; } port_numa[port_id] = socket_id; @@ -458,9 +458,9 @@ parse_ringnuma_config(const char *q_arg) return -1; } socket_id = (uint8_t)int_fld[FLD_SOCKET]; - if (socket_id >= MAX_SOCKET) { + if (socket_id >= max_socket) { printf("Invalid socket id, range is [0, %d]\n", - MAX_SOCKET - 1); + max_socket - 1); return -1; } ring_flag = (uint8_t)int_fld[FLD_FLAG]; @@ -667,12 +667,12 @@ launch_args_parse(int argc, char** argv) "invalid ring-numa configuration\n"); if (!strcmp(lgopts[opt_idx].name, "socket-num")) { n = atoi(optarg); - if(n < MAX_SOCKET) + if((uint8_t)n < max_socket) socket_num = (uint8_t)n; else rte_exit(EXIT_FAILURE, "The socket number should be < %d\n", - MAX_SOCKET); + max_socket); } if (!strcmp(lgopts[opt_idx].name, "mbuf-size")) { n = atoi(optarg); diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 386bf84..2578b6b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -313,6 +313,8 @@ struct queue_stats_mappings *rx_queue_stats_mappings = rx_queue_stats_mappings_a uint16_t nb_tx_queue_stats_mappings = 0; uint16_t nb_rx_queue_stats_mappings = 0; +unsigned max_socket = 0; + /* Forward function declarations */ static void map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port *port); static void check_all_ports_link_status(uint32_t port_mask); @@ -345,6 +347,7 @@ set_default_fwd_lcores_config(void) { unsigned int i; unsigned int nb_lc; + unsigned int sock_num; nb_lc = 0; for (i = 0; i < RTE_MAX_LCORE; i++) { @@ -353,6 +356,12 @@ set_default_fwd_lcores_config(void) if (i == rte_get_master_lcore()) continue; fwd_lcores_cpuids[nb_lc++] = i; + sock_num = rte_lcore_to_socket_id(i) + 1; + if (sock_num > max_socket) { + if (sock_num > RTE_MAX_NUMA_NODES) + rte_exit(EXIT_FAILURE, "Total sockets greater than %u\n", RTE_MAX_NUMA_NODES); + max_socket = sock_num; + } } nb_lcores = (lcoreid_t) nb_lc; nb_cfg_lcores = nb_lcores; @@ -446,7 +455,7 @@ check_socket_id(const unsigned int socket_id) { static int warning_once = 0; - if (socket_id >= MAX_SOCKET) { + if (socket_id >= max_socket) { if (!warning_once && numa_support) printf("Warning: NUMA should be configured manually by" " using --port-numa-config and" @@ -466,9 +475,9 @@ init_config(void) struct rte_mempool *mbp; unsigned int nb_mbuf_per_pool; lcoreid_t lc_id; - uint8_t port_per_socket[MAX_SOCKET]; + uint8_t port_per_socket[RTE_MAX_NUMA_NODES]; - memset(port_per_socket,0,MAX_SOCKET); + memset(port_per_socket,0,RTE_MAX_NUMA_NODES); /* Configuration of logical cores. */ fwd_lcores = rte_zmall
[dpdk-dev] [PATCH] app/testpmd Fix max_socket detection
Previously, max_socket was set to the highest numbered socket with an enabled lcore. The intent is to set it to the highest socket regardless of it being enabled. Change-Id: I6306af0f90aa3c1fc5ffed75d1eed8297d29e132 Signed-off-by: Stephen Hurd --- app/test-pmd/testpmd.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 6129c26..26a2cce 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -359,17 +359,17 @@ set_default_fwd_lcores_config(void) nb_lc = 0; for (i = 0; i < RTE_MAX_LCORE; i++) { + if (sock_num > max_socket) { + if (sock_num > RTE_MAX_NUMA_NODES) + rte_exit(EXIT_FAILURE, "Total sockets greater than %u\n", RTE_MAX_NUMA_NODES); + max_socket = sock_num; + } if (! rte_lcore_is_enabled(i)) continue; if (i == rte_get_master_lcore()) continue; fwd_lcores_cpuids[nb_lc++] = i; sock_num = rte_lcore_to_socket_id(i) + 1; - if (sock_num > max_socket) { - if (sock_num > RTE_MAX_NUMA_NODES) - rte_exit(EXIT_FAILURE, "Total sockets greater than %u\n", RTE_MAX_NUMA_NODES); - max_socket = sock_num; - } } nb_lcores = (lcoreid_t) nb_lc; nb_cfg_lcores = nb_lcores; -- 1.9.1
[dpdk-dev] [PATCH v2] app/testpmd Fix max_socket detection
Previously, max_socket was set to the highest numbered socket with an enabled lcore. The intent is to set it to the highest socket regardless of it being enabled. Change-Id: I6306af0f90aa3c1fc5ffed75d1eed8297d29e132 Signed-off-by: Stephen Hurd v2: Forgot to commit before sending email... sorry for the nouse. --- app/test-pmd/testpmd.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 6129c26..a4088f9 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -359,17 +359,17 @@ set_default_fwd_lcores_config(void) nb_lc = 0; for (i = 0; i < RTE_MAX_LCORE; i++) { - if (! rte_lcore_is_enabled(i)) - continue; - if (i == rte_get_master_lcore()) - continue; - fwd_lcores_cpuids[nb_lc++] = i; sock_num = rte_lcore_to_socket_id(i) + 1; if (sock_num > max_socket) { if (sock_num > RTE_MAX_NUMA_NODES) rte_exit(EXIT_FAILURE, "Total sockets greater than %u\n", RTE_MAX_NUMA_NODES); max_socket = sock_num; } + if (! rte_lcore_is_enabled(i)) + continue; + if (i == rte_get_master_lcore()) + continue; + fwd_lcores_cpuids[nb_lc++] = i; } nb_lcores = (lcoreid_t) nb_lc; nb_cfg_lcores = nb_lcores; -- 1.9.1
[dpdk-dev] [PATCH v2] app/testpmd Fix max_socket detection
Yes, this is cause a bug which prevents cross-socket testing... per michael.qiu at intel.com on Fri 12/18/2015 5:33 PM (unable to find email on the list) >> Hi, Stephen >> >> I just see this patch and found some issue with it. >> >> When I start testpmd with -c 0x3 but with socket-num 1, that means run >> lcore in socket 0, but want hugepage allocated in socket 1, in previous, >> it works, I don't know why you force it in the socket lcore locates.I >> would like to give a warning instead of failure. just like before: >> >> EAL: Requesting 512 pages of size 2MB from socket 1 >> EAL: TSC frequency is ~2294689 KHz >> EAL: WARNING: Master core has no memory on local socket! >> >> After your patch: >> >> EAL: No probed ethernet devices >> Interactive-mode selected >> EAL: Error - exiting with code: 1 >> Cause: The socket number should be < 1 >> His example command was: ./testpmd -c 0x3 -n 4 -- -i -socket-num=1 -- Stephen Hurd -Original Message- From: Bruce Richardson [mailto:bruce.richard...@intel.com] Sent: Thursday, January 14, 2016 5:44 AM To: Stephen Hurd Cc: dev at dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] app/testpmd Fix max_socket detection On Wed, Jan 13, 2016 at 02:23:36PM -0800, Stephen Hurd wrote: > Previously, max_socket was set to the highest numbered socket with > an enabled lcore. The intent is to set it to the highest socket > regardless of it being enabled. > Can you clarify why this changes is necessary? Is it causing a bug somewhere? thanks, /Bruce
[dpdk-dev] [PATCH v2] app/testpmd Fix max_socket detection
Found it... http://www.dpdk.org/ml/archives/dev/2015-December/030564.html -- Stephen Hurd -Original Message- From: Bruce Richardson [mailto:bruce.richard...@intel.com] Sent: Thursday, January 14, 2016 5:44 AM To: Stephen Hurd Cc: dev at dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] app/testpmd Fix max_socket detection On Wed, Jan 13, 2016 at 02:23:36PM -0800, Stephen Hurd wrote: > Previously, max_socket was set to the highest numbered socket with > an enabled lcore. The intent is to set it to the highest socket > regardless of it being enabled. > Can you clarify why this changes is necessary? Is it causing a bug somewhere? thanks, /Bruce
[dpdk-dev] [PATCH v5 03/38] bnxt: add driver register/unregister support
From: Ajit Khaparde Move init() cleanup into uninit() function Fix .dev_private_size New HWRM calls: bnxt_hwrm_func_driver_register: This command is used by the function driver to register its information with the HWRM. bnxt_hwrm_func_driver_unregister: This command is used by the function driver to unregister with the HWRM. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comment regarding removal of bnxt_dev_close_op v5: Reformat footer Add HWRM function descriptions --- drivers/net/bnxt/bnxt.h| 1 + drivers/net/bnxt/bnxt_ethdev.c | 29 +++- drivers/net/bnxt/bnxt_hwrm.c | 50 ++ drivers/net/bnxt/bnxt_hwrm.h | 3 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 271 + 5 files changed, 350 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 8cb7f5b..ed057ef 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -91,6 +91,7 @@ struct bnxt { struct rte_pci_device *pdev; uint32_tflags; +#define BNXT_FLAG_REGISTERED (1 << 0) #define BNXT_FLAG_VF (1 << 1) #define BNXT_PF(bp)(!((bp)->flags & BNXT_FLAG_VF)) #define BNXT_VF(bp)((bp)->flags & BNXT_FLAG_VF) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 32ed081..26e6447 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -176,17 +176,38 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) memcpy(bp->mac_addr, bp->vf.mac_addr, sizeof(bp->mac_addr)); memcpy(ð_dev->data->mac_addrs[0], bp->mac_addr, ETHER_ADDR_LEN); - return -EPERM; + rc = bnxt_hwrm_func_driver_register(bp, 0, + bp->pf.vf_req_fwd); + if (rc) { + RTE_LOG(ERR, PMD, + "Failed to register driver"); + rc = -EBUSY; + goto error_free; + } + + RTE_LOG(INFO, PMD, + DRV_MODULE_NAME " found at mem %" PRIx64 ", node addr %pM\n", + eth_dev->pci_dev->mem_resource[0].phys_addr, + eth_dev->pci_dev->mem_resource[0].addr); + + return 0; error_free: - bnxt_dev_close_op(eth_dev); + eth_dev->driver->eth_dev_uninit(eth_dev); error: return rc; } static int -bnxt_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused) { - return 0; +bnxt_dev_uninit(struct rte_eth_dev *eth_dev) { + struct bnxt *bp = eth_dev->data->dev_private; + int rc; + + if (eth_dev->data->mac_addrs) + rte_free(eth_dev->data->mac_addrs); + rc = bnxt_hwrm_func_driver_unregister(bp, 0); + bnxt_free_hwrm_resources(bp); + return rc; } static struct eth_driver bnxt_rte_pmd = { diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index e187121..8aba8cd 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "bnxt.h" #include "bnxt_hwrm.h" @@ -178,6 +179,34 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp) return rc; } +int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags, + uint32_t *vf_req_fwd) +{ + int rc; + struct hwrm_func_drv_rgtr_input req = {.req_type = 0 }; + struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr; + + if (bp->flags & BNXT_FLAG_REGISTERED) + return 0; + + HWRM_PREP(req, FUNC_DRV_RGTR, -1, resp); + req.flags = flags; + req.enables = HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER; + req.ver_maj = RTE_VER_YEAR; + req.ver_min = RTE_VER_MONTH; + req.ver_upd = RTE_VER_MINOR; + + memcpy(req.vf_req_fwd, vf_req_fwd, sizeof(req.vf_req_fwd)); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->flags |= BNXT_FLAG_REGISTERED; + + return rc; +} + int bnxt_hwrm_ver_get(struct bnxt *bp) { int rc = 0; @@ -264,6 +293,27 @@ error: return rc; } +int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags) +{ + int rc; + struct hwrm_func_drv_unrgtr_input req = {.req_type = 0 }; + struct hwrm_func_drv_unrgtr_output *resp = bp->hwrm_cmd_resp_addr; + + if (!(bp->flags & BNXT_FLAG_REGISTERED)) + return 0; + + HWRM_PREP(req, FUNC_DRV_UNRGTR, -1, resp); + req.flags = flags; + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->flags &= ~BNXT_FLAG_REGISTERED; + + return rc; +} + int bnxt_hwrm_queu
[dpdk-dev] [PATCH v5 02/38] bnxt: add HWRM init code
From: Ajit Khaparde Start adding support to use the HWRM API. Hardware Resource Manager or HWRM in short, is a set of API provided by the firmware running in the ASIC to manage the various resources. Initial commit just performs necessary HWRM queries for init, then fails as before. Now that struct bnxt is non-zero size, we can set dev_private_size correctly. The used HWRM calls so far: bnxt_hwrm_func_qcaps: This command returns capabilities of a function. bnxt_hwrm_ver_get: This function is called by a driver to determine the HWRM interface version supported by the HWRM firmware, the version of HWRM firmware implementation, the name of HWRM firmware, the versions of other embedded firmwares, and the names of other embedded firmwares, etc. Gets the firmware version and interface specifications. Returns an error if the firmware on the device is not supported by the driver and ensures the response space is large enough for the largest possible response. bnxt_hwrm_queue_qportcfg: This function is called by a driver to query queue configuration of a port. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix few issues highlighted by checkpatch. v5: Fix footer formatting Switch to using the HWRM function descriptions from the source documentation --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 114 drivers/net/bnxt/bnxt_ethdev.c | 111 +++- drivers/net/bnxt/bnxt_hwrm.c | 324 +++ drivers/net/bnxt/bnxt_hwrm.h | 53 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 954 + 6 files changed, 1555 insertions(+), 2 deletions(-) create mode 100644 drivers/net/bnxt/bnxt.h create mode 100644 drivers/net/bnxt/bnxt_hwrm.c create mode 100644 drivers/net/bnxt/bnxt_hwrm.h create mode 100644 drivers/net/bnxt/hsi_struct_def_dpdk.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index f6333fd..9965597 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -49,6 +49,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c # # Export include files diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h new file mode 100644 index 000..8cb7f5b --- /dev/null +++ b/drivers/net/bnxt/bnxt.h @@ -0,0 +1,114 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _BNXT_H_ +#define _BNXT_H_ + +#include +#include + +#include +#include +#include +#include + +struct bnxt_vf_info { + uint16_tfw_fid; + uint8_t mac_addr[ETHER_ADDR_LEN]; + uint16_tmax_rsscos_ctx; + uint16_tmax_cp_rings; + uint16_tmax_tx_rings; + uint16_tmax_rx_rings; + uint16_tmax_l2_ctx; + uint16_tmax_vnics; + struct bnxt_pf_info *pf; +}; + +struct bnxt_pf_info { +#define BNXT_FIRST_PF_FID 1 +#define BNXT_MAX_VFS(bp) (bp->pf.max_vfs) +#define BNXT_FIRST_VF_FID 128 +#define BNXT_PF_
[dpdk-dev] [PATCH v5 07/38] bnxt: declare generic ring structs and free() func
From: Ajit Khaparde Declare generic ring structures and a free() function. These are generic ring mamagement functions which will be used to create Tx, Rx and Completion rings in the subsequent patches, and tie them to the HWRM managed ring resources. This generic ring structure is shared all the ring types and tracks the the host Buffer Descriptors (BDs) and the HWRM assigned ID. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address checkpatch warnings. v5: Reorder footer --- drivers/net/bnxt/Makefile| 1 + drivers/net/bnxt/bnxt_ring.c | 47 ++ drivers/net/bnxt/bnxt_ring.h | 92 3 files changed, 140 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_ring.c create mode 100644 drivers/net/bnxt/bnxt_ring.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index c57afaa..757ea62 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c new file mode 100644 index 000..b57d3ba --- /dev/null +++ b/drivers/net/bnxt/bnxt_ring.c @@ -0,0 +1,47 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bnxt.h" +#include "bnxt_ring.h" + +/* + * Generic ring handling + */ + +void bnxt_free_ring(struct bnxt_ring *ring) +{ + if (ring->vmem_size && *ring->vmem) { + memset((char *)*ring->vmem, 0, ring->vmem_size); + *ring->vmem = NULL; + } +} diff --git a/drivers/net/bnxt/bnxt_ring.h b/drivers/net/bnxt/bnxt_ring.h new file mode 100644 index 000..3abfb04 --- /dev/null +++ b/drivers/net/bnxt/bnxt_ring.h @@ -0,0 +1,92 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU
[dpdk-dev] [PATCH v5 05/38] bnxt: add dev configure operation
From: Ajit Khaparde The dev_configure_op function calls bnxt_set_hwrm_link_config() to setup the PHY. This calls the new bnxt_parse_eth_link_*() functions to translate from the DPDK macro values to those used by HWRM calls, then calls bnxt_hwrm_port_phy_cfg() to issue the HWRM call. New HWRM calls: bnxt_hwrm_port_phy_cfg: This command configures the PHY device for the port. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fixed few issues identified by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt.h| 32 +++ drivers/net/bnxt/bnxt_ethdev.c | 24 ++ drivers/net/bnxt/bnxt_hwrm.c | 230 drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 470 + 5 files changed, 757 insertions(+) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index f8707b2..bfce91e 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -81,6 +81,29 @@ struct bnxt_pf_info { struct bnxt_vf_info *vf; }; +/* Max wait time is 10 * 100ms = 1s */ +#define BNXT_LINK_WAIT_CNT 10 +#define BNXT_LINK_WAIT_INTERVAL100 +struct bnxt_link_info { + uint8_t phy_flags; + uint8_t mac_type; + uint8_t phy_link_status; + uint8_t loop_back; + uint8_t link_up; + uint8_t duplex; + uint8_t pause; + uint8_t force_pause; + uint8_t auto_pause; + uint8_t auto_mode; +#define PHY_VER_LEN3 + uint8_t phy_ver[PHY_VER_LEN]; + uint16_tlink_speed; + uint16_tsupport_speeds; + uint16_tauto_link_speed; + uint16_tauto_link_speed_mask; + uint32_tpreemphasis; +}; + #define BNXT_COS_QUEUE_COUNT 8 struct bnxt_cos_queue_info { uint8_t id; @@ -99,6 +122,14 @@ struct bnxt { #define BNXT_PF(bp)(!((bp)->flags & BNXT_FLAG_VF)) #define BNXT_VF(bp)((bp)->flags & BNXT_FLAG_VF) + unsigned intrx_nr_rings; + unsigned intrx_cp_nr_rings; + struct bnxt_rx_queue **rx_queues; + + unsigned inttx_nr_rings; + unsigned inttx_cp_nr_rings; + struct bnxt_tx_queue **tx_queues; + #define MAX_NUM_MAC_ADDR 32 uint8_t mac_addr[ETHER_ADDR_LEN]; @@ -109,6 +140,7 @@ struct bnxt { uint16_tmax_req_len; uint16_tmax_resp_len; + struct bnxt_link_info link_info; struct bnxt_cos_queue_info cos_queue[BNXT_COS_QUEUE_COUNT]; struct bnxt_pf_info pf; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index a8a9912..b46d2ce 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -154,6 +154,29 @@ found: dev_info->vmdq_queue_base = 0; } +/* Configure the device based on the configuration provided */ +static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + int rc; + + bp->rx_queues = (void *)eth_dev->data->rx_queues; + bp->tx_queues = (void *)eth_dev->data->tx_queues; + + /* Inherit new configurations */ + bp->rx_nr_rings = eth_dev->data->nb_rx_queues; + bp->tx_nr_rings = eth_dev->data->nb_tx_queues; + bp->rx_cp_nr_rings = bp->rx_nr_rings; + bp->tx_cp_nr_rings = bp->tx_nr_rings; + + if (eth_dev->data->dev_conf.rxmode.jumbo_frame) + eth_dev->data->mtu = + eth_dev->data->dev_conf.rxmode.max_rx_pkt_len - + ETHER_HDR_LEN - ETHER_CRC_LEN - VLAN_TAG_SIZE; + rc = bnxt_set_hwrm_link_config(bp, true); + return rc; +} + /* * Initialization */ @@ -161,6 +184,7 @@ found: static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, + .dev_configure = bnxt_dev_configure_op, }; static bool bnxt_vf_pciid(uint16_t id) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 3eabf0c..a2d7815 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -314,6 +314,61 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags) return rc; } +static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf) +{ + int rc = 0; + struct hwrm_port_phy_cfg_input req = {.req_type = 0}; + struct hwrm_port_phy_c
[dpdk-dev] [PATCH v5 08/38] bnxt: add completion ring support
From: Ajit Khaparde Structures, macros, and functions for working with completion rings in the driver. Completion Ring is used by the Ethernet controller to provide the status of transmitted & received packets, report errors, report status changes to the host software, and inter-function forwarding requests. In addition to the generic ring features, a completion ring can have a statistics context that has statistics periodically DMAed to host memory, along with a consumer index. bnxt_handle_async_event() handles completions not related to a specific transmit or receive ring such as link status changes which arrive on the default completion ring. Other physical or virtual functions on the same device may send an HWRM command forward request. In this case, we will pass it through unvalidated. In the future, we will be able to have the PF monitor and control VF access to the HWRM interface if needed. New HWRM Calls: bnxt_hwrm_exec_fwd_resp: Execute an encapsulated command and forward the response. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Reorder footer Expand patch description --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 5 + drivers/net/bnxt/bnxt_cpr.c| 140 drivers/net/bnxt/bnxt_cpr.h| 88 + drivers/net/bnxt/bnxt_hwrm.c | 18 +++ drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 227 + 7 files changed, 481 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_cpr.c create mode 100644 drivers/net/bnxt/bnxt_cpr.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 757ea62..afd1690 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -48,6 +48,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # # all source are stored in SRCS-y # +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_cpr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index d0f84f4..bdd355f 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -42,6 +42,8 @@ #include #include +#include "bnxt_cpr.h" + #define BNXT_MAX_MTU 9000 #define VLAN_TAG_SIZE 4 @@ -137,6 +139,9 @@ struct bnxt { unsigned inttx_cp_nr_rings; struct bnxt_tx_queue **tx_queues; + /* Default completion ring */ + struct bnxt_cp_ring_info*def_cp_ring; + struct bnxt_vnic_info *vnic_info; STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c new file mode 100644 index 000..7de2b9c --- /dev/null +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -0,0 +1,140 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bnxt.h" +#include "bnxt_cpr.h" +#include "bnxt_hwrm.h" +#include "bnxt_ring.h" + +/* + * Async event handling + */ +void bnxt_handle_async_event(struct bnxt *bp __rte_unused, +
[dpdk-dev] [PATCH v5 10/38] bnxt: add Tx queue operations (nonfunctional)
From: Ajit Khaparde In this patch we are adding the bnxt_tx_queue_setup_op() and bnxt_tx_queue_release_op() functions. These will be tied to the tx_queue_setup and tx_queue_release dev_ops in a subsequent patch. In these functions we allocate/free memory for the TX queues. This still requires support to create a TX ring in the ASIC which will be completed in a future commit. Each Tx queue created via the tx_queue_setup dev_op will have an associated Tx ring in the hardware. A Tx request coming on the Tx queue gets sent to the corresponding Tx ring in the ASIC for subsequent transmission. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_ethdev.c | 3 + drivers/net/bnxt/bnxt_txq.c| 124 + drivers/net/bnxt/bnxt_txq.h| 75 + 4 files changed, 203 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_txq.c create mode 100644 drivers/net/bnxt/bnxt_txq.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index b7834b1..13a90b9 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b46d2ce..77a6d92 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -41,6 +41,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" +#include "bnxt_txq.h" #define DRV_MODULE_NAME"bnxt" static const char bnxt_version[] = @@ -185,6 +186,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, .dev_configure = bnxt_dev_configure_op, + .tx_queue_setup = bnxt_tx_queue_setup_op, + .tx_queue_release = bnxt_tx_queue_release_op, }; static bool bnxt_vf_pciid(uint16_t id) diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c new file mode 100644 index 000..8928984 --- /dev/null +++ b/drivers/net/bnxt/bnxt_txq.c @@ -0,0 +1,124 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include + +#include "bnxt.h" +#include "bnxt_ring.h" +#include "bnxt_txq.h" + +/* + * TX Queues + */ + +void bnxt_free_txq_stats(struct bnxt_tx_queue *txq) +{ + struct bnxt_cp_ring_info *cpr = txq->cp_ring; + + /* 'Unreserve' rte_memzone */ + + if (cpr->hw_stats) + cpr->hw_stats = NULL; +} + +static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq __rte_unused) +{ + /* TODO: Requires interaction with TX ring */ +} + +void bnxt_free_tx_mbufs(struct bnxt *bp) +{ + struct bnxt_tx_queue *txq; + int i; + + for (i = 0; i < (int)bp->tx_nr_rings; i++) { +
[dpdk-dev] [PATCH v5 12/38] bnxt: add statistics operations
From: Ajit Khaparde Add the bnxt_stats_get_op() and bnxt_stats_reset_op() dev_ops to get and reset staitstics. It also brings in the asociated HWRM calls to handle the requests appropriately. We also have the bnxt_free_stats() function which will be used in the follow on patches to free the memory allocated by the driver for statistics. New HWRM calls: bnxt_hwrm_stat_clear: This command clears statistics of a context Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Add more description for the patch Add HWRM function descriptions Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_cpr.c| 1 + drivers/net/bnxt/bnxt_cpr.h| 2 - drivers/net/bnxt/bnxt_ethdev.c | 3 + drivers/net/bnxt/bnxt_hwrm.c | 49 drivers/net/bnxt/bnxt_hwrm.h | 7 +- drivers/net/bnxt/bnxt_rxq.c| 1 + drivers/net/bnxt/bnxt_stats.c | 142 + drivers/net/bnxt/bnxt_stats.h | 44 ++ drivers/net/bnxt/bnxt_txq.c| 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 107 + 11 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 drivers/net/bnxt/bnxt_stats.c create mode 100644 drivers/net/bnxt/bnxt_stats.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 21ed71c..f6a04f8 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 7de2b9c..5a4b13d 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -35,6 +35,7 @@ #include "bnxt_cpr.h" #include "bnxt_hwrm.h" #include "bnxt_ring.h" +#include "hsi_struct_def_dpdk.h" /* * Async event handling diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h index ecabc5f..2be22de 100644 --- a/drivers/net/bnxt/bnxt_cpr.h +++ b/drivers/net/bnxt/bnxt_cpr.h @@ -34,8 +34,6 @@ #ifndef _BNXT_CPR_H_ #define _BNXT_CPR_H_ -#include "hsi_struct_def_dpdk.h" - #define CMP_VALID(cmp, raw_cons, ring) \ (!!(((struct cmpl_base *)(cmp))->info3_v & CMPL_BASE_V) == \ !((raw_cons) & ((ring)->ring_size))) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 7e7d1ab..3453509 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -42,6 +42,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_stats.h" #include "bnxt_txq.h" #define DRV_MODULE_NAME"bnxt" @@ -187,6 +188,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, .dev_configure = bnxt_dev_configure_op, + .stats_get = bnxt_stats_get_op, + .stats_reset = bnxt_stats_reset_op, .rx_queue_setup = bnxt_rx_queue_setup_op, .rx_queue_release = bnxt_rx_queue_release_op, .tx_queue_setup = bnxt_tx_queue_setup_op, diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 65cd4a7..633683b 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -39,8 +39,11 @@ #include #include "bnxt.h" +#include "bnxt_cpr.h" #include "bnxt_filter.h" #include "bnxt_hwrm.h" +#include "bnxt_rxq.h" +#include "bnxt_txq.h" #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" @@ -480,10 +483,56 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) return rc; } +int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) +{ + int rc = 0; + struct hwrm_stat_ctx_clr_stats_input req = {.req_type = 0 }; + struct hwrm_stat_ctx_clr_stats_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, STAT_CTX_CLR_STATS, -1, resp); + + if (cpr->hw_stats_ctx_id == (uint32_t)HWRM_NA_SIGNATURE) + return rc; + + req.stat_ctx_id = rte_cpu_to_le_16(cpr->hw_stats_ctx_id); + req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + /* * HWRM utility functions */ +int bnxt_clear_all_hwrm_stat_ctxs(st
[dpdk-dev] [PATCH v5 36/38] bnxt: add reta update/query operations
From: Ajit Khaparde Add code to Update/query reta dev_ops Uses the bnxt_hwrm_vnic_rss_cfg() HWRM API added earlier. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 56 ++ 1 file changed, 56 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b04010c..b3b76f1 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -582,6 +582,60 @@ static void bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev) bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); } +static int bnxt_reta_update_op(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; + struct bnxt_vnic_info *vnic; + int i; + + if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)) + return -EINVAL; + + if (reta_size != HW_HASH_INDEX_SIZE) { + RTE_LOG(ERR, PMD, "The configured hash table lookup size " + "(%d) must equal the size supported by the hardware " + "(%d)\n", reta_size, HW_HASH_INDEX_SIZE); + return -EINVAL; + } + /* Update the RSS VNIC(s) */ + for (i = 0; i < MAX_FF_POOLS; i++) { + STAILQ_FOREACH(vnic, &bp->ff_pool[i], next) { + memcpy(vnic->rss_table, reta_conf, reta_size); + + bnxt_hwrm_vnic_rss_cfg(bp, vnic); + } + } + return 0; +} + +static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; + + /* Retrieve from the default VNIC */ + if (!vnic) + return -EINVAL; + if (!vnic->rss_table) + return -EINVAL; + + if (reta_size != HW_HASH_INDEX_SIZE) { + RTE_LOG(ERR, PMD, "The configured hash table lookup size " + "(%d) must equal the size supported by the hardware " + "(%d)\n", reta_size, HW_HASH_INDEX_SIZE); + return -EINVAL; + } + /* EW - need to revisit here copying from u64 to u16 */ + memcpy(reta_conf, vnic->rss_table, reta_size); + + return 0; +} + /* * Initialization */ @@ -600,6 +654,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .rx_queue_release = bnxt_rx_queue_release_op, .tx_queue_setup = bnxt_tx_queue_setup_op, .tx_queue_release = bnxt_tx_queue_release_op, + .reta_update = bnxt_reta_update_op, + .reta_query = bnxt_reta_query_op, .link_update = bnxt_link_update_op, .promiscuous_enable = bnxt_promiscuous_enable_op, .promiscuous_disable = bnxt_promiscuous_disable_op, -- 1.9.1
[dpdk-dev] [PATCH v5 38/38] bnxt: add flow control operations
From: Ajit Khaparde Add flow_ctrl_get and flow_ctrl_set dev_ops. Uses the bnxt_set_hwrm_link_config() HWRM API added in earlier patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 83 ++ 1 file changed, 83 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3c7f868..406e38a 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -755,6 +755,87 @@ static int bnxt_rss_hash_conf_get_op(struct rte_eth_dev *eth_dev, return 0; } +static int bnxt_flow_ctrl_get_op(struct rte_eth_dev *dev, + struct rte_eth_fc_conf *fc_conf __rte_unused) +{ + struct bnxt *bp = (struct bnxt *)dev->data->dev_private; + struct rte_eth_link link_info; + int rc; + + rc = bnxt_get_hwrm_link_config(bp, &link_info); + if (rc) + return rc; + + memset(fc_conf, 0, sizeof(*fc_conf)); + if (bp->link_info.auto_pause) + fc_conf->autoneg = 1; + switch (bp->link_info.pause) { + case 0: + fc_conf->mode = RTE_FC_NONE; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX: + fc_conf->mode = RTE_FC_TX_PAUSE; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX: + fc_conf->mode = RTE_FC_RX_PAUSE; + break; + case (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX | + HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX): + fc_conf->mode = RTE_FC_FULL; + break; + } + return 0; +} + +static int bnxt_flow_ctrl_set_op(struct rte_eth_dev *dev, + struct rte_eth_fc_conf *fc_conf) +{ + struct bnxt *bp = (struct bnxt *)dev->data->dev_private; + + switch (fc_conf->mode) { + case RTE_FC_NONE: + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = 0; + break; + case RTE_FC_RX_PAUSE: + if (fc_conf->autoneg) { + bp->link_info.auto_pause = + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX; + bp->link_info.force_pause = 0; + } else { + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX; + } + break; + case RTE_FC_TX_PAUSE: + if (fc_conf->autoneg) { + bp->link_info.auto_pause = + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX; + bp->link_info.force_pause = 0; + } else { + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX; + } + break; + case RTE_FC_FULL: + if (fc_conf->autoneg) { + bp->link_info.auto_pause = + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX | + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX; + bp->link_info.force_pause = 0; + } else { + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX | + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX; + } + break; + } + return bnxt_set_hwrm_link_config(bp, true); +} + /* * Initialization */ @@ -784,6 +865,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .allmulticast_disable = bnxt_allmulticast_disable_op, .mac_addr_add = bnxt_mac_addr_add_op, .mac_addr_remove = bnxt_mac_addr_remove_op, + .flow_ctrl_get = bnxt_flow_ctrl_get_op, + .flow_ctrl_set = bnxt_flow_ctrl_set_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v5 30/38] bnxt: add start/stop/link update operations
From: Ajit Khaparde This patch adds code to add the start, stop and link update dev_ops. Also adds wraper functions like bnxt_init_chip(), bnxt_init_nic(), bnxt_alloc_mem(), bnxt_free_mem() The BNXT driver will now minimally pass traffic with testpmd. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. Shorten the string passed for reserving memzone when default completion ring is created. v5: Reorder footer --- drivers/net/bnxt/bnxt_ethdev.c | 269 + 1 file changed, 269 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 6888363..ac82876 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -40,12 +40,17 @@ #include #include "bnxt.h" +#include "bnxt_cpr.h" +#include "bnxt_filter.h" #include "bnxt_hwrm.h" +#include "bnxt_ring.h" #include "bnxt_rxq.h" #include "bnxt_rxr.h" #include "bnxt_stats.h" #include "bnxt_txq.h" #include "bnxt_txr.h" +#include "bnxt_vnic.h" +#include "hsi_struct_def_dpdk.h" #define DRV_MODULE_NAME"bnxt" static const char bnxt_version[] = @@ -65,6 +70,177 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) bnxt_free_hwrm_resources(bp); } +/***/ + +/* + * High level utility functions + */ + +static void bnxt_free_mem(struct bnxt *bp) +{ + bnxt_free_filter_mem(bp); + bnxt_free_vnic_attributes(bp); + bnxt_free_vnic_mem(bp); + + bnxt_free_stats(bp); + bnxt_free_tx_rings(bp); + bnxt_free_rx_rings(bp); + bnxt_free_def_cp_ring(bp); +} + +static int bnxt_alloc_mem(struct bnxt *bp) +{ + int rc; + + /* Default completion ring */ + rc = bnxt_init_def_ring_struct(bp, SOCKET_ID_ANY); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_rings(bp, 0, NULL, NULL, + bp->def_cp_ring, "def_cp"); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_vnic_mem(bp); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_vnic_attributes(bp); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_filter_mem(bp); + if (rc) + goto alloc_mem_err; + + return 0; + +alloc_mem_err: + bnxt_free_mem(bp); + return rc; +} + +static int bnxt_init_chip(struct bnxt *bp) +{ + unsigned int i, rss_idx, fw_idx; + int rc; + + rc = bnxt_alloc_all_hwrm_stat_ctxs(bp); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM stat ctx alloc failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_alloc_hwrm_rings(bp); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM ring alloc failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_alloc_all_hwrm_ring_grps(bp); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM ring grp alloc failure: %x\n", rc); + goto err_out; + } + + rc = bnxt_mq_rx_configure(bp); + if (rc) { + RTE_LOG(ERR, PMD, "MQ mode configure failure rc: %x\n", rc); + goto err_out; + } + + /* VNIC configuration */ + for (i = 0; i < bp->nr_vnics; i++) { + struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; + + rc = bnxt_hwrm_vnic_alloc(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM vnic alloc failure rc: %x\n", + rc); + goto err_out; + } + + rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, + "HWRM vnic ctx alloc failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_hwrm_vnic_cfg(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM vnic cfg failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_set_hwrm_vnic_filters(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM vnic filter failure rc: %x\n", + rc); + goto err_out; + } + if (vnic->rss_table && vnic->hash_type) { + /* +* Fill the RSS hash & redirection table with +* ring group ids for all VNICs +*/ + for (rss_idx = 0, fw_idx = 0; +
[dpdk-dev] [PATCH v5 26/38] bnxt: add HWRM stat context free function
From: Ajit Khaparde Add function and associated structures and definitions to free statistics context from the ASIC. New HWRM call: bnxt_hwrm_stat_ctx_free This command is used to free a stat context. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 44 ++ drivers/net/bnxt/bnxt_hwrm.h | 3 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 81 ++ 3 files changed, 128 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index f335401..cb30109 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -742,6 +742,28 @@ int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, return rc; } +int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, + struct bnxt_cp_ring_info *cpr, unsigned int idx) +{ + int rc; + struct hwrm_stat_ctx_free_input req = {.req_type = 0 }; + struct hwrm_stat_ctx_free_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, STAT_CTX_FREE, -1, resp); + + req.stat_ctx_id = rte_cpu_to_le_16(cpr->hw_stats_ctx_id); + req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; + bp->grp_info[idx].fw_stats_ctx = cpr->hw_stats_ctx_id; + + return rc; +} + int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0, i, j; @@ -918,6 +940,28 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp) return 0; } +int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp) +{ + int rc; + unsigned int i; + struct bnxt_cp_ring_info *cpr; + + for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) { + unsigned int idx = i + 1; + + if (i >= bp->rx_cp_nr_rings) + cpr = bp->tx_queues[i - bp->rx_cp_nr_rings]->cp_ring; + else + cpr = bp->rx_queues[i]->cp_ring; + if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) { + rc = bnxt_hwrm_stat_ctx_free(bp, cpr, idx); + if (rc) + return rc; + } + } + return 0; +} + int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) { unsigned int i; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index a9a8dc6..ffb45b1 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -74,6 +74,8 @@ int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx); int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, unsigned int idx); +int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, + struct bnxt_cp_ring_info *cpr, unsigned int idx); int bnxt_hwrm_ver_get(struct bnxt *bp); @@ -87,6 +89,7 @@ int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); +int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp); int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 4e2eb9f..d58295a 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -104,6 +104,7 @@ struct ctx_hw_stats64 { #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) #define HWRM_CFA_L2_SET_RX_MASK(UINT32_C(0x93)) #define HWRM_STAT_CTX_ALLOC(UINT32_C(0xb0)) +#define HWRM_STAT_CTX_FREE (UINT32_C(0xb1)) #define HWRM_STAT_CTX_CLR_STATS(UINT32_C(0xb3)) #define HWRM_EXEC_FWD_RESP (UINT32_C(0xd0)) @@ -3839,6 +3840,86 @@ struct hwrm_stat_ctx_clr_stats_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_stat_ctx_free */ +/* Description: This command is used to free a stat context. */ +/* Input (24 bytes) */ + +struct hwrm_stat_ctx_free_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ +
[dpdk-dev] [PATCH v5 22/38] bnxt: add API for L2 Rx mask set/clear functions
From: Ajit Khaparde Add API to set/clear L2 Rx mask. New HWRM calls: bnxt_hwrm_cfa_l2_clear_rx_mask bnxt_hwrm_cfa_l2_set_rx_mask These HWRM APIs allow setting and clearing of Rx masks in L2 context per VNIC. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 45 +++ drivers/net/bnxt/bnxt_hwrm.h | 3 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 135 + 3 files changed, 183 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 29b0729..2c43159 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -141,6 +141,51 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg, uint32_t msg_len) } \ } +int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 }; + struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, CFA_L2_SET_RX_MASK, -1, resp); + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + req.mask = 0; + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + +int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 }; + struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr; + uint32_t mask = 0; + + HWRM_PREP(req, CFA_L2_SET_RX_MASK, -1, resp); + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + + /* FIXME add multicast flag, when multicast adding options is supported +* by ethtool. +*/ + if (vnic->flags & BNXT_VNIC_INFO_PROMISC) + mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS; + if (vnic->flags & BNXT_VNIC_INFO_ALLMULTI) + mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST; + req.mask = rte_cpu_to_le_32(HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST | + HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST | + mask); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + int bnxt_hwrm_clear_filter(struct bnxt *bp, struct bnxt_filter_info *filter) { diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 8c7b939..8037242 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -43,6 +43,9 @@ struct bnxt_cp_ring_info; #define HWRM_SEQ_ID_INVALID -1U +int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, + struct bnxt_vnic_info *vnic); +int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_clear_filter(struct bnxt *bp, struct bnxt_filter_info *filter); int bnxt_hwrm_set_filter(struct bnxt *bp, diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 72d4984..f8f6a3f 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -1732,6 +1732,141 @@ struct hwrm_cfa_l2_filter_free_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_cfa_l2_set_rx_mask */ +/* Description: This command will set rx mask of the function. */ + +/* Input (40 bytes) */ +struct hwrm_cfa_l2_set_rx_mask_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero before the request is made. +*/ + uint64_t resp_addr; + + /* VNIC ID */ + uint32_t vnic_id; + + /* Reserved for future use. */ + #define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_RESERVED UINT32_C(0x1) + /* +* Whe
[dpdk-dev] [PATCH v5 18/38] bnxt: add HWRM vnic free function
From: Ajit Khaparde In this patch we add a new HWRM API to free a VNIC. A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. New HWRM call: bnxt_hwrm_vnic_free: Frees a vnic allocated by the bnxt_hwrm_vnic_alloc() function. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 21 + drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 82 ++ 3 files changed, 104 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index fb0b7bf..fbbb81d 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -553,6 +553,27 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_free_input req = {.req_type = 0 }; + struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr; + + if (vnic->fw_vnic_id == INVALID_HW_RING_ID) + return rc; + + HWRM_PREP(req, VNIC_FREE, -1, resp); + + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_vnic_id = INVALID_HW_RING_ID; + return rc; +} + /* * HWRM utility functions */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 7d09773..93fb759 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,6 +63,7 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_ver_get(struct bnxt *bp); +int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index eedd368..0771897 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -90,6 +90,7 @@ struct ctx_hw_stats64 { #define HWRM_PORT_PHY_CFG (UINT32_C(0x20)) #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30)) #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) +#define HWRM_VNIC_FREE (UINT32_C(0x41)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3218,6 +3219,87 @@ struct hwrm_vnic_alloc_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_vnic_free */ +/* + * Description: Free a VNIC resource. Idle any resources associated with the + * VNIC as well as the VNIC. Reset and release all resources associated with the + * VNIC. + */ + +/* Input (24 bytes) */ +struct hwrm_vnic_free_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero before the request is made. +*/ + uint64_t resp_addr; + + /* Logical vnic ID */ + uint32_t vnic_id; + + uint32_t unused_0; +} __attribute__((packed)); + +/* Output (16 bytes) */ +struct hwrm_vnic_free_output { + /* +* Pass/Fail or error type Note: receiver to verify the in parameters, +* and fail the call with an error when appropriate +*/ + uint16_t error_code; + + /* This field returns the type of original request. */ + uint16_t req_type; + + /* This field provides original sequence number of the command. */ + uint16_t seq_id; + + /* +* This field is the length of the response in bytes. The last byte of +* the response is a valid flag that will read as
[dpdk-dev] [PATCH v5 20/38] bnxt: add API to allow configuration of vnic
From: Ajit Khaparde This patch adds APIs to allow configuration of a VNIC. The functions alloc and free the Class of Service or COS and Load Balance context corresponding to the VNIC in the chip. New HWRM calls: bnxt_hwrm_vnic_ctx_alloc: Used to allocate COS/Load Balance context of VNIC bnxt_hwrm_vnic_ctx_free: Used to free COS/Load Balance context of VNIC Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: More description in commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 38 drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 153 + 3 files changed, 193 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 0c54129..5a5063f 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -587,6 +587,44 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_rss_cos_lb_ctx_alloc_input req = {.req_type = 0 }; + struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp = + bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_ALLOC, -1, resp); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_rss_cos_lb_ctx = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id); + + return rc; +} + +int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {.req_type = 0 }; + struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp = + bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_FREE, -1, resp); + + req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_rss_cos_lb_ctx = INVALID_HW_RING_ID; + + return rc; +} + int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index cdaa295..fbb8aba 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -65,6 +65,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index ef0b37a..6412df2 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -92,6 +92,8 @@ struct ctx_hw_stats64 { #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_VNIC_FREE (UINT32_C(0x41)) #define HWRM_VNIC_CFG (UINT32_C(0x42)) +#define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC (UINT32_C(0x70)) +#define HWRM_VNIC_RSS_COS_LB_CTX_FREE (UINT32_C(0x71)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3576,6 +3578,157 @@ struct hwrm_vnic_rss_cfg_output { uint8_t valid; } __attribute__((packed)); +/* Input (16 bytes) */ +struct hwrm_vnic_rss_cos_lb_ctx_alloc_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero
[dpdk-dev] [PATCH v5 15/38] bnxt: add code to alloc/free Tx Rx and cmpl rings
From: Ajit Khaparde Perform allocation and free()ing of ring and information structures for the TX, RX, and completion rings. The previous patches had so far provided top level stubs and generic ring support, while this patch does the real allocation and freeing of the memory specific to each different type of generic ring. For example bnxt_init_tx_ring_struct() or bnxt_init_rx_ring_struct() is now allocating memory based on the socked_id being provided. bnxt_tx_queue_setup_op() or bnxt_rx_queue_setup_op() have gone through some reformatting to perform a graceful cleanup in case memory allocation fails. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. Change the argument passed to bnxt_alloc_rings. Instead of passing bnxt_tx_ring and bnxt_rx_ring, shorten them to txr and rxr respectively. Add code to free the reserved memzone v5: More descriptive commit log Reorder footer --- drivers/net/bnxt/bnxt_cpr.c | 28 +++- drivers/net/bnxt/bnxt_cpr.h | 2 +- drivers/net/bnxt/bnxt_ring.c | 4 drivers/net/bnxt/bnxt_ring.h | 1 + drivers/net/bnxt/bnxt_rxq.c | 19 --- drivers/net/bnxt/bnxt_rxr.c | 42 ++ drivers/net/bnxt/bnxt_rxr.h | 2 +- drivers/net/bnxt/bnxt_txq.c | 25 - drivers/net/bnxt/bnxt_txr.c | 43 ++- drivers/net/bnxt/bnxt_txr.h | 2 +- 10 files changed, 127 insertions(+), 41 deletions(-) diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 5a4b13d..60c277a 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -31,6 +31,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #include "bnxt.h" #include "bnxt_cpr.h" #include "bnxt_hwrm.h" @@ -121,21 +123,37 @@ reject: void bnxt_free_def_cp_ring(struct bnxt *bp) { struct bnxt_cp_ring_info *cpr = bp->def_cp_ring; - struct bnxt_ring *ring = cpr->cp_ring_struct; - bnxt_free_ring(ring); + bnxt_free_ring(cpr->cp_ring_struct); + rte_free(cpr->cp_ring_struct); + rte_free(cpr); } /* For the default completion ring only */ -void bnxt_init_def_ring_struct(struct bnxt *bp) +int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id) { - struct bnxt_cp_ring_info *cpr = bp->def_cp_ring; - struct bnxt_ring *ring = cpr->cp_ring_struct; + struct bnxt_cp_ring_info *cpr; + struct bnxt_ring *ring; + cpr = rte_zmalloc_socket("cpr", +sizeof(struct bnxt_cp_ring_info), +RTE_CACHE_LINE_SIZE, socket_id); + if (cpr == NULL) + return -ENOMEM; + bp->def_cp_ring = cpr; + + ring = rte_zmalloc_socket("bnxt_cp_ring_struct", + sizeof(struct bnxt_ring), + RTE_CACHE_LINE_SIZE, socket_id); + if (ring == NULL) + return -ENOMEM; + cpr->cp_ring_struct = ring; ring->bd = (void *)cpr->cp_desc_ring; ring->bd_dma = cpr->cp_desc_mapping; ring->ring_size = rte_align32pow2(DEFAULT_CP_RING_SIZE); ring->ring_mask = ring->ring_size - 1; ring->vmem_size = 0; ring->vmem = NULL; + + return 0; } diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h index 4bd5606..c176f8c 100644 --- a/drivers/net/bnxt/bnxt_cpr.h +++ b/drivers/net/bnxt/bnxt_cpr.h @@ -79,7 +79,7 @@ struct bnxt_cp_ring_info { struct bnxt; void bnxt_free_def_cp_ring(struct bnxt *bp); -void bnxt_init_def_ring_struct(struct bnxt *bp); +int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id); void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp); void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp); diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index f547a9e..67b009a 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -51,6 +51,7 @@ void bnxt_free_ring(struct bnxt_ring *ring) memset((char *)*ring->vmem, 0, ring->vmem_size); *ring->vmem = NULL; } + rte_memzone_free((const struct rte_memzone *)ring->mem_zone); } /* @@ -135,6 +136,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, tx_ring_info->tx_desc_ring = (struct tx_bd_long *)tx_ring->bd; tx_ring->bd_dma = mz->phys_addr + tx_ring_start; tx_ring_info->tx_desc_mapping = tx_ring->bd_dma; + tx_ring->mem_zone = (const void *)mz; if (!tx_ring->bd) return -ENOMEM; @@ -154,6 +156,7 @@ int bnxt_alloc_rings(
[dpdk-dev] [PATCH v5 17/38] bnxt: add HWRM vnic alloc function
From: Ajit Khaparde This requires a group info array in struct bnxt, so add that, we can save the max size from the func_qcap response, and alloc/free in init/uninit A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. New HWRM call: bnxt_hwrm_vnic_alloc: Allocates a VNIC resource in the hardware. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/bnxt.h| 2 + drivers/net/bnxt/bnxt_hwrm.c | 32 +++ drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 99 ++ 4 files changed, 135 insertions(+) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index f7cf9d1..df1f771 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -141,6 +141,8 @@ struct bnxt { /* Default completion ring */ struct bnxt_cp_ring_info*def_cp_ring; + uint32_tmax_ring_grps; + struct bnxt_ring_grp_info *grp_info; unsigned intnr_vnics; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index d1ca60a..fb0b7bf 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -43,6 +43,7 @@ #include "bnxt_filter.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_ring.h" #include "bnxt_txq.h" #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" @@ -235,6 +236,7 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp) HWRM_CHECK_RESULT; + bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps); if (BNXT_PF(bp)) { struct bnxt_pf_info *pf = &bp->pf; @@ -521,6 +523,36 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) return rc; } +int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0, i, j; + struct hwrm_vnic_alloc_input req = {.req_type = 0 }; + struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + /* map ring groups to this vnic */ + for (i = vnic->start_grp_id, j = 0; i <= vnic->end_grp_id; i++, j++) { + if (bp->grp_info[i].fw_grp_id == (uint16_t)HWRM_NA_SIGNATURE) { + RTE_LOG(ERR, PMD, + "Not enough ring groups avail:%x req:%x\n", j, + (vnic->end_grp_id - vnic->start_grp_id) + 1); + break; + } + vnic->fw_grp_ids[j] = bp->grp_info[i].fw_grp_id; + } + + vnic->fw_rss_cos_lb_ctx = (uint16_t)HWRM_NA_SIGNATURE; + vnic->ctx_is_rss_cos_lb = HW_CONTEXT_NONE; + + HWRM_PREP(req, VNIC_ALLOC, -1, resp); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id); + return rc; +} + /* * HWRM utility functions */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 2679d09..7d09773 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,6 +63,8 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_ver_get(struct bnxt *bp); +int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); + int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 6209368..eedd368 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -89,6 +89,7 @@ struct ctx_hw_stats64 { #define HWRM_FUNC_DRV_RGTR (UINT32_C(0x1d)) #define HWRM_PORT_PHY_CFG (UINT32_C(0x20)) #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30)) +#define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3119,6 +3120,104 @@ struct hwrm_stat_ctx_clr_stats_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_vnic_alloc */ +/* + * Description: This VNIC is a resource in the RX side of the chip that is used + * to represent a virtual host "interface". # At the time of VNIC allocation or + * configuration, the function can specify whether it wants the requested VNIC + * to be the default VNIC for the function or not. # If a function requests + * allocation of a VNI
[dpdk-dev] [PATCH v5 04/38] bnxt: add dev infos get operation
From: Ajit Khaparde Gets device info from the bp structure filled in the init() function. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder footer --- drivers/net/bnxt/bnxt.h| 3 ++ drivers/net/bnxt/bnxt_ethdev.c | 95 ++ drivers/net/bnxt/bnxt_hwrm.c | 2 +- 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index ed057ef..f8707b2 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -42,6 +42,9 @@ #include #include +#define BNXT_MAX_MTU 9000 +#define VLAN_TAG_SIZE 4 + struct bnxt_vf_info { uint16_tfw_fid; uint8_t mac_addr[ETHER_ADDR_LEN]; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 26e6447..a8a9912 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -61,10 +61,105 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) } /* + * Device configuration and status function + */ + +static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev, + struct rte_eth_dev_info *dev_info) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + uint16_t max_vnics, i, j, vpool, vrxq; + + /* MAC Specifics */ + dev_info->max_mac_addrs = MAX_NUM_MAC_ADDR; + dev_info->max_hash_mac_addrs = 0; + + /* PF/VF specifics */ + if (BNXT_PF(bp)) { + dev_info->max_rx_queues = bp->pf.max_rx_rings; + dev_info->max_tx_queues = bp->pf.max_tx_rings; + dev_info->max_vfs = bp->pf.active_vfs; + dev_info->reta_size = bp->pf.max_rsscos_ctx; + max_vnics = bp->pf.max_vnics; + } else { + dev_info->max_rx_queues = bp->vf.max_rx_rings; + dev_info->max_tx_queues = bp->vf.max_tx_rings; + dev_info->reta_size = bp->vf.max_rsscos_ctx; + max_vnics = bp->vf.max_vnics; + } + + /* Fast path specifics */ + dev_info->min_rx_bufsize = 1; + dev_info->max_rx_pktlen = BNXT_MAX_MTU + ETHER_HDR_LEN + ETHER_CRC_LEN + + VLAN_TAG_SIZE; + dev_info->rx_offload_capa = 0; + dev_info->tx_offload_capa = DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_TSO; + + /* *INDENT-OFF* */ + dev_info->default_rxconf = (struct rte_eth_rxconf) { + .rx_thresh = { + .pthresh = 8, + .hthresh = 8, + .wthresh = 0, + }, + .rx_free_thresh = 32, + .rx_drop_en = 0, + }; + + dev_info->default_txconf = (struct rte_eth_txconf) { + .tx_thresh = { + .pthresh = 32, + .hthresh = 0, + .wthresh = 0, + }, + .tx_free_thresh = 32, + .tx_rs_thresh = 32, + .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS | +ETH_TXQ_FLAGS_NOOFFLOADS, + }; + /* *INDENT-ON* */ + + /* +* TODO: default_rxconf, default_txconf, rx_desc_lim, and tx_desc_lim +* need further investigation. +*/ + + /* VMDq resources */ + vpool = 64; /* ETH_64_POOLS */ + vrxq = 128; /* ETH_VMDQ_DCB_NUM_QUEUES */ + for (i = 0; i < 4; vpool >>= 1, i++) { + if (max_vnics > vpool) { + for (j = 0; j < 5; vrxq >>= 1, j++) { + if (dev_info->max_rx_queues > vrxq) { + if (vpool > vrxq) + vpool = vrxq; + goto found; + } + } + /* Not enough resources to support VMDq */ + break; + } + } + /* Not enough resources to support VMDq */ + vpool = 0; + vrxq = 0; +found: + dev_info->max_vmdq_pools = vpool; + dev_info->vmdq_queue_num = vrxq; + + dev_info->vmdq_pool_base = 0; + dev_info->vmdq_queue_base = 0; +} + +/* * Initialization */ static struct eth_dev_ops bnxt_dev_ops = { + .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, }; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 8aba8cd..3eabf0c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -83,7 +83,7 @@ sta
[dpdk-dev] [PATCH v5 23/38] bnxt: add HWRM API for stats context allocation
From: Ajit Khaparde Add HWRM API code to allocate a statistics context in the ASIC. This API will be called by the previously submitted "add statistics operations patch". New HWRM call: bnxt_hwrm_stat_ctx_alloc: This command allocates and does basic preparation for a stat context. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 52 drivers/net/bnxt/bnxt_hwrm.h | 3 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 89 ++ 3 files changed, 144 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 2c43159..420a1cc 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -568,6 +568,31 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) return rc; } +int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, +struct bnxt_cp_ring_info *cpr, unsigned int idx) +{ + int rc; + struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 }; + struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, STAT_CTX_ALLOC, -1, resp); + + req.update_period_ms = rte_cpu_to_le_32(1000); + + req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++); + req.stats_dma_addr = + rte_cpu_to_le_64(cpr->hw_stats_map); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + cpr->hw_stats_ctx_id = rte_le_to_cpu_16(resp->stat_ctx_id); + bp->grp_info[idx].fw_stats_ctx = cpr->hw_stats_ctx_id; + + return rc; +} + int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0, i, j; @@ -744,6 +769,33 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp) return 0; } +int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) +{ + unsigned int i; + int rc = 0; + + for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) { + struct bnxt_tx_queue *txq; + struct bnxt_rx_queue *rxq; + struct bnxt_cp_ring_info *cpr; + unsigned int idx = i + 1; + + if (i >= bp->rx_cp_nr_rings) { + txq = bp->tx_queues[i - bp->rx_cp_nr_rings]; + cpr = txq->cp_ring; + } else { + rxq = bp->rx_queues[i]; + cpr = rxq->cp_ring; + } + + rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr, idx); + + if (rc) + return rc; + } + return rc; +} + void bnxt_free_hwrm_resources(struct bnxt *bp) { /* Release memzone */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 8037242..49966f5 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,6 +63,8 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags); int bnxt_hwrm_queue_qportcfg(struct bnxt *bp); int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); +int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, +struct bnxt_cp_ring_info *cpr, unsigned int idx); int bnxt_hwrm_ver_get(struct bnxt *bp); @@ -74,6 +76,7 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index f8f6a3f..28362c9 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -99,6 +99,7 @@ struct ctx_hw_stats64 { #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) #define HWRM_CFA_L2_SET_RX_MASK(UINT32_C(0x93)) +#define HWRM_STAT_CTX_ALLOC(UINT32_C(0xb0)) #define HWRM_STAT_CTX_CLR_STATS(UINT32_C(0xb3)) #define HWRM_EXEC_FWD_RESP (UINT32_C(0xd0)) @@ -3183,6 +3184,94 @@ struct hwrm_queue_qportcfg_input { uint16_t unused_0; } __attribute__((packed)); +/* hwrm_stat_ctx_alloc */ +/* + * Description: This command allocates and does basic preparation for a stat + * context. + */ + +/* Input (32 bytes) */ +struct hwrm_stat_ctx_alloc_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command i
[dpdk-dev] [PATCH v5 06/38] bnxt: add vnic functions and structs
From: Ajit Khaparde Add functions to allocate, initialize, and free vnics. A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 14 ++ drivers/net/bnxt/bnxt_vnic.c | 277 + drivers/net/bnxt/bnxt_vnic.h | 80 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 3 + 5 files changed, 375 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_vnic.c create mode 100644 drivers/net/bnxt/bnxt_vnic.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 9965597..c57afaa 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # # Export include files diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index bfce91e..d0f84f4 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -45,6 +45,13 @@ #define BNXT_MAX_MTU 9000 #define VLAN_TAG_SIZE 4 +enum bnxt_hw_context { + HW_CONTEXT_NONE = 0, + HW_CONTEXT_IS_RSS = 1, + HW_CONTEXT_IS_COS = 2, + HW_CONTEXT_IS_LB= 3, +}; + struct bnxt_vf_info { uint16_tfw_fid; uint8_t mac_addr[ETHER_ADDR_LEN]; @@ -130,6 +137,13 @@ struct bnxt { unsigned inttx_cp_nr_rings; struct bnxt_tx_queue **tx_queues; + struct bnxt_vnic_info *vnic_info; + STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; + + /* VNIC pointer for flow filter (VMDq) pools */ +#define MAX_FF_POOLS ETH_64_POOLS + STAILQ_HEAD(, bnxt_vnic_info) ff_pool[MAX_FF_POOLS]; + #define MAX_NUM_MAC_ADDR 32 uint8_t mac_addr[ETHER_ADDR_LEN]; diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c new file mode 100644 index 000..c04c4c7 --- /dev/null +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -0,0 +1,277 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2014-2015 Broadcom Corporation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include + +#include "bnxt.h" +#include "bnxt_vnic.h" +#include "hsi_struct_def_dpdk.h" + +/* + * VNIC Functions + */ + +static void prandom_bytes(void *dest_ptr, size_t len) +{ + char *dest = (char *)dest_ptr; + uint64_t rb; + + while (len) { + rb = rte_rand(); + if (len >= 8) { + memcpy(dest, &rb, 8); + len -= 8; + dest += 8; + } else { + memcpy(dest, &rb, len); + dest += len; + len = 0; + } + } +} + +void bnxt_init_vnics(struct bnxt *bp) +{ + struct bnxt_vnic_info *vnic; + uint16_t max_vnics; + int i, j; + + if (BNXT_PF(bp)) { + struct bnxt_pf_i
[dpdk-dev] [PATCH v5 32/38] bnxt: add all multicast enable/disable operations
From: Ajit Khaparde This patch adds dev_ops to enable/disable multicast traffic. Uses the bnxt_hwrm_cfa_l2_set_rx_mask() API added in the earlier patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder footer Rewrite the patch description. --- drivers/net/bnxt/bnxt_ethdev.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3fce540..d3a624f 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -465,6 +465,34 @@ static void bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev) bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); } +static void bnxt_allmulticast_enable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags |= BNXT_VNIC_INFO_ALLMULTI; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + +static void bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + /* * Initialization */ @@ -484,6 +512,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .link_update = bnxt_link_update_op, .promiscuous_enable = bnxt_promiscuous_enable_op, .promiscuous_disable = bnxt_promiscuous_disable_op, + .allmulticast_enable = bnxt_allmulticast_enable_op, + .allmulticast_disable = bnxt_allmulticast_disable_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v5 31/38] bnxt: add promiscuous enable/disable operations
From: Ajit Khaparde This patch adds the promiscuous mode enable and disable dev_ops. Uses the bnxt_hwrm_cfa_l2_set_rx_mask() API added in the earlier patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix couple of typos in the commit message. v5: Reorder footer Rewrite the patch description. --- drivers/net/bnxt/bnxt_ethdev.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index ac82876..3fce540 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -437,6 +437,34 @@ out: return rc; } +static void bnxt_promiscuous_enable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags |= BNXT_VNIC_INFO_PROMISC; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + +static void bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags &= ~BNXT_VNIC_INFO_PROMISC; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + /* * Initialization */ @@ -454,6 +482,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .tx_queue_setup = bnxt_tx_queue_setup_op, .tx_queue_release = bnxt_tx_queue_release_op, .link_update = bnxt_link_update_op, + .promiscuous_enable = bnxt_promiscuous_enable_op, + .promiscuous_disable = bnxt_promiscuous_disable_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v5 25/38] bnxt: add ring group alloc/free functions
From: Ajit Khaparde Add HWRM API for ring group alloc/free functions, associated structs and definitions. This API allocates and does basic preparation for a ring group in ASIC. A ring group is identified by an index. It consists of Rx ring id, completion ring id and a statistics context. New HWRM calls: bnxt_hwrm_ring_grp_alloc Allocates and does basic preparation for a ring group bnxt_hwrm_ring_grp_free Frees and does cleansup resources of a ring group Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address issues pointed out by checkpatch. v5: Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 84 +++ drivers/net/bnxt/bnxt_hwrm.h | 4 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 185 + 3 files changed, 273 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 565b76f..f335401 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -655,6 +655,47 @@ int bnxt_hwrm_ring_free(struct bnxt *bp, return 0; } +int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx) +{ + int rc = 0; + struct hwrm_ring_grp_alloc_input req = {.req_type = 0 }; + struct hwrm_ring_grp_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_GRP_ALLOC, -1, resp); + + req.cr = rte_cpu_to_le_16(bp->grp_info[idx].cp_fw_ring_id); + req.rr = rte_cpu_to_le_16(bp->grp_info[idx].rx_fw_ring_id); + req.ar = rte_cpu_to_le_16(bp->grp_info[idx].ag_fw_ring_id); + req.sc = rte_cpu_to_le_16(bp->grp_info[idx].fw_stats_ctx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->grp_info[idx].fw_grp_id = + rte_le_to_cpu_16(resp->ring_group_id); + + return rc; +} + +int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx) +{ + int rc; + struct hwrm_ring_grp_free_input req = {.req_type = 0 }; + struct hwrm_ring_grp_free_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_GRP_FREE, -1, resp); + + req.ring_group_id = rte_cpu_to_le_16(bp->grp_info[idx].fw_grp_id); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->grp_info[idx].fw_grp_id = INVALID_HW_RING_ID; + return rc; +} + int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) { int rc = 0; @@ -904,6 +945,49 @@ int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) return rc; } +int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp) +{ + uint16_t i; + uint32_t rc = 0; + + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + unsigned int idx = i + 1; + + if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID) { + RTE_LOG(ERR, PMD, + "Attempt to free invalid ring group %d\n", + idx); + continue; + } + + rc = bnxt_hwrm_ring_grp_free(bp, idx); + + if (rc) + return rc; + } + return rc; +} + +int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp) +{ + uint16_t i; + uint32_t rc = 0; + + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + unsigned int idx = i + 1; + + if (bp->grp_info[idx].cp_fw_ring_id == INVALID_HW_RING_ID || + bp->grp_info[idx].rx_fw_ring_id == INVALID_HW_RING_ID) + continue; + + rc = bnxt_hwrm_ring_grp_alloc(bp, idx); + + if (rc) + return rc; + } + return rc; +} + void bnxt_free_hwrm_resources(struct bnxt *bp) { /* Release memzone */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index ebde5fb..a9a8dc6 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -68,6 +68,8 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp, uint32_t stats_ctx_id); int bnxt_hwrm_ring_free(struct bnxt *bp, struct bnxt_ring *ring, uint32_t ring_type); +int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx); +int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx); int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, @@ -85,6 +87,8 @@ int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); +int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp); +int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); int bnxt_set_hwrm_link_config(struct bnxt *bp, bool lin
[dpdk-dev] [PATCH v5 37/38] bnxt: add RSS device operations
From: Ajit Khaparde Add rss_hash_update and rss_hash_conf_get dev_ops Uses the bnxt_hwrm_vnic_rss_cfg() HWRM API added in the previous patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 121 + 1 file changed, 121 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b3b76f1..3c7f868 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -62,6 +62,14 @@ static struct rte_pci_id bnxt_pci_id_map[] = { {.device_id = 0}, }; +#define BNXT_ETH_RSS_SUPPORT ( \ + ETH_RSS_IPV4 | \ + ETH_RSS_NONFRAG_IPV4_TCP | \ + ETH_RSS_NONFRAG_IPV4_UDP | \ + ETH_RSS_IPV6 | \ + ETH_RSS_NONFRAG_IPV6_TCP | \ + ETH_RSS_NONFRAG_IPV6_UDP) + /***/ /* @@ -636,6 +644,117 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev, return 0; } +static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; + struct bnxt_vnic_info *vnic; + uint16_t hash_type = 0; + int i; + + /* +* If RSS enablement were different than dev_configure, +* then return -EINVAL +*/ + if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) { + if (!rss_conf->rss_hf) + return -EINVAL; + } else { + if (rss_conf->rss_hf & BNXT_ETH_RSS_SUPPORT) + return -EINVAL; + } + if (rss_conf->rss_hf & ETH_RSS_IPV4) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_UDP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4; + if (rss_conf->rss_hf & ETH_RSS_IPV6) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_UDP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6; + + /* Update the RSS VNIC(s) */ + for (i = 0; i < MAX_FF_POOLS; i++) { + STAILQ_FOREACH(vnic, &bp->ff_pool[i], next) { + vnic->hash_type = hash_type; + + /* +* Use the supplied key if the key length is +* acceptable and the rss_key is not NULL +*/ + if (rss_conf->rss_key && + rss_conf->rss_key_len <= HW_HASH_KEY_SIZE) + memcpy(vnic->rss_hash_key, rss_conf->rss_key, + rss_conf->rss_key_len); + + bnxt_hwrm_vnic_rss_cfg(bp, vnic); + } + } + return 0; +} + +static int bnxt_rss_hash_conf_get_op(struct rte_eth_dev *eth_dev, +struct rte_eth_rss_conf *rss_conf) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; + int len; + uint32_t hash_types; + + /* RSS configuration is the same for all VNICs */ + if (vnic && vnic->rss_hash_key) { + if (rss_conf->rss_key) { + len = rss_conf->rss_key_len <= HW_HASH_KEY_SIZE ? + rss_conf->rss_key_len : HW_HASH_KEY_SIZE; + memcpy(rss_conf->rss_key, vnic->rss_hash_key, len); + } + + hash_types = vnic->hash_type; + rss_conf->rss_hf = 0; + if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4) { + rss_conf->rss_hf |= ETH_RSS_IPV4; + hash_types &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4; + } + if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4) { + rss_conf->rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP; + hash_types &= + ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4; + } + if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4) { + rss_co
[dpdk-dev] [PATCH v5 01/38] bnxt: new driver for Broadcom NetXtreme-C devices
From: Ajit Khaparde This patch adds the initial skeleton for bnxt driver along with the nic guide to tie into the build system. At this point, the driver simply fails init. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix a warning that the document isn't included in any toctree Also remove a PCI ID added erroneously. v5: Re-format footer --- MAINTAINERS | 5 ++ config/common_base | 5 ++ doc/guides/nics/bnxt.rst| 49 +++ doc/guides/nics/index.rst | 1 + drivers/net/Makefile| 1 + drivers/net/bnxt/Makefile | 63 ++ drivers/net/bnxt/bnxt_ethdev.c | 109 drivers/net/bnxt/rte_pmd_bnxt_version.map | 4 + lib/librte_eal/common/include/rte_pci_dev_ids.h | 38 +++-- mk/rte.app.mk | 1 + 10 files changed, 271 insertions(+), 5 deletions(-) create mode 100644 doc/guides/nics/bnxt.rst create mode 100644 drivers/net/bnxt/Makefile create mode 100644 drivers/net/bnxt/bnxt_ethdev.c create mode 100644 drivers/net/bnxt/rte_pmd_bnxt_version.map diff --git a/MAINTAINERS b/MAINTAINERS index 3e6b70c..78d8530 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -401,6 +401,11 @@ M: Declan Doherty F: drivers/crypto/null/ F: doc/guides/cryptodevs/null.rst +Broadcom BNXT PMD +M: Stephen Hurd +F: drivers/net/bnxt/ +F: doc/guides/nics/bnxt.rst + Packet processing - diff --git a/config/common_base b/config/common_base index b9ba405..71be7cd 100644 --- a/config/common_base +++ b/config/common_base @@ -245,6 +245,11 @@ CONFIG_RTE_LIBRTE_NFP_PMD=n CONFIG_RTE_LIBRTE_NFP_DEBUG=n # +# Compile burst-oriented Broadcom BNXT PMD driver +# +CONFIG_RTE_LIBRTE_BNXT_PMD=y + +# # Compile software PMD backed by SZEDATA2 device # CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n diff --git a/doc/guides/nics/bnxt.rst b/doc/guides/nics/bnxt.rst new file mode 100644 index 000..2669e98 --- /dev/null +++ b/doc/guides/nics/bnxt.rst @@ -0,0 +1,49 @@ +.. BSD LICENSE +Copyright 2016 Broadcom Limited + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +* Neither the name of Broadcom Limited nor the names of its +contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +bnxt poll mode driver library += + +The bnxt poll mode library (**librte_pmd_bnxt**) implements support for +**Broadcom NetXtreme? C-Series**. These adapters support Standards- +compliant 10/25/50Gbps 30MPPS full-duplex throughput. + +Information about this family of adapters can be found in the +`NetXtreme? Brand section <https://www.broadcom.com/products/ethernet-communication-and-switching?technology%5B%5D=88>`_ +of the `Broadcom web site <http://www.broadcom.com/>`_. + +Limitations +--- + +With the current driver, allocated mbufs must be large enough to hold +the entire received frame. If the mbufs are not large enough, the +packets will be dropped. This is most limiting when jumbo frames are +used. + +SR-IOV is not supported. diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst index 0b13698..ffe011e 100644 --- a/doc/guides/nics/index.rst +++ b/doc/guides/nics/index.rst @@ -36,6 +36,7 @@ Network Interface Controller Drivers :numbered: overview +bnxt bnx2x cxgbe e1000em diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 6ba7658..3832706 100644 --- a/drivers/net/Makefile
[dpdk-dev] [PATCH v5 28/38] bnxt: allocate and free all HWRM rings and groups
From: Ajit Khaparde Add a top level functions to initialize ring groups, and functions to allocate and free all the rings via HWRM. A ring group is identified by an index. It consists of Rx or Tx ring id, completion ring id and a statistics context. Once a ring group is initialized, use this group index while creating the rings in the ASIC using the appropriate HWRM API added via earlier patches. Functions added: bnxt_free_cp_ring Calls the HWRM function generic ring free with arugments specific to a completion ring and sanitizes the host completion structure bnxt_free_all_hwrm_rings Frees all the HWRM allocated hardware rings bnxt_free_all_hwrm_resources Frees all the resources allocated via the HRM in the hardware bnxt_alloc_hwrm_rings Allocates all the HWRM rings needed in the current configuration This should be the last functionality needed to add start/stop device operations. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comment to merge another patch into this to avoid a compilation issue. Fix issues pointed out by checkpatch. v5: Reorder the footer. Remove instances of bnxt_ring_struct --- drivers/net/bnxt/bnxt_hwrm.c | 112 +++- drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/bnxt_ring.c | 119 +++ drivers/net/bnxt/bnxt_ring.h | 2 + 4 files changed, 233 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 13f9e1c..fcc4811 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -43,8 +43,10 @@ #include "bnxt_filter.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_rxr.h" #include "bnxt_ring.h" #include "bnxt_txq.h" +#include "bnxt_txr.h" #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" @@ -579,7 +581,11 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp, break; case HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL: req.ring_type = ring_type; - req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_POLL; + /* +* TODO: Some HWRM versions crash with +* HWRM_RING_ALLOC_INPUT_INT_MODE_POLL +*/ + req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX; req.length = rte_cpu_to_le_32(ring->ring_size); break; default: @@ -1012,6 +1018,84 @@ int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp) return rc; } +static void bnxt_free_cp_ring(struct bnxt *bp, + struct bnxt_cp_ring_info *cpr, unsigned int idx) +{ + struct bnxt_ring *cp_ring = cpr->cp_ring_struct; + + bnxt_hwrm_ring_free(bp, cp_ring, + HWRM_RING_FREE_INPUT_RING_TYPE_CMPL); + cp_ring->fw_ring_id = INVALID_HW_RING_ID; + bp->grp_info[idx].cp_fw_ring_id = INVALID_HW_RING_ID; + memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size * + sizeof(*cpr->cp_desc_ring)); + cpr->cp_raw_cons = 0; +} + +int bnxt_free_all_hwrm_rings(struct bnxt *bp) +{ + unsigned int i; + int rc = 0; + + for (i = 0; i < bp->tx_cp_nr_rings; i++) { + struct bnxt_tx_queue *txq = bp->tx_queues[i]; + struct bnxt_tx_ring_info *txr = txq->tx_ring; + struct bnxt_ring *ring = txr->tx_ring_struct; + struct bnxt_cp_ring_info *cpr = txq->cp_ring; + unsigned int idx = bp->rx_cp_nr_rings + i + 1; + + if (ring->fw_ring_id != INVALID_HW_RING_ID) { + bnxt_hwrm_ring_free(bp, ring, + HWRM_RING_FREE_INPUT_RING_TYPE_TX); + ring->fw_ring_id = INVALID_HW_RING_ID; + memset(txr->tx_desc_ring, 0, + txr->tx_ring_struct->ring_size * + sizeof(*txr->tx_desc_ring)); + memset(txr->tx_buf_ring, 0, + txr->tx_ring_struct->ring_size * + sizeof(*txr->tx_buf_ring)); + txr->tx_prod = 0; + txr->tx_cons = 0; + } + if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) + bnxt_free_cp_ring(bp, cpr, idx); + } + + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + struct bnxt_rx_queue *rxq = bp->rx_queues[i]; + struct bnxt_rx_ring_info *rxr = rxq->rx_ring; + struct bnxt_ring *ring = rxr->rx_ring_struct; + struct bn
[dpdk-dev] [PATCH v5 35/38] bnxt: add set link up/down operations
From: Ajit Khaparde Adds dev_ops to set link UP or DOWN as appropriate. Uses the bnxt_set_hwrm_link_config() API added in previous patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 20 1 file changed, 20 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 34a5873..b04010c 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -380,6 +380,24 @@ error: return rc; } +static int bnxt_dev_set_link_up_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + + eth_dev->data->dev_link.link_status = 1; + bnxt_set_hwrm_link_config(bp, true); + return 0; +} + +static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + + eth_dev->data->dev_link.link_status = 0; + bnxt_set_hwrm_link_config(bp, false); + return 0; +} + static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) { struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; @@ -574,6 +592,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_configure = bnxt_dev_configure_op, .dev_start = bnxt_dev_start_op, .dev_stop = bnxt_dev_stop_op, + .dev_set_link_up = bnxt_dev_set_link_up_op, + .dev_set_link_down = bnxt_dev_set_link_down_op, .stats_get = bnxt_stats_get_op, .stats_reset = bnxt_stats_reset_op, .rx_queue_setup = bnxt_rx_queue_setup_op, -- 1.9.1
[dpdk-dev] [PATCH v5 27/38] bnxt: add HWRM API to set and clear filters
From: Ajit Khaparde New HWRM call: bnxt_clear_hwrm_vnic_filters This patch adds code to set and clear L2 filters from the corresponding VNIC. These filters will determine the Rx flows Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Separated this code from the previous patch as it had nothing to do with freeing of statistics context. v5: Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 26 ++ drivers/net/bnxt/bnxt_hwrm.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index cb30109..13f9e1c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -1059,6 +1059,32 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp) return 0; } +int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + struct bnxt_filter_info *filter; + int rc = 0; + + STAILQ_FOREACH(filter, &vnic->filter, next) { + rc = bnxt_hwrm_clear_filter(bp, filter); + if (rc) + break; + } + return rc; +} + +int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + struct bnxt_filter_info *filter; + int rc = 0; + + STAILQ_FOREACH(filter, &vnic->filter, next) { + rc = bnxt_hwrm_set_filter(bp, vnic, filter); + if (rc) + break; + } + return rc; +} + static uint16_t bnxt_parse_eth_link_duplex(uint32_t conf_link_speed) { uint8_t hw_link_duplex = HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index ffb45b1..9c26118 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -92,6 +92,9 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp); int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp); +int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic); +void bnxt_free_all_hwrm_resources(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up); -- 1.9.1
[dpdk-dev] [PATCH v5 13/38] bnxt: add initial Tx code implementation
From: Ajit Khaparde Initial implementation of tx_pkt_burst for transmit. bnxt_xmit_pkts() is the top level function that is called during Tx. bnxt_handle_tx_cp() is used to check and process the Tx completions generated for the Tx Buffer Descriptors sent by the hardware. This patch also adds code to allocate rings in the hardware. For each Tx queue allocated in the PMD driver, a corresponding ring in hardware will be created. Every time a Tx request is initiated via the bnxt_xmit_pkts() call, a Buffer Descriptor is created and is sent to the hardware via the associated Tx ring. On completing the Tx operation, the hardware will generates the status in the form of a completion. This completion is processed by the bnxt_handle_tx_cp() function. Functions like bnxt_init_tx_ring_struct() and bnxt_init_one_tx_ring() are used to initialize various members of the structure before starting Tx operations. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Expand the patch description Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_cpr.h| 4 +- drivers/net/bnxt/bnxt_ethdev.c | 3 +- drivers/net/bnxt/bnxt_ring.c | 145 ++ drivers/net/bnxt/bnxt_ring.h | 8 + drivers/net/bnxt/bnxt_txq.c| 42 ++- drivers/net/bnxt/bnxt_txr.c| 314 drivers/net/bnxt/bnxt_txr.h| 71 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 512 + 9 files changed, 1091 insertions(+), 9 deletions(-) create mode 100644 drivers/net/bnxt/bnxt_txr.c create mode 100644 drivers/net/bnxt/bnxt_txr.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index f6a04f8..0785681 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h index 2be22de..4bd5606 100644 --- a/drivers/net/bnxt/bnxt_cpr.h +++ b/drivers/net/bnxt/bnxt_cpr.h @@ -51,11 +51,11 @@ #define B_CP_DB_REARM(cpr, raw_cons) \ (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_REARM_FLAGS | \ - RING_CMP(&cpr->cp_ring_struct, raw_cons))) + RING_CMP(cpr->cp_ring_struct, raw_cons))) #define B_CP_DIS_DB(cpr, raw_cons) \ (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_FLAGS | \ - RING_CMP(&cpr->cp_ring_struct, raw_cons))) + RING_CMP(cpr->cp_ring_struct, raw_cons))) struct bnxt_ring; struct bnxt_cp_ring_info { diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3453509..4ace543 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -44,6 +44,7 @@ #include "bnxt_rxq.h" #include "bnxt_stats.h" #include "bnxt_txq.h" +#include "bnxt_txr.h" #define DRV_MODULE_NAME"bnxt" static const char bnxt_version[] = @@ -269,7 +270,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) } eth_dev->dev_ops = &bnxt_dev_ops; /* eth_dev->rx_pkt_burst = &bnxt_recv_pkts; */ - /* eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; */ + eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; rc = bnxt_alloc_hwrm_resources(bp); if (rc) { diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index b57d3ba..2645dda 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -31,8 +31,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #include "bnxt.h" +#include "bnxt_cpr.h" #include "bnxt_ring.h" +#include "bnxt_txr.h" + +#include "hsi_struct_def_dpdk.h" /* * Generic ring handling @@ -45,3 +51,142 @@ void bnxt_free_ring(struct bnxt_ring *ring) *ring->vmem = NULL; } } + +/* + * Allocates a completion ring with vmem and stats optionally also allocating + * a TX and/or RX ring. Passing NULL as tx_ring_info and/or rx_ring_info + * to not allocate them. + * + * Order in the allocation is: + * stats - Always non-zero length + * cp vmem - Always zero-length, supported for the bnxt_ring abstraction + * tx vmem - Only non-zero length if tx_ring_info is not NULL + * rx vmem - Only non-zero length if rx_ring_info is not NULL + * cp bd
[dpdk-dev] [PATCH v5 21/38] bnxt: add HWRM API to configure RSS
From: Ajit Khaparde A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. New HWRM call: bnxt_hwrm_vnic_rss_cfg: Used to enable RSS configuration of the VNIC. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Expand the commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 24 drivers/net/bnxt/bnxt_hwrm.h | 2 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 1 + 3 files changed, 27 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 5a5063f..29b0729 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -646,6 +646,30 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, + struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 }; + struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_RSS_CFG, -1, resp); + + req.hash_type = rte_cpu_to_le_32(vnic->hash_type); + + req.ring_grp_tbl_addr = + rte_cpu_to_le_64(vnic->rss_table_dma_addr); + req.hash_key_tbl_addr = + rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr); + req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + /* * HWRM utility functions */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index fbb8aba..8c7b939 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -68,6 +68,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, + struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 6412df2..72d4984 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -92,6 +92,7 @@ struct ctx_hw_stats64 { #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_VNIC_FREE (UINT32_C(0x41)) #define HWRM_VNIC_CFG (UINT32_C(0x42)) +#define HWRM_VNIC_RSS_CFG (UINT32_C(0x46)) #define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC (UINT32_C(0x70)) #define HWRM_VNIC_RSS_COS_LB_CTX_FREE (UINT32_C(0x71)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) -- 1.9.1
[dpdk-dev] [PATCH v5 19/38] bnxt: add HWRM vnic configure function
From: Ajit Khaparde A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. This patch configures the properties and actions of the vnic allocated by vnic_alloc function from the previous patch. bnxt_hwrm_vnic_cfg: Configure the VNIC structure in hardware. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 34 drivers/net/bnxt/bnxt_hwrm.h | 3 +- drivers/net/bnxt/hsi_struct_def_dpdk.h | 155 + 3 files changed, 191 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index fbbb81d..0c54129 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -553,6 +553,40 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_cfg_input req = {.req_type = 0 }; + struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_CFG, -1, resp); + + /* Only RSS support for now TBD: COS & LB */ + req.enables = + rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP | +HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE | +HWRM_VNIC_CFG_INPUT_ENABLES_MRU); + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + req.dflt_ring_grp = + rte_cpu_to_le_16(bp->grp_info[vnic->start_grp_id].fw_grp_id); + req.rss_rule = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx); + req.cos_rule = rte_cpu_to_le_16(0x); + req.lb_rule = rte_cpu_to_le_16(0x); + req.mru = rte_cpu_to_le_16(bp->eth_dev->data->mtu + ETHER_HDR_LEN + + ETHER_CRC_LEN + VLAN_TAG_SIZE); + if (vnic->func_default) + req.flags = 1; + if (vnic->vlan_strip) + req.flags |= + rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 93fb759..cdaa295 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,8 +63,9 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_ver_get(struct bnxt *bp); -int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 0771897..ef0b37a 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -91,6 +91,7 @@ struct ctx_hw_stats64 { #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30)) #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_VNIC_FREE (UINT32_C(0x41)) +#define HWRM_VNIC_CFG (UINT32_C(0x42)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3219,6 +3220,160 @@ struct hwrm_vnic_alloc_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_vnic_cfg */ +/* Description: Configure the RX VNIC structure. */ + +/* Input (40 bytes) */ +struct hwrm_vnic_cfg_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This
[dpdk-dev] [PATCH v5 11/38] bnxt: add Rx queue create/destroy operations
From: Ajit Khaparde In this patch we are adding the bnxt_rx_queue_setup_op() and bnxt_rx_queue_release_op() functions. These will be tied to the rx_queue_setup and rx_queue_release dev_ops in a subsequent patch. In these functions we allocate/free memory for the RX queues. This still requires support to create a RX ring in the ASIC which will be completed in a future commit. Each Rx queue created via the rx_queue_setup dev_op will have an associated Rx ring in the hardware. The Rx logic in the hardware picks a Rx ring for each Rx frame received by the hardware depending on the properties like RSS, MAC and VLAN settings configured in the hardware. These packets in the end arrive on the Rx queue corresponding to the Rx ring in the hardware. We are also adding some functions like bnxt_mq_rx_configure() bnxt_free_rx_mbufs() and bnxt_free_rxq_stats() which will be used in subsequent patches. We are also adding hwrm_vnic_rss_cfg_* structures, which will be used in subsequent patches to enable RSS configuration. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 2 + drivers/net/bnxt/bnxt_ethdev.c | 3 + drivers/net/bnxt/bnxt_rxq.c| 287 + drivers/net/bnxt/bnxt_rxq.h| 74 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 121 ++ 6 files changed, 488 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_rxq.c create mode 100644 drivers/net/bnxt/bnxt_rxq.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 13a90b9..21ed71c 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 49aa38b..f7cf9d1 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -142,6 +142,8 @@ struct bnxt { /* Default completion ring */ struct bnxt_cp_ring_info*def_cp_ring; + unsigned intnr_vnics; + struct bnxt_vnic_info *vnic_info; STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 77a6d92..7e7d1ab 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -41,6 +41,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" +#include "bnxt_rxq.h" #include "bnxt_txq.h" #define DRV_MODULE_NAME"bnxt" @@ -186,6 +187,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, .dev_configure = bnxt_dev_configure_op, + .rx_queue_setup = bnxt_rx_queue_setup_op, + .rx_queue_release = bnxt_rx_queue_release_op, .tx_queue_setup = bnxt_tx_queue_setup_op, .tx_queue_release = bnxt_tx_queue_release_op, }; diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c new file mode 100644 index 000..d5c3173 --- /dev/null +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -0,0 +1,287 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * L
[dpdk-dev] [PATCH v5 16/38] bnxt: add HWRM function reset command
From: Ajit Khaparde Add bnxt_hwrm_func_reset() function and supporting structs and macros. New HWRM calls: bnxt_hwrm_func_reset: This command puts the function into the reset state. In the reset state, global and port related features of the chip are not available. This command resets a hardware function (PCIe function) and frees any resources used by the function. This command initiated by the driver prepare the function for re-use. This command may also be initiated by a driver prior to doing it's own configuration. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- More descriptive commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 17 + drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 129 + 3 files changed, 147 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 633683b..d1ca60a 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -265,6 +265,23 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp) return rc; } +int bnxt_hwrm_func_reset(struct bnxt *bp) +{ + int rc = 0; + struct hwrm_func_reset_input req = {.req_type = 0 }; + struct hwrm_func_reset_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, FUNC_RESET, -1, resp); + + req.enables = rte_cpu_to_le_32(0); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags, uint32_t *vf_req_fwd) { diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 75c3442..2679d09 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -54,6 +54,7 @@ int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, void *fwd_cmd); int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags, uint32_t *vf_req_fwd); int bnxt_hwrm_func_qcaps(struct bnxt *bp); +int bnxt_hwrm_func_reset(struct bnxt *bp); int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags); int bnxt_hwrm_queue_qportcfg(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 8b30787..6209368 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -83,6 +83,7 @@ struct ctx_hw_stats64 { * Request types */ #define HWRM_VER_GET (UINT32_C(0x0)) +#define HWRM_FUNC_RESET(UINT32_C(0x11)) #define HWRM_FUNC_QCAPS(UINT32_C(0x15)) #define HWRM_FUNC_DRV_UNRGTR (UINT32_C(0x1a)) #define HWRM_FUNC_DRV_RGTR (UINT32_C(0x1d)) @@ -2048,6 +2049,134 @@ struct hwrm_func_qcaps_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_func_reset */ +/* + * Description: This command resets a hardware function (PCIe function) and + * frees any resources used by the function. This command shall be initiated by + * the driver after an FLR has occurred to prepare the function for re-use. This + * command may also be initiated by a driver prior to doing it's own + * configuration. This command puts the function into the reset state. In the + * reset state, global and port related features of the chip are not available. + */ +/* + * Note: This command will reset a function that has already been disabled or + * idled. The command returns all the resources owned by the function so a new + * driver may allocate and configure resources normally. + */ + +/* Input (24 bytes) */ +struct hwrm_func_reset_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero before the request is made. +*/ + uint64_t resp_addr; + + /* This bit must be '1' for the vf_id_valid field to be configured. */ + #define HWRM_FUNC_RESE
[dpdk-dev] [PATCH v5 09/38] bnxt: add L2 filter alloc/init/free
From: Ajit Khaparde Add the L2 filter structure and the alloc/init/free functions for dealing with them. A filter is used to identify traffic that contains a matching set of parameters like unicast or broadcast MAC address or a VLAN tag amongst other things which then allows the ASIC to direct the incoming traffic to an appropriate VNIC or Rx ring. New HWRM calls: bnxt_hwrm_clear_filter: Free a L2 filter. bnxt_hwrm_set_filter Allocate an An L2 filter or a L2 context. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Move bnxt_hwrm_set_filter() into this patch Add short descriptions of new HWRM calls Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 3 + drivers/net/bnxt/bnxt_filter.c | 175 + drivers/net/bnxt/bnxt_filter.h | 74 ++ drivers/net/bnxt/bnxt_hwrm.c | 65 + drivers/net/bnxt/bnxt_hwrm.h | 6 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 456 + 7 files changed, 780 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_filter.c create mode 100644 drivers/net/bnxt/bnxt_filter.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index afd1690..b7834b1 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_cpr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index bdd355f..49aa38b 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -145,6 +145,9 @@ struct bnxt { struct bnxt_vnic_info *vnic_info; STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; + struct bnxt_filter_info *filter_info; + STAILQ_HEAD(, bnxt_filter_info) free_filter_list; + /* VNIC pointer for flow filter (VMDq) pools */ #define MAX_FF_POOLS ETH_64_POOLS STAILQ_HEAD(, bnxt_vnic_info) ff_pool[MAX_FF_POOLS]; diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c new file mode 100644 index 000..f03a1dc --- /dev/null +++ b/drivers/net/bnxt/bnxt_filter.c @@ -0,0 +1,175 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include + +#include "bnxt.h" +#include "bnxt_filter.h" +#include "bnxt_hwrm.h" +#include "bnxt_vnic.h" +#include "hsi_struct_def_dpdk.h" + +/* + * Filter Functions + */ + +struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp) +{ + struct bnxt_filter_info *filter; + + /* Find the 1st unused filter from the free_filter_list pool*/ + filter = STAILQ_FIRST(&bp->free_filter_list); + if (!filter) { + RTE_LOG(ERR, PMD, "No more free filter resources\n"); + return NULL; + } + STAILQ_REMOVE_HEAD(&bp->free_filter_list, next); + + /* Default to L2 MAC
[dpdk-dev] [PATCH v5 14/38] bnxt: add initial Rx code implementation
From: Ajit Khaparde This patch adds initial implementation of rx_pkt_burst() function fo Rx. bnxt_recv_pkts() is the top level function for doing Rx. This patch also adds code to allocate rings in the ASIC. For each Rx queue allocated in the PMD driver, a corresponding ring in hardware will be created. Every time a frame is received a Rx ring is selected based on the hardware configuration like RSS, MAC or VLAN, COS and such. The hardware uses a completion ring to indicate the availability of a packet. This patch also brings in functions like bnxt_init_one_rx_ring() bnxt_init_rx_ring_struct() which initializes various structures before a Rx can begin. bnxt_init_rxbds() initializes the Rx Buffer Descriptors while bnxt_alloc_rx_data() allocates a buffer in the host to receive the incoming packet. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Use rte_mbuf_raw_alloc instead of the now depricated __rte_mbuf_raw_alloc and fix issues pointed out by checkpatch. v5: Expand the patch description Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_ethdev.c | 3 +- drivers/net/bnxt/bnxt_ring.c | 61 ++--- drivers/net/bnxt/bnxt_rxq.c| 34 ++- drivers/net/bnxt/bnxt_rxr.c| 341 drivers/net/bnxt/bnxt_rxr.h| 62 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 474 + 7 files changed, 936 insertions(+), 40 deletions(-) create mode 100644 drivers/net/bnxt/bnxt_rxr.c create mode 100644 drivers/net/bnxt/bnxt_rxr.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 0785681..4d35412 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4ace543..6888363 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -42,6 +42,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_rxr.h" #include "bnxt_stats.h" #include "bnxt_txq.h" #include "bnxt_txr.h" @@ -269,7 +270,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) goto error; } eth_dev->dev_ops = &bnxt_dev_ops; - /* eth_dev->rx_pkt_burst = &bnxt_recv_pkts; */ + eth_dev->rx_pkt_burst = &bnxt_recv_pkts; eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; rc = bnxt_alloc_hwrm_resources(bp); diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index 2645dda..f547a9e 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -36,6 +36,7 @@ #include "bnxt.h" #include "bnxt_cpr.h" #include "bnxt_ring.h" +#include "bnxt_rxr.h" #include "bnxt_txr.h" #include "hsi_struct_def_dpdk.h" @@ -74,8 +75,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, { struct bnxt_ring *cp_ring = cp_ring_info->cp_ring_struct; struct bnxt_ring *tx_ring; - /* TODO: RX ring */ - /* struct bnxt_ring *rx_ring; */ + struct bnxt_ring *rx_ring; struct rte_pci_device *pdev = bp->pdev; const struct rte_memzone *mz = NULL; char mz_name[RTE_MEMZONE_NAMESIZE]; @@ -92,12 +92,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, tx_ring_struct->vmem_size) : 0; int rx_vmem_start = tx_vmem_start + tx_vmem_len; - /* TODO: RX ring */ - int rx_vmem_len = 0; - /* -* rx_ring_info ? RTE_CACHE_LINE_ROUNDUP(rx_ring_info-> -* rx_ring_struct->vmem_size) : 0; -*/ + int rx_vmem_len = rx_ring_info ? + RTE_CACHE_LINE_ROUNDUP(rx_ring_info-> + rx_ring_struct->vmem_size) : 0; int cp_ring_start = rx_vmem_start + rx_vmem_len; int cp_ring_len = RTE_CACHE_LINE_ROUNDUP(cp_ring->ring_size * @@ -109,13 +106,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, sizeof(struct tx_bd_long)) : 0; int rx_ring_start = tx_ring_start + tx_ring_len; - /* TODO: RX ring */ - int rx_ring_len = 0; - /* -* rx_ring_info ? -* RTE_CACHE_LINE_ROUNDUP(rx_ring_info->rx_ring_struct->ring_size * -* sizeof(struct rx_prod_pkt_bd)) : 0; -*/
[dpdk-dev] [PATCH v5 29/38] bnxt: add HWRM port PHY config call and helpers
From: Ajit Khaparde Add HWRM calls to query the port's PHY and link configuration. New HWRM call: bnxt_hwrm_port_phy_qcfg This command queries the PHY configuration for the port Also adding helper function like bnxt_get_hwrm_link_config() and bnxt_parse_hw_link_speed() parse the link state. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. v5: Reorder footer Rewrite the patch description. --- drivers/net/bnxt/bnxt_hwrm.c | 120 + drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 790 + 3 files changed, 911 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index fcc4811..5d81a60 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -521,6 +521,43 @@ static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf) return rc; } +static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp, + struct bnxt_link_info *link_info) +{ + int rc = 0; + struct hwrm_port_phy_qcfg_input req = {.req_type = 0}; + struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, PORT_PHY_QCFG, -1, resp); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + link_info->phy_link_status = resp->link; + if (link_info->phy_link_status == HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) { + link_info->link_up = 1; + link_info->link_speed = rte_le_to_cpu_16(resp->link_speed); + } else { + link_info->link_up = 0; + link_info->link_speed = 0; + } + link_info->duplex = resp->duplex; + link_info->pause = resp->pause; + link_info->auto_pause = resp->auto_pause; + link_info->force_pause = resp->force_pause; + link_info->auto_mode = resp->auto_mode; + + link_info->support_speeds = rte_le_to_cpu_16(resp->support_speeds); + link_info->auto_link_speed = rte_le_to_cpu_16(resp->auto_link_speed); + link_info->preemphasis = rte_le_to_cpu_32(resp->preemphasis); + link_info->phy_ver[0] = resp->phy_maj; + link_info->phy_ver[1] = resp->phy_min; + link_info->phy_ver[2] = resp->phy_bld; + + return rc; +} + int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) { int rc = 0; @@ -1326,6 +1363,89 @@ static uint16_t bnxt_parse_eth_link_speed_mask(uint32_t link_speed) return ret; } +static uint32_t bnxt_parse_hw_link_speed(uint16_t hw_link_speed) +{ + uint32_t eth_link_speed = ETH_SPEED_NUM_NONE; + + switch (hw_link_speed) { + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB: + eth_link_speed = ETH_SPEED_NUM_100M; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB: + eth_link_speed = ETH_SPEED_NUM_1G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB: + eth_link_speed = ETH_SPEED_NUM_2_5G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB: + eth_link_speed = ETH_SPEED_NUM_10G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB: + eth_link_speed = ETH_SPEED_NUM_20G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB: + eth_link_speed = ETH_SPEED_NUM_25G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB: + eth_link_speed = ETH_SPEED_NUM_40G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB: + eth_link_speed = ETH_SPEED_NUM_50G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB: + default: + RTE_LOG(ERR, PMD, "HWRM link speed %d not defined\n", + hw_link_speed); + break; + } + return eth_link_speed; +} + +static uint16_t bnxt_parse_hw_link_duplex(uint16_t hw_link_duplex) +{ + uint16_t eth_link_duplex = ETH_LINK_FULL_DUPLEX; + + switch (hw_link_duplex) { + case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH: + case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL: + eth_link_duplex = ETH_LINK_FULL_DUPLEX; + break; + case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF: + eth_link_duplex = ETH_LINK_HALF_DUPLEX; + break; + default: + RTE_LOG(ERR, PMD, "HWRM link duplex %d not defined\n", + hw_link_duplex); + break; + } + return eth_link_duplex; +} + +int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link) +{ + int rc = 0; +
[dpdk-dev] [PATCH v5 24/38] bnxt: add HWRM ring alloc/free functions
From: Ajit Khaparde Add HWRM API calls to allocate and free TX, RX and Completion rings in the hardware along with the associated structs and definitions. This informs the hardware of how the specific rings were set up in the host and allocates them in the HWRM, setting up the doorbell registers etc. as needed, returning an ID for the ring. Basic ring alloc/free calls: bnxt_hwrm_ring_alloc This command allocates and does basic preparation for a ring. bnxt_hwrm_ring_free This command is used to free a ring and associated resources. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 108 drivers/net/bnxt/bnxt_hwrm.h | 7 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 305 + 3 files changed, 420 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 420a1cc..565b76f 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -547,6 +547,114 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) return rc; } +int bnxt_hwrm_ring_alloc(struct bnxt *bp, +struct bnxt_ring *ring, +uint32_t ring_type, uint32_t map_index, +uint32_t stats_ctx_id) +{ + int rc = 0; + struct hwrm_ring_alloc_input req = {.req_type = 0 }; + struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_ALLOC, -1, resp); + + req.enables = rte_cpu_to_le_32(0); + + req.page_tbl_addr = rte_cpu_to_le_64(ring->bd_dma); + req.fbo = rte_cpu_to_le_32(0); + /* Association of ring index with doorbell index */ + req.logical_id = rte_cpu_to_le_16(map_index); + + switch (ring_type) { + case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX: + req.queue_id = bp->cos_queue[0].id; + case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX: + req.ring_type = ring_type; + req.cmpl_ring_id = + rte_cpu_to_le_16(bp->grp_info[map_index].cp_fw_ring_id); + req.length = rte_cpu_to_le_32(ring->ring_size); + req.stat_ctx_id = rte_cpu_to_le_16(stats_ctx_id); + req.enables = rte_cpu_to_le_32(rte_le_to_cpu_32(req.enables) | + HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID); + break; + case HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL: + req.ring_type = ring_type; + req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_POLL; + req.length = rte_cpu_to_le_32(ring->ring_size); + break; + default: + RTE_LOG(ERR, PMD, "hwrm alloc invalid ring type %d\n", + ring_type); + return -1; + } + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + if (rc || resp->error_code) { + if (rc == 0 && resp->error_code) + rc = rte_le_to_cpu_16(resp->error_code); + switch (ring_type) { + case HWRM_RING_FREE_INPUT_RING_TYPE_CMPL: + RTE_LOG(ERR, PMD, + "hwrm_ring_alloc cp failed. rc:%d\n", rc); + return rc; + case HWRM_RING_FREE_INPUT_RING_TYPE_RX: + RTE_LOG(ERR, PMD, + "hwrm_ring_alloc rx failed. rc:%d\n", rc); + return rc; + case HWRM_RING_FREE_INPUT_RING_TYPE_TX: + RTE_LOG(ERR, PMD, + "hwrm_ring_alloc tx failed. rc:%d\n", rc); + return rc; + default: + RTE_LOG(ERR, PMD, "Invalid ring. rc:%d\n", rc); + return rc; + } + } + + ring->fw_ring_id = rte_le_to_cpu_16(resp->ring_id); + return rc; +} + +int bnxt_hwrm_ring_free(struct bnxt *bp, + struct bnxt_ring *ring, uint32_t ring_type) +{ + int rc; + struct hwrm_ring_free_input req = {.req_type = 0 }; + struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_FREE, -1, resp); + + req.ring_type = ring_type; + req.ring_id = rte_cpu_to_le_16(ring->fw_ring_id); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + if (rc || resp->error_code) { + if (rc == 0 && resp->error_code) + rc = rte_le_to_cpu_16(resp->error_code); + + switch (ring_type) { + case HWRM_RING_FREE_INPUT_RING_TYPE_CMPL: + RTE_LOG(ERR, PMD, "hwrm_ring_free cp failed. rc:%d\n&q
[dpdk-dev] [PATCH v5 33/38] bnxt: free memory in close operation
From: Ajit Khaparde This patch adds code to free all resources except the one corresponding to HWRM, which are required to notify the HWRM that the driver is unloaded (these are freed in uninit()). Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index d3a624f..4254531 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -62,14 +62,6 @@ static struct rte_pci_id bnxt_pci_id_map[] = { {.device_id = 0}, }; -static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) -{ - struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; - - rte_free(eth_dev->data->mac_addrs); - bnxt_free_hwrm_resources(bp); -} - /***/ /* @@ -388,6 +380,16 @@ error: return rc; } +static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + + bnxt_free_tx_mbufs(bp); + bnxt_free_rx_mbufs(bp); + bnxt_free_mem(bp); + rte_free(eth_dev->data->mac_addrs); +} + /* Unload the driver, release resources */ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) { -- 1.9.1
[dpdk-dev] [PATCH v5 34/38] bnxt: add MAC address add/remove dev ops
From: Ajit Khaparde This patch adds dev_ops to Add/Remove MAC addresses. These use the bnxt_hwrm_set_filter() defined in the previous patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 71 ++ 1 file changed, 71 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4254531..34a5873 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -402,6 +402,75 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) bnxt_shutdown_nic(bp); } +static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev, + uint32_t index) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + uint64_t pool_mask = eth_dev->data->mac_pool_sel[index]; + struct bnxt_vnic_info *vnic; + struct bnxt_filter_info *filter, *temp_filter; + int i; + + /* +* Loop through all VNICs from the specified filter flow pools to +* remove the corresponding MAC addr filter +*/ + for (i = 0; i < MAX_FF_POOLS; i++) { + if (!(pool_mask & (1 << i))) + continue; + + STAILQ_FOREACH(vnic, &bp->ff_pool[i], next) { + filter = STAILQ_FIRST(&vnic->filter); + while (filter) { + temp_filter = STAILQ_NEXT(filter, next); + if (filter->mac_index == index) { + STAILQ_REMOVE(&vnic->filter, filter, + bnxt_filter_info, next); + bnxt_hwrm_clear_filter(bp, filter); + filter->mac_index = INVALID_MAC_INDEX; + memset(&filter->l2_addr, 0, + ETHER_ADDR_LEN); + STAILQ_INSERT_TAIL( + &bp->free_filter_list, + filter, next); + } + filter = temp_filter; + } + } + } +} + +static void bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev, +struct ether_addr *mac_addr, +uint32_t index, uint32_t pool) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic = STAILQ_FIRST(&bp->ff_pool[pool]); + struct bnxt_filter_info *filter; + + if (!vnic) { + RTE_LOG(ERR, PMD, "VNIC not found for pool %d!\n", pool); + return; + } + /* Attach requested MAC address to the new l2_filter */ + STAILQ_FOREACH(filter, &vnic->filter, next) { + if (filter->mac_index == index) { + RTE_LOG(ERR, PMD, + "MAC addr already existed for pool %d\n", pool); + return; + } + } + filter = bnxt_alloc_filter(bp); + if (!filter) { + RTE_LOG(ERR, PMD, "L2 filter alloc failed\n"); + return; + } + STAILQ_INSERT_TAIL(&vnic->filter, filter, next); + filter->mac_index = index; + memcpy(filter->l2_addr, mac_addr, ETHER_ADDR_LEN); + bnxt_hwrm_set_filter(bp, vnic, filter); +} + static int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) { @@ -516,6 +585,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .promiscuous_disable = bnxt_promiscuous_disable_op, .allmulticast_enable = bnxt_allmulticast_enable_op, .allmulticast_disable = bnxt_allmulticast_disable_op, + .mac_addr_add = bnxt_mac_addr_add_op, + .mac_addr_remove = bnxt_mac_addr_remove_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v5 02/38] bnxt: add HWRM init code
On Wed, Jun 15, 2016 at 9:25 AM, Ferruh Yigit wrote: > > Hi Stephen, > > I run basic checks on the patch set, mainly it compiles and applies > fine, overall patch set looks good. > > Only get following checkpatch warning: > Only v5,02/38 has one WARNING:MACRO_WITH_FLOW_CONTROL > This is intentional, is this style of copy/paste avoidance not allowed? -- Stephen Hurd Principal Engineer - Software Development Broadcom Corporation 949-926-8039 stephen.hurd at broadcom.com
[dpdk-dev] [PATCH v6 00/38] new bnxt poll mode driver library
The bnxt poll mode library (librte_pmd_bnxt) implements support for Broadcom NetXtreme C-Series. These adapters support Standards- compliant 10/25/50Gbps 30MPPS full-duplex throughput. Information about this family of adapters can be found in the NetXtreme Brand section https://goo.gl/4H7q63 of the Broadcom web site http://www.broadcom.com/ With the current driver, allocated mbufs must be large enough to hold the entire received frame. If the mbufs are not large enough, the packets will be dropped. This is most limiting when jumbo frames are used. Ajit Khaparde (38): bnxt: new driver for Broadcom NetXtreme-C devices bnxt: add HWRM init code bnxt: add driver register/unregister support bnxt: add dev infos get operation bnxt: add dev configure operation bnxt: add vnic functions and structs bnxt: declare generic ring structs and free() func bnxt: add completion ring support bnxt: add L2 filter alloc/init/free bnxt: add Tx queue operations (nonfunctional) bnxt: add Rx queue create/destroy operations bnxt: add statistics operations bnxt: add initial Tx code implementation bnxt: add initial Rx code implementation bnxt: add code to alloc/free Tx Rx and cmpl rings bnxt: add HWRM function reset command bnxt: add HWRM vnic alloc function bnxt: add HWRM vnic free function bnxt: add HWRM vnic configure function bnxt: add API to allow configuration of vnic bnxt: add HWRM API to configure RSS bnxt: add API for L2 Rx mask set/clear functions bnxt: add HWRM API for stats context allocation bnxt: add HWRM ring alloc/free functions bnxt: add ring group alloc/free functions bnxt: add HWRM stat context free function bnxt: add HWRM API to set and clear filters bnxt: allocate and free all HWRM rings and groups bnxt: add HWRM port PHY config call and helpers bnxt: add start/stop/link update operations bnxt: add promiscuous enable/disable operations bnxt: add all multicast enable/disable operations bnxt: free memory in close operation bnxt: add MAC address add/remove dev ops bnxt: add set link up/down operations bnxt: add reta update/query operations bnxt: add RSS device operations bnxt: add flow control operations MAINTAINERS |5 + config/common_base |5 + doc/guides/nics/bnxt.rst| 49 + doc/guides/nics/index.rst |1 + doc/guides/nics/overview.rst| 138 +- drivers/net/Makefile|1 + drivers/net/bnxt/Makefile | 73 + drivers/net/bnxt/bnxt.h | 176 + drivers/net/bnxt/bnxt_cpr.c | 159 + drivers/net/bnxt/bnxt_cpr.h | 86 + drivers/net/bnxt/bnxt_ethdev.c | 1049 drivers/net/bnxt/bnxt_filter.c | 175 + drivers/net/bnxt/bnxt_filter.h | 74 + drivers/net/bnxt/bnxt_hwrm.c| 1491 ++ drivers/net/bnxt/bnxt_hwrm.h| 104 + drivers/net/bnxt/bnxt_ring.c| 306 ++ drivers/net/bnxt/bnxt_ring.h| 103 + drivers/net/bnxt/bnxt_rxq.c | 319 ++ drivers/net/bnxt/bnxt_rxq.h | 74 + drivers/net/bnxt/bnxt_rxr.c | 367 ++ drivers/net/bnxt/bnxt_rxr.h | 62 + drivers/net/bnxt/bnxt_stats.c | 142 + drivers/net/bnxt/bnxt_stats.h | 44 + drivers/net/bnxt/bnxt_txq.c | 162 + drivers/net/bnxt/bnxt_txq.h | 75 + drivers/net/bnxt/bnxt_txr.c | 339 ++ drivers/net/bnxt/bnxt_txr.h | 71 + drivers/net/bnxt/bnxt_vnic.c| 277 ++ drivers/net/bnxt/bnxt_vnic.h| 80 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 5799 +++ drivers/net/bnxt/rte_pmd_bnxt_version.map |4 + lib/librte_eal/common/include/rte_pci_dev_ids.h | 38 +- mk/rte.app.mk |1 + 33 files changed, 11775 insertions(+), 74 deletions(-) create mode 100644 doc/guides/nics/bnxt.rst create mode 100644 drivers/net/bnxt/Makefile create mode 100644 drivers/net/bnxt/bnxt.h create mode 100644 drivers/net/bnxt/bnxt_cpr.c create mode 100644 drivers/net/bnxt/bnxt_cpr.h create mode 100644 drivers/net/bnxt/bnxt_ethdev.c create mode 100644 drivers/net/bnxt/bnxt_filter.c create mode 100644 drivers/net/bnxt/bnxt_filter.h create mode 100644 drivers/net/bnxt/bnxt_hwrm.c create mode 100644 drivers/net/bnxt/bnxt_hwrm.h create mode 100644 drivers/net/bnxt/bnxt_ring.c create mode 100644 drivers/net/bnxt/bnxt_ring.h create mode 100644 drivers/net/bnxt/bnxt_rxq.c create mode 100644 drivers/net/bnxt/bnxt_rxq.h create mode 100644 drivers/net/bnxt/bnxt_rxr.c create mode 100644 drivers/net/bnxt/bnxt_rxr.h create
[dpdk-dev] [PATCH v6 01/38] bnxt: new driver for Broadcom NetXtreme-C devices
From: Ajit Khaparde This patch adds the initial skeleton for bnxt driver along with the nic guide to tie into the build system. At this point, the driver simply fails init. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix a warning that the document isn't included in any toctree Also remove a PCI ID added erroneously. v5: Re-format footer v6: Add a column for the bnxt driver in doc/guides/nics/overview.rst --- MAINTAINERS | 5 + config/common_base | 5 + doc/guides/nics/bnxt.rst| 49 + doc/guides/nics/index.rst | 1 + doc/guides/nics/overview.rst| 138 drivers/net/Makefile| 1 + drivers/net/bnxt/Makefile | 63 +++ drivers/net/bnxt/bnxt_ethdev.c | 109 +++ drivers/net/bnxt/rte_pmd_bnxt_version.map | 4 + lib/librte_eal/common/include/rte_pci_dev_ids.h | 38 ++- mk/rte.app.mk | 1 + 11 files changed, 340 insertions(+), 74 deletions(-) create mode 100644 doc/guides/nics/bnxt.rst create mode 100644 drivers/net/bnxt/Makefile create mode 100644 drivers/net/bnxt/bnxt_ethdev.c create mode 100644 drivers/net/bnxt/rte_pmd_bnxt_version.map diff --git a/MAINTAINERS b/MAINTAINERS index 3e6b70c..78d8530 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -401,6 +401,11 @@ M: Declan Doherty F: drivers/crypto/null/ F: doc/guides/cryptodevs/null.rst +Broadcom BNXT PMD +M: Stephen Hurd +F: drivers/net/bnxt/ +F: doc/guides/nics/bnxt.rst + Packet processing - diff --git a/config/common_base b/config/common_base index b9ba405..71be7cd 100644 --- a/config/common_base +++ b/config/common_base @@ -245,6 +245,11 @@ CONFIG_RTE_LIBRTE_NFP_PMD=n CONFIG_RTE_LIBRTE_NFP_DEBUG=n # +# Compile burst-oriented Broadcom BNXT PMD driver +# +CONFIG_RTE_LIBRTE_BNXT_PMD=y + +# # Compile software PMD backed by SZEDATA2 device # CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n diff --git a/doc/guides/nics/bnxt.rst b/doc/guides/nics/bnxt.rst new file mode 100644 index 000..2669e98 --- /dev/null +++ b/doc/guides/nics/bnxt.rst @@ -0,0 +1,49 @@ +.. BSD LICENSE +Copyright 2016 Broadcom Limited + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +* Neither the name of Broadcom Limited nor the names of its +contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +bnxt poll mode driver library += + +The bnxt poll mode library (**librte_pmd_bnxt**) implements support for +**Broadcom NetXtreme? C-Series**. These adapters support Standards- +compliant 10/25/50Gbps 30MPPS full-duplex throughput. + +Information about this family of adapters can be found in the +`NetXtreme? Brand section <https://www.broadcom.com/products/ethernet-communication-and-switching?technology%5B%5D=88>`_ +of the `Broadcom web site <http://www.broadcom.com/>`_. + +Limitations +--- + +With the current driver, allocated mbufs must be large enough to hold +the entire received frame. If the mbufs are not large enough, the +packets will be dropped. This is most limiting when jumbo frames are +used. + +SR-IOV is not supported. diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst index 0b13698..ffe011e 100644 --- a/doc/guides/nics/index.rst +++ b/doc/guides/nics/index.rst @@ -36,6 +36,7 @@ Network Interface Controller Drivers :numbered: overview +bnxt bnx2x
[dpdk-dev] [PATCH v6 04/38] bnxt: add dev infos get operation
From: Ajit Khaparde Gets device info from the bp structure filled in the init() function. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder footer --- drivers/net/bnxt/bnxt.h| 3 ++ drivers/net/bnxt/bnxt_ethdev.c | 95 ++ drivers/net/bnxt/bnxt_hwrm.c | 2 +- 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index ed057ef..f8707b2 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -42,6 +42,9 @@ #include #include +#define BNXT_MAX_MTU 9000 +#define VLAN_TAG_SIZE 4 + struct bnxt_vf_info { uint16_tfw_fid; uint8_t mac_addr[ETHER_ADDR_LEN]; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 26e6447..a8a9912 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -61,10 +61,105 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) } /* + * Device configuration and status function + */ + +static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev, + struct rte_eth_dev_info *dev_info) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + uint16_t max_vnics, i, j, vpool, vrxq; + + /* MAC Specifics */ + dev_info->max_mac_addrs = MAX_NUM_MAC_ADDR; + dev_info->max_hash_mac_addrs = 0; + + /* PF/VF specifics */ + if (BNXT_PF(bp)) { + dev_info->max_rx_queues = bp->pf.max_rx_rings; + dev_info->max_tx_queues = bp->pf.max_tx_rings; + dev_info->max_vfs = bp->pf.active_vfs; + dev_info->reta_size = bp->pf.max_rsscos_ctx; + max_vnics = bp->pf.max_vnics; + } else { + dev_info->max_rx_queues = bp->vf.max_rx_rings; + dev_info->max_tx_queues = bp->vf.max_tx_rings; + dev_info->reta_size = bp->vf.max_rsscos_ctx; + max_vnics = bp->vf.max_vnics; + } + + /* Fast path specifics */ + dev_info->min_rx_bufsize = 1; + dev_info->max_rx_pktlen = BNXT_MAX_MTU + ETHER_HDR_LEN + ETHER_CRC_LEN + + VLAN_TAG_SIZE; + dev_info->rx_offload_capa = 0; + dev_info->tx_offload_capa = DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_TSO; + + /* *INDENT-OFF* */ + dev_info->default_rxconf = (struct rte_eth_rxconf) { + .rx_thresh = { + .pthresh = 8, + .hthresh = 8, + .wthresh = 0, + }, + .rx_free_thresh = 32, + .rx_drop_en = 0, + }; + + dev_info->default_txconf = (struct rte_eth_txconf) { + .tx_thresh = { + .pthresh = 32, + .hthresh = 0, + .wthresh = 0, + }, + .tx_free_thresh = 32, + .tx_rs_thresh = 32, + .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS | +ETH_TXQ_FLAGS_NOOFFLOADS, + }; + /* *INDENT-ON* */ + + /* +* TODO: default_rxconf, default_txconf, rx_desc_lim, and tx_desc_lim +* need further investigation. +*/ + + /* VMDq resources */ + vpool = 64; /* ETH_64_POOLS */ + vrxq = 128; /* ETH_VMDQ_DCB_NUM_QUEUES */ + for (i = 0; i < 4; vpool >>= 1, i++) { + if (max_vnics > vpool) { + for (j = 0; j < 5; vrxq >>= 1, j++) { + if (dev_info->max_rx_queues > vrxq) { + if (vpool > vrxq) + vpool = vrxq; + goto found; + } + } + /* Not enough resources to support VMDq */ + break; + } + } + /* Not enough resources to support VMDq */ + vpool = 0; + vrxq = 0; +found: + dev_info->max_vmdq_pools = vpool; + dev_info->vmdq_queue_num = vrxq; + + dev_info->vmdq_pool_base = 0; + dev_info->vmdq_queue_base = 0; +} + +/* * Initialization */ static struct eth_dev_ops bnxt_dev_ops = { + .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, }; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 8aba8cd..3eabf0c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -83,7 +83,7 @@ sta
[dpdk-dev] [PATCH v6 06/38] bnxt: add vnic functions and structs
From: Ajit Khaparde Add functions to allocate, initialize, and free vnics. A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 14 ++ drivers/net/bnxt/bnxt_vnic.c | 277 + drivers/net/bnxt/bnxt_vnic.h | 80 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 3 + 5 files changed, 375 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_vnic.c create mode 100644 drivers/net/bnxt/bnxt_vnic.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 9965597..c57afaa 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # # Export include files diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index bfce91e..d0f84f4 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -45,6 +45,13 @@ #define BNXT_MAX_MTU 9000 #define VLAN_TAG_SIZE 4 +enum bnxt_hw_context { + HW_CONTEXT_NONE = 0, + HW_CONTEXT_IS_RSS = 1, + HW_CONTEXT_IS_COS = 2, + HW_CONTEXT_IS_LB= 3, +}; + struct bnxt_vf_info { uint16_tfw_fid; uint8_t mac_addr[ETHER_ADDR_LEN]; @@ -130,6 +137,13 @@ struct bnxt { unsigned inttx_cp_nr_rings; struct bnxt_tx_queue **tx_queues; + struct bnxt_vnic_info *vnic_info; + STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; + + /* VNIC pointer for flow filter (VMDq) pools */ +#define MAX_FF_POOLS ETH_64_POOLS + STAILQ_HEAD(, bnxt_vnic_info) ff_pool[MAX_FF_POOLS]; + #define MAX_NUM_MAC_ADDR 32 uint8_t mac_addr[ETHER_ADDR_LEN]; diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c new file mode 100644 index 000..c04c4c7 --- /dev/null +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -0,0 +1,277 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2014-2015 Broadcom Corporation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include + +#include "bnxt.h" +#include "bnxt_vnic.h" +#include "hsi_struct_def_dpdk.h" + +/* + * VNIC Functions + */ + +static void prandom_bytes(void *dest_ptr, size_t len) +{ + char *dest = (char *)dest_ptr; + uint64_t rb; + + while (len) { + rb = rte_rand(); + if (len >= 8) { + memcpy(dest, &rb, 8); + len -= 8; + dest += 8; + } else { + memcpy(dest, &rb, len); + dest += len; + len = 0; + } + } +} + +void bnxt_init_vnics(struct bnxt *bp) +{ + struct bnxt_vnic_info *vnic; + uint16_t max_vnics; + int i, j; + + if (BNXT_PF(bp)) { + struct bnxt_pf_i
[dpdk-dev] [PATCH v6 07/38] bnxt: declare generic ring structs and free() func
From: Ajit Khaparde Declare generic ring structures and a free() function. These are generic ring management functions which will be used to create Tx, Rx and Completion rings in the subsequent patches, and tie them to the HWRM managed ring resources. This generic ring structure is shared all the ring types and tracks the the host Buffer Descriptors (BDs) and the HWRM assigned ID. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address checkpatch warnings. v5: Reorder footer v6: Correct typo --- drivers/net/bnxt/Makefile| 1 + drivers/net/bnxt/bnxt_ring.c | 47 ++ drivers/net/bnxt/bnxt_ring.h | 92 3 files changed, 140 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_ring.c create mode 100644 drivers/net/bnxt/bnxt_ring.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index c57afaa..757ea62 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c new file mode 100644 index 000..b57d3ba --- /dev/null +++ b/drivers/net/bnxt/bnxt_ring.c @@ -0,0 +1,47 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bnxt.h" +#include "bnxt_ring.h" + +/* + * Generic ring handling + */ + +void bnxt_free_ring(struct bnxt_ring *ring) +{ + if (ring->vmem_size && *ring->vmem) { + memset((char *)*ring->vmem, 0, ring->vmem_size); + *ring->vmem = NULL; + } +} diff --git a/drivers/net/bnxt/bnxt_ring.h b/drivers/net/bnxt/bnxt_ring.h new file mode 100644 index 000..3abfb04 --- /dev/null +++ b/drivers/net/bnxt/bnxt_ring.h @@ -0,0 +1,92 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUE
[dpdk-dev] [PATCH v6 05/38] bnxt: add dev configure operation
From: Ajit Khaparde The dev_configure_op function calls bnxt_set_hwrm_link_config() to setup the PHY. This calls the new bnxt_parse_eth_link_*() functions to translate from the DPDK macro values to those used by HWRM calls, then calls bnxt_hwrm_port_phy_cfg() to issue the HWRM call. New HWRM calls: bnxt_hwrm_port_phy_cfg: This command configures the PHY device for the port. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fixed few issues identified by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt.h| 32 +++ drivers/net/bnxt/bnxt_ethdev.c | 24 ++ drivers/net/bnxt/bnxt_hwrm.c | 230 drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 470 + 5 files changed, 757 insertions(+) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index f8707b2..bfce91e 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -81,6 +81,29 @@ struct bnxt_pf_info { struct bnxt_vf_info *vf; }; +/* Max wait time is 10 * 100ms = 1s */ +#define BNXT_LINK_WAIT_CNT 10 +#define BNXT_LINK_WAIT_INTERVAL100 +struct bnxt_link_info { + uint8_t phy_flags; + uint8_t mac_type; + uint8_t phy_link_status; + uint8_t loop_back; + uint8_t link_up; + uint8_t duplex; + uint8_t pause; + uint8_t force_pause; + uint8_t auto_pause; + uint8_t auto_mode; +#define PHY_VER_LEN3 + uint8_t phy_ver[PHY_VER_LEN]; + uint16_tlink_speed; + uint16_tsupport_speeds; + uint16_tauto_link_speed; + uint16_tauto_link_speed_mask; + uint32_tpreemphasis; +}; + #define BNXT_COS_QUEUE_COUNT 8 struct bnxt_cos_queue_info { uint8_t id; @@ -99,6 +122,14 @@ struct bnxt { #define BNXT_PF(bp)(!((bp)->flags & BNXT_FLAG_VF)) #define BNXT_VF(bp)((bp)->flags & BNXT_FLAG_VF) + unsigned intrx_nr_rings; + unsigned intrx_cp_nr_rings; + struct bnxt_rx_queue **rx_queues; + + unsigned inttx_nr_rings; + unsigned inttx_cp_nr_rings; + struct bnxt_tx_queue **tx_queues; + #define MAX_NUM_MAC_ADDR 32 uint8_t mac_addr[ETHER_ADDR_LEN]; @@ -109,6 +140,7 @@ struct bnxt { uint16_tmax_req_len; uint16_tmax_resp_len; + struct bnxt_link_info link_info; struct bnxt_cos_queue_info cos_queue[BNXT_COS_QUEUE_COUNT]; struct bnxt_pf_info pf; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index a8a9912..b46d2ce 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -154,6 +154,29 @@ found: dev_info->vmdq_queue_base = 0; } +/* Configure the device based on the configuration provided */ +static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + int rc; + + bp->rx_queues = (void *)eth_dev->data->rx_queues; + bp->tx_queues = (void *)eth_dev->data->tx_queues; + + /* Inherit new configurations */ + bp->rx_nr_rings = eth_dev->data->nb_rx_queues; + bp->tx_nr_rings = eth_dev->data->nb_tx_queues; + bp->rx_cp_nr_rings = bp->rx_nr_rings; + bp->tx_cp_nr_rings = bp->tx_nr_rings; + + if (eth_dev->data->dev_conf.rxmode.jumbo_frame) + eth_dev->data->mtu = + eth_dev->data->dev_conf.rxmode.max_rx_pkt_len - + ETHER_HDR_LEN - ETHER_CRC_LEN - VLAN_TAG_SIZE; + rc = bnxt_set_hwrm_link_config(bp, true); + return rc; +} + /* * Initialization */ @@ -161,6 +184,7 @@ found: static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, + .dev_configure = bnxt_dev_configure_op, }; static bool bnxt_vf_pciid(uint16_t id) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 3eabf0c..a2d7815 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -314,6 +314,61 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags) return rc; } +static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf) +{ + int rc = 0; + struct hwrm_port_phy_cfg_input req = {.req_type = 0}; + struct hwrm_port_phy_c
[dpdk-dev] [PATCH v6 03/38] bnxt: add driver register/unregister support
From: Ajit Khaparde Move init() cleanup into uninit() function Fix .dev_private_size New HWRM calls: bnxt_hwrm_func_driver_register: This command is used by the function driver to register its information with the HWRM. bnxt_hwrm_func_driver_unregister: This command is used by the function driver to unregister with the HWRM. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comment regarding removal of bnxt_dev_close_op v5: Reformat footer Add HWRM function descriptions --- drivers/net/bnxt/bnxt.h| 1 + drivers/net/bnxt/bnxt_ethdev.c | 29 +++- drivers/net/bnxt/bnxt_hwrm.c | 50 ++ drivers/net/bnxt/bnxt_hwrm.h | 3 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 271 + 5 files changed, 350 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 8cb7f5b..ed057ef 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -91,6 +91,7 @@ struct bnxt { struct rte_pci_device *pdev; uint32_tflags; +#define BNXT_FLAG_REGISTERED (1 << 0) #define BNXT_FLAG_VF (1 << 1) #define BNXT_PF(bp)(!((bp)->flags & BNXT_FLAG_VF)) #define BNXT_VF(bp)((bp)->flags & BNXT_FLAG_VF) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 32ed081..26e6447 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -176,17 +176,38 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) memcpy(bp->mac_addr, bp->vf.mac_addr, sizeof(bp->mac_addr)); memcpy(ð_dev->data->mac_addrs[0], bp->mac_addr, ETHER_ADDR_LEN); - return -EPERM; + rc = bnxt_hwrm_func_driver_register(bp, 0, + bp->pf.vf_req_fwd); + if (rc) { + RTE_LOG(ERR, PMD, + "Failed to register driver"); + rc = -EBUSY; + goto error_free; + } + + RTE_LOG(INFO, PMD, + DRV_MODULE_NAME " found at mem %" PRIx64 ", node addr %pM\n", + eth_dev->pci_dev->mem_resource[0].phys_addr, + eth_dev->pci_dev->mem_resource[0].addr); + + return 0; error_free: - bnxt_dev_close_op(eth_dev); + eth_dev->driver->eth_dev_uninit(eth_dev); error: return rc; } static int -bnxt_dev_uninit(struct rte_eth_dev *eth_dev __rte_unused) { - return 0; +bnxt_dev_uninit(struct rte_eth_dev *eth_dev) { + struct bnxt *bp = eth_dev->data->dev_private; + int rc; + + if (eth_dev->data->mac_addrs) + rte_free(eth_dev->data->mac_addrs); + rc = bnxt_hwrm_func_driver_unregister(bp, 0); + bnxt_free_hwrm_resources(bp); + return rc; } static struct eth_driver bnxt_rte_pmd = { diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index e187121..8aba8cd 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "bnxt.h" #include "bnxt_hwrm.h" @@ -178,6 +179,34 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp) return rc; } +int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags, + uint32_t *vf_req_fwd) +{ + int rc; + struct hwrm_func_drv_rgtr_input req = {.req_type = 0 }; + struct hwrm_func_drv_rgtr_output *resp = bp->hwrm_cmd_resp_addr; + + if (bp->flags & BNXT_FLAG_REGISTERED) + return 0; + + HWRM_PREP(req, FUNC_DRV_RGTR, -1, resp); + req.flags = flags; + req.enables = HWRM_FUNC_DRV_RGTR_INPUT_ENABLES_VER; + req.ver_maj = RTE_VER_YEAR; + req.ver_min = RTE_VER_MONTH; + req.ver_upd = RTE_VER_MINOR; + + memcpy(req.vf_req_fwd, vf_req_fwd, sizeof(req.vf_req_fwd)); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->flags |= BNXT_FLAG_REGISTERED; + + return rc; +} + int bnxt_hwrm_ver_get(struct bnxt *bp) { int rc = 0; @@ -264,6 +293,27 @@ error: return rc; } +int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags) +{ + int rc; + struct hwrm_func_drv_unrgtr_input req = {.req_type = 0 }; + struct hwrm_func_drv_unrgtr_output *resp = bp->hwrm_cmd_resp_addr; + + if (!(bp->flags & BNXT_FLAG_REGISTERED)) + return 0; + + HWRM_PREP(req, FUNC_DRV_UNRGTR, -1, resp); + req.flags = flags; + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->flags &= ~BNXT_FLAG_REGISTERED; + + return rc; +} + int bnxt_hwrm_queu
[dpdk-dev] [PATCH v6 15/38] bnxt: add code to alloc/free Tx Rx and cmpl rings
From: Ajit Khaparde Perform allocation and free()ing of ring and information structures for the TX, RX, and completion rings. The previous patches had so far provided top level stubs and generic ring support, while this patch does the real allocation and freeing of the memory specific to each different type of generic ring. For example bnxt_init_tx_ring_struct() or bnxt_init_rx_ring_struct() is now allocating memory based on the socked_id being provided. bnxt_tx_queue_setup_op() or bnxt_rx_queue_setup_op() have gone through some reformatting to perform a graceful cleanup in case memory allocation fails. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. Change the argument passed to bnxt_alloc_rings. Instead of passing bnxt_tx_ring and bnxt_rx_ring, shorten them to txr and rxr respectively. Add code to free the reserved memzone v5: More descriptive commit log Reorder footer --- drivers/net/bnxt/bnxt_cpr.c | 28 +++- drivers/net/bnxt/bnxt_cpr.h | 2 +- drivers/net/bnxt/bnxt_ring.c | 4 drivers/net/bnxt/bnxt_ring.h | 1 + drivers/net/bnxt/bnxt_rxq.c | 19 --- drivers/net/bnxt/bnxt_rxr.c | 42 ++ drivers/net/bnxt/bnxt_rxr.h | 2 +- drivers/net/bnxt/bnxt_txq.c | 25 - drivers/net/bnxt/bnxt_txr.c | 43 ++- drivers/net/bnxt/bnxt_txr.h | 2 +- 10 files changed, 127 insertions(+), 41 deletions(-) diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 5a4b13d..60c277a 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -31,6 +31,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #include "bnxt.h" #include "bnxt_cpr.h" #include "bnxt_hwrm.h" @@ -121,21 +123,37 @@ reject: void bnxt_free_def_cp_ring(struct bnxt *bp) { struct bnxt_cp_ring_info *cpr = bp->def_cp_ring; - struct bnxt_ring *ring = cpr->cp_ring_struct; - bnxt_free_ring(ring); + bnxt_free_ring(cpr->cp_ring_struct); + rte_free(cpr->cp_ring_struct); + rte_free(cpr); } /* For the default completion ring only */ -void bnxt_init_def_ring_struct(struct bnxt *bp) +int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id) { - struct bnxt_cp_ring_info *cpr = bp->def_cp_ring; - struct bnxt_ring *ring = cpr->cp_ring_struct; + struct bnxt_cp_ring_info *cpr; + struct bnxt_ring *ring; + cpr = rte_zmalloc_socket("cpr", +sizeof(struct bnxt_cp_ring_info), +RTE_CACHE_LINE_SIZE, socket_id); + if (cpr == NULL) + return -ENOMEM; + bp->def_cp_ring = cpr; + + ring = rte_zmalloc_socket("bnxt_cp_ring_struct", + sizeof(struct bnxt_ring), + RTE_CACHE_LINE_SIZE, socket_id); + if (ring == NULL) + return -ENOMEM; + cpr->cp_ring_struct = ring; ring->bd = (void *)cpr->cp_desc_ring; ring->bd_dma = cpr->cp_desc_mapping; ring->ring_size = rte_align32pow2(DEFAULT_CP_RING_SIZE); ring->ring_mask = ring->ring_size - 1; ring->vmem_size = 0; ring->vmem = NULL; + + return 0; } diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h index 4bd5606..c176f8c 100644 --- a/drivers/net/bnxt/bnxt_cpr.h +++ b/drivers/net/bnxt/bnxt_cpr.h @@ -79,7 +79,7 @@ struct bnxt_cp_ring_info { struct bnxt; void bnxt_free_def_cp_ring(struct bnxt *bp); -void bnxt_init_def_ring_struct(struct bnxt *bp); +int bnxt_init_def_ring_struct(struct bnxt *bp, unsigned int socket_id); void bnxt_handle_async_event(struct bnxt *bp, struct cmpl_base *cmp); void bnxt_handle_fwd_req(struct bnxt *bp, struct cmpl_base *cmp); diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index f547a9e..67b009a 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -51,6 +51,7 @@ void bnxt_free_ring(struct bnxt_ring *ring) memset((char *)*ring->vmem, 0, ring->vmem_size); *ring->vmem = NULL; } + rte_memzone_free((const struct rte_memzone *)ring->mem_zone); } /* @@ -135,6 +136,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, tx_ring_info->tx_desc_ring = (struct tx_bd_long *)tx_ring->bd; tx_ring->bd_dma = mz->phys_addr + tx_ring_start; tx_ring_info->tx_desc_mapping = tx_ring->bd_dma; + tx_ring->mem_zone = (const void *)mz; if (!tx_ring->bd) return -ENOMEM; @@ -154,6 +156,7 @@ int bnxt_alloc_rings(
[dpdk-dev] [PATCH v6 13/38] bnxt: add initial Tx code implementation
From: Ajit Khaparde Initial implementation of tx_pkt_burst for transmit. bnxt_xmit_pkts() is the top level function that is called during Tx. bnxt_handle_tx_cp() is used to check and process the Tx completions generated for the Tx Buffer Descriptors sent by the hardware. This patch also adds code to allocate rings in the hardware. For each Tx queue allocated in the PMD driver, a corresponding ring in hardware will be created. Every time a Tx request is initiated via the bnxt_xmit_pkts() call, a Buffer Descriptor is created and is sent to the hardware via the associated Tx ring. On completing the Tx operation, the hardware will generates the status in the form of a completion. This completion is processed by the bnxt_handle_tx_cp() function. Functions like bnxt_init_tx_ring_struct() and bnxt_init_one_tx_ring() are used to initialize various members of the structure before starting Tx operations. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Expand the patch description Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_cpr.h| 4 +- drivers/net/bnxt/bnxt_ethdev.c | 3 +- drivers/net/bnxt/bnxt_ring.c | 145 ++ drivers/net/bnxt/bnxt_ring.h | 8 + drivers/net/bnxt/bnxt_txq.c| 42 ++- drivers/net/bnxt/bnxt_txr.c| 314 drivers/net/bnxt/bnxt_txr.h| 71 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 512 + 9 files changed, 1091 insertions(+), 9 deletions(-) create mode 100644 drivers/net/bnxt/bnxt_txr.c create mode 100644 drivers/net/bnxt/bnxt_txr.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index f6a04f8..0785681 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -56,6 +56,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h index 2be22de..4bd5606 100644 --- a/drivers/net/bnxt/bnxt_cpr.h +++ b/drivers/net/bnxt/bnxt_cpr.h @@ -51,11 +51,11 @@ #define B_CP_DB_REARM(cpr, raw_cons) \ (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_REARM_FLAGS | \ - RING_CMP(&cpr->cp_ring_struct, raw_cons))) + RING_CMP(cpr->cp_ring_struct, raw_cons))) #define B_CP_DIS_DB(cpr, raw_cons) \ (*(uint32_t *)((cpr)->cp_doorbell) = (DB_CP_FLAGS | \ - RING_CMP(&cpr->cp_ring_struct, raw_cons))) + RING_CMP(cpr->cp_ring_struct, raw_cons))) struct bnxt_ring; struct bnxt_cp_ring_info { diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3453509..4ace543 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -44,6 +44,7 @@ #include "bnxt_rxq.h" #include "bnxt_stats.h" #include "bnxt_txq.h" +#include "bnxt_txr.h" #define DRV_MODULE_NAME"bnxt" static const char bnxt_version[] = @@ -269,7 +270,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) } eth_dev->dev_ops = &bnxt_dev_ops; /* eth_dev->rx_pkt_burst = &bnxt_recv_pkts; */ - /* eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; */ + eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; rc = bnxt_alloc_hwrm_resources(bp); if (rc) { diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index b57d3ba..2645dda 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -31,8 +31,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include + #include "bnxt.h" +#include "bnxt_cpr.h" #include "bnxt_ring.h" +#include "bnxt_txr.h" + +#include "hsi_struct_def_dpdk.h" /* * Generic ring handling @@ -45,3 +51,142 @@ void bnxt_free_ring(struct bnxt_ring *ring) *ring->vmem = NULL; } } + +/* + * Allocates a completion ring with vmem and stats optionally also allocating + * a TX and/or RX ring. Passing NULL as tx_ring_info and/or rx_ring_info + * to not allocate them. + * + * Order in the allocation is: + * stats - Always non-zero length + * cp vmem - Always zero-length, supported for the bnxt_ring abstraction + * tx vmem - Only non-zero length if tx_ring_info is not NULL + * rx vmem - Only non-zero length if rx_ring_info is not NULL + * cp bd
[dpdk-dev] [PATCH v6 16/38] bnxt: add HWRM function reset command
From: Ajit Khaparde Add bnxt_hwrm_func_reset() function and supporting structs and macros. New HWRM calls: bnxt_hwrm_func_reset: This command puts the function into the reset state. In the reset state, global and port related features of the chip are not available. This command resets a hardware function (PCIe function) and frees any resources used by the function. This command initiated by the driver prepare the function for re-use. This command may also be initiated by a driver prior to doing it's own configuration. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- More descriptive commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 17 + drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 129 + 3 files changed, 147 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 633683b..d1ca60a 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -265,6 +265,23 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp) return rc; } +int bnxt_hwrm_func_reset(struct bnxt *bp) +{ + int rc = 0; + struct hwrm_func_reset_input req = {.req_type = 0 }; + struct hwrm_func_reset_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, FUNC_RESET, -1, resp); + + req.enables = rte_cpu_to_le_32(0); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags, uint32_t *vf_req_fwd) { diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 75c3442..2679d09 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -54,6 +54,7 @@ int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, void *fwd_cmd); int bnxt_hwrm_func_driver_register(struct bnxt *bp, uint32_t flags, uint32_t *vf_req_fwd); int bnxt_hwrm_func_qcaps(struct bnxt *bp); +int bnxt_hwrm_func_reset(struct bnxt *bp); int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags); int bnxt_hwrm_queue_qportcfg(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 8b30787..6209368 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -83,6 +83,7 @@ struct ctx_hw_stats64 { * Request types */ #define HWRM_VER_GET (UINT32_C(0x0)) +#define HWRM_FUNC_RESET(UINT32_C(0x11)) #define HWRM_FUNC_QCAPS(UINT32_C(0x15)) #define HWRM_FUNC_DRV_UNRGTR (UINT32_C(0x1a)) #define HWRM_FUNC_DRV_RGTR (UINT32_C(0x1d)) @@ -2048,6 +2049,134 @@ struct hwrm_func_qcaps_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_func_reset */ +/* + * Description: This command resets a hardware function (PCIe function) and + * frees any resources used by the function. This command shall be initiated by + * the driver after an FLR has occurred to prepare the function for re-use. This + * command may also be initiated by a driver prior to doing it's own + * configuration. This command puts the function into the reset state. In the + * reset state, global and port related features of the chip are not available. + */ +/* + * Note: This command will reset a function that has already been disabled or + * idled. The command returns all the resources owned by the function so a new + * driver may allocate and configure resources normally. + */ + +/* Input (24 bytes) */ +struct hwrm_func_reset_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero before the request is made. +*/ + uint64_t resp_addr; + + /* This bit must be '1' for the vf_id_valid field to be configured. */ + #define HWRM_FUNC_RESE
[dpdk-dev] [PATCH v6 10/38] bnxt: add Tx queue operations (nonfunctional)
From: Ajit Khaparde In this patch we are adding the bnxt_tx_queue_setup_op() and bnxt_tx_queue_release_op() functions. These will be tied to the tx_queue_setup and tx_queue_release dev_ops in a subsequent patch. In these functions we allocate/free memory for the TX queues. This still requires support to create a TX ring in the ASIC which will be completed in a future commit. Each Tx queue created via the tx_queue_setup dev_op will have an associated Tx ring in the hardware. A Tx request coming on the Tx queue gets sent to the corresponding Tx ring in the ASIC for subsequent transmission. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_ethdev.c | 3 + drivers/net/bnxt/bnxt_txq.c| 124 + drivers/net/bnxt/bnxt_txq.h| 75 + 4 files changed, 203 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_txq.c create mode 100644 drivers/net/bnxt/bnxt_txq.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index b7834b1..13a90b9 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c # diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b46d2ce..77a6d92 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -41,6 +41,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" +#include "bnxt_txq.h" #define DRV_MODULE_NAME"bnxt" static const char bnxt_version[] = @@ -185,6 +186,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, .dev_configure = bnxt_dev_configure_op, + .tx_queue_setup = bnxt_tx_queue_setup_op, + .tx_queue_release = bnxt_tx_queue_release_op, }; static bool bnxt_vf_pciid(uint16_t id) diff --git a/drivers/net/bnxt/bnxt_txq.c b/drivers/net/bnxt/bnxt_txq.c new file mode 100644 index 000..8928984 --- /dev/null +++ b/drivers/net/bnxt/bnxt_txq.c @@ -0,0 +1,124 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include + +#include "bnxt.h" +#include "bnxt_ring.h" +#include "bnxt_txq.h" + +/* + * TX Queues + */ + +void bnxt_free_txq_stats(struct bnxt_tx_queue *txq) +{ + struct bnxt_cp_ring_info *cpr = txq->cp_ring; + + /* 'Unreserve' rte_memzone */ + + if (cpr->hw_stats) + cpr->hw_stats = NULL; +} + +static void bnxt_tx_queue_release_mbufs(struct bnxt_tx_queue *txq __rte_unused) +{ + /* TODO: Requires interaction with TX ring */ +} + +void bnxt_free_tx_mbufs(struct bnxt *bp) +{ + struct bnxt_tx_queue *txq; + int i; + + for (i = 0; i < (int)bp->tx_nr_rings; i++) { +
[dpdk-dev] [PATCH v6 11/38] bnxt: add Rx queue create/destroy operations
From: Ajit Khaparde In this patch we are adding the bnxt_rx_queue_setup_op() and bnxt_rx_queue_release_op() functions. These will be tied to the rx_queue_setup and rx_queue_release dev_ops in a subsequent patch. In these functions we allocate/free memory for the RX queues. This still requires support to create a RX ring in the ASIC which will be completed in a future commit. Each Rx queue created via the rx_queue_setup dev_op will have an associated Rx ring in the hardware. The Rx logic in the hardware picks a Rx ring for each Rx frame received by the hardware depending on the properties like RSS, MAC and VLAN settings configured in the hardware. These packets in the end arrive on the Rx queue corresponding to the Rx ring in the hardware. We are also adding some functions like bnxt_mq_rx_configure() bnxt_free_rx_mbufs() and bnxt_free_rxq_stats() which will be used in subsequent patches. We are also adding hwrm_vnic_rss_cfg_* structures, which will be used in subsequent patches to enable RSS configuration. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 2 + drivers/net/bnxt/bnxt_ethdev.c | 3 + drivers/net/bnxt/bnxt_rxq.c| 287 + drivers/net/bnxt/bnxt_rxq.h| 74 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 121 ++ 6 files changed, 488 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_rxq.c create mode 100644 drivers/net/bnxt/bnxt_rxq.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 13a90b9..21ed71c 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 49aa38b..f7cf9d1 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -142,6 +142,8 @@ struct bnxt { /* Default completion ring */ struct bnxt_cp_ring_info*def_cp_ring; + unsigned intnr_vnics; + struct bnxt_vnic_info *vnic_info; STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 77a6d92..7e7d1ab 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -41,6 +41,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" +#include "bnxt_rxq.h" #include "bnxt_txq.h" #define DRV_MODULE_NAME"bnxt" @@ -186,6 +187,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, .dev_configure = bnxt_dev_configure_op, + .rx_queue_setup = bnxt_rx_queue_setup_op, + .rx_queue_release = bnxt_rx_queue_release_op, .tx_queue_setup = bnxt_tx_queue_setup_op, .tx_queue_release = bnxt_tx_queue_release_op, }; diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c new file mode 100644 index 000..d5c3173 --- /dev/null +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -0,0 +1,287 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * L
[dpdk-dev] [PATCH v6 17/38] bnxt: add HWRM vnic alloc function
From: Ajit Khaparde This requires a group info array in struct bnxt, so add that, we can save the max size from the func_qcap response, and alloc/free in init/uninit A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. New HWRM call: bnxt_hwrm_vnic_alloc: Allocates a VNIC resource in the hardware. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/bnxt.h| 2 + drivers/net/bnxt/bnxt_hwrm.c | 32 +++ drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 99 ++ 4 files changed, 135 insertions(+) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index f7cf9d1..df1f771 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -141,6 +141,8 @@ struct bnxt { /* Default completion ring */ struct bnxt_cp_ring_info*def_cp_ring; + uint32_tmax_ring_grps; + struct bnxt_ring_grp_info *grp_info; unsigned intnr_vnics; diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index d1ca60a..fb0b7bf 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -43,6 +43,7 @@ #include "bnxt_filter.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_ring.h" #include "bnxt_txq.h" #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" @@ -235,6 +236,7 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp) HWRM_CHECK_RESULT; + bp->max_ring_grps = rte_le_to_cpu_32(resp->max_hw_ring_grps); if (BNXT_PF(bp)) { struct bnxt_pf_info *pf = &bp->pf; @@ -521,6 +523,36 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) return rc; } +int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0, i, j; + struct hwrm_vnic_alloc_input req = {.req_type = 0 }; + struct hwrm_vnic_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + /* map ring groups to this vnic */ + for (i = vnic->start_grp_id, j = 0; i <= vnic->end_grp_id; i++, j++) { + if (bp->grp_info[i].fw_grp_id == (uint16_t)HWRM_NA_SIGNATURE) { + RTE_LOG(ERR, PMD, + "Not enough ring groups avail:%x req:%x\n", j, + (vnic->end_grp_id - vnic->start_grp_id) + 1); + break; + } + vnic->fw_grp_ids[j] = bp->grp_info[i].fw_grp_id; + } + + vnic->fw_rss_cos_lb_ctx = (uint16_t)HWRM_NA_SIGNATURE; + vnic->ctx_is_rss_cos_lb = HW_CONTEXT_NONE; + + HWRM_PREP(req, VNIC_ALLOC, -1, resp); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id); + return rc; +} + /* * HWRM utility functions */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 2679d09..7d09773 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,6 +63,8 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_ver_get(struct bnxt *bp); +int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); + int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 6209368..eedd368 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -89,6 +89,7 @@ struct ctx_hw_stats64 { #define HWRM_FUNC_DRV_RGTR (UINT32_C(0x1d)) #define HWRM_PORT_PHY_CFG (UINT32_C(0x20)) #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30)) +#define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3119,6 +3120,104 @@ struct hwrm_stat_ctx_clr_stats_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_vnic_alloc */ +/* + * Description: This VNIC is a resource in the RX side of the chip that is used + * to represent a virtual host "interface". # At the time of VNIC allocation or + * configuration, the function can specify whether it wants the requested VNIC + * to be the default VNIC for the function or not. # If a function requests + * allocation of a VNI
[dpdk-dev] [PATCH v6 26/38] bnxt: add HWRM stat context free function
From: Ajit Khaparde Add function and associated structures and definitions to free statistics context from the ASIC. New HWRM call: bnxt_hwrm_stat_ctx_free This command is used to free a stat context. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 44 ++ drivers/net/bnxt/bnxt_hwrm.h | 3 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 81 ++ 3 files changed, 128 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index f335401..cb30109 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -742,6 +742,28 @@ int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, return rc; } +int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, + struct bnxt_cp_ring_info *cpr, unsigned int idx) +{ + int rc; + struct hwrm_stat_ctx_free_input req = {.req_type = 0 }; + struct hwrm_stat_ctx_free_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, STAT_CTX_FREE, -1, resp); + + req.stat_ctx_id = rte_cpu_to_le_16(cpr->hw_stats_ctx_id); + req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + cpr->hw_stats_ctx_id = HWRM_NA_SIGNATURE; + bp->grp_info[idx].fw_stats_ctx = cpr->hw_stats_ctx_id; + + return rc; +} + int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0, i, j; @@ -918,6 +940,28 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp) return 0; } +int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp) +{ + int rc; + unsigned int i; + struct bnxt_cp_ring_info *cpr; + + for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) { + unsigned int idx = i + 1; + + if (i >= bp->rx_cp_nr_rings) + cpr = bp->tx_queues[i - bp->rx_cp_nr_rings]->cp_ring; + else + cpr = bp->rx_queues[i]->cp_ring; + if (cpr->hw_stats_ctx_id != HWRM_NA_SIGNATURE) { + rc = bnxt_hwrm_stat_ctx_free(bp, cpr, idx); + if (rc) + return rc; + } + } + return 0; +} + int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) { unsigned int i; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index a9a8dc6..ffb45b1 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -74,6 +74,8 @@ int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx); int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, unsigned int idx); +int bnxt_hwrm_stat_ctx_free(struct bnxt *bp, + struct bnxt_cp_ring_info *cpr, unsigned int idx); int bnxt_hwrm_ver_get(struct bnxt *bp); @@ -87,6 +89,7 @@ int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); +int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp); int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 4e2eb9f..d58295a 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -104,6 +104,7 @@ struct ctx_hw_stats64 { #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) #define HWRM_CFA_L2_SET_RX_MASK(UINT32_C(0x93)) #define HWRM_STAT_CTX_ALLOC(UINT32_C(0xb0)) +#define HWRM_STAT_CTX_FREE (UINT32_C(0xb1)) #define HWRM_STAT_CTX_CLR_STATS(UINT32_C(0xb3)) #define HWRM_EXEC_FWD_RESP (UINT32_C(0xd0)) @@ -3839,6 +3840,86 @@ struct hwrm_stat_ctx_clr_stats_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_stat_ctx_free */ +/* Description: This command is used to free a stat context. */ +/* Input (24 bytes) */ + +struct hwrm_stat_ctx_free_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ +
[dpdk-dev] [PATCH v6 20/38] bnxt: add API to allow configuration of vnic
From: Ajit Khaparde This patch adds APIs to allow configuration of a VNIC. The functions alloc and free the Class of Service or COS and Load Balance context corresponding to the VNIC in the chip. New HWRM calls: bnxt_hwrm_vnic_ctx_alloc: Used to allocate COS/Load Balance context of VNIC bnxt_hwrm_vnic_ctx_free: Used to free COS/Load Balance context of VNIC Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: More description in commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 38 drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 153 + 3 files changed, 193 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 0c54129..5a5063f 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -587,6 +587,44 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_rss_cos_lb_ctx_alloc_input req = {.req_type = 0 }; + struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp = + bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_ALLOC, -1, resp); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_rss_cos_lb_ctx = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id); + + return rc; +} + +int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_rss_cos_lb_ctx_free_input req = {.req_type = 0 }; + struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp = + bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_FREE, -1, resp); + + req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_rss_cos_lb_ctx = INVALID_HW_RING_ID; + + return rc; +} + int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index cdaa295..fbb8aba 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -65,6 +65,8 @@ int bnxt_hwrm_ver_get(struct bnxt *bp); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index ef0b37a..6412df2 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -92,6 +92,8 @@ struct ctx_hw_stats64 { #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_VNIC_FREE (UINT32_C(0x41)) #define HWRM_VNIC_CFG (UINT32_C(0x42)) +#define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC (UINT32_C(0x70)) +#define HWRM_VNIC_RSS_COS_LB_CTX_FREE (UINT32_C(0x71)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3576,6 +3578,157 @@ struct hwrm_vnic_rss_cfg_output { uint8_t valid; } __attribute__((packed)); +/* Input (16 bytes) */ +struct hwrm_vnic_rss_cos_lb_ctx_alloc_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero
[dpdk-dev] [PATCH v6 12/38] bnxt: add statistics operations
From: Ajit Khaparde Add the bnxt_stats_get_op() and bnxt_stats_reset_op() dev_ops to get and reset statistics. It also brings in the associated HWRM calls to handle the requests appropriately. We also have the bnxt_free_stats() function which will be used in the follow on patches to free the memory allocated by the driver for statistics. New HWRM calls: bnxt_hwrm_stat_clear: This command clears statistics of a context Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Add more description for the patch Add HWRM function descriptions Reorder footer v6: Correct typos --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_cpr.c| 1 + drivers/net/bnxt/bnxt_cpr.h| 2 - drivers/net/bnxt/bnxt_ethdev.c | 3 + drivers/net/bnxt/bnxt_hwrm.c | 49 drivers/net/bnxt/bnxt_hwrm.h | 7 +- drivers/net/bnxt/bnxt_rxq.c| 1 + drivers/net/bnxt/bnxt_stats.c | 142 + drivers/net/bnxt/bnxt_stats.h | 44 ++ drivers/net/bnxt/bnxt_txq.c| 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 107 + 11 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 drivers/net/bnxt/bnxt_stats.c create mode 100644 drivers/net/bnxt/bnxt_stats.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 21ed71c..f6a04f8 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 7de2b9c..5a4b13d 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -35,6 +35,7 @@ #include "bnxt_cpr.h" #include "bnxt_hwrm.h" #include "bnxt_ring.h" +#include "hsi_struct_def_dpdk.h" /* * Async event handling diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h index ecabc5f..2be22de 100644 --- a/drivers/net/bnxt/bnxt_cpr.h +++ b/drivers/net/bnxt/bnxt_cpr.h @@ -34,8 +34,6 @@ #ifndef _BNXT_CPR_H_ #define _BNXT_CPR_H_ -#include "hsi_struct_def_dpdk.h" - #define CMP_VALID(cmp, raw_cons, ring) \ (!!(((struct cmpl_base *)(cmp))->info3_v & CMPL_BASE_V) == \ !((raw_cons) & ((ring)->ring_size))) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 7e7d1ab..3453509 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -42,6 +42,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_stats.h" #include "bnxt_txq.h" #define DRV_MODULE_NAME"bnxt" @@ -187,6 +188,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_infos_get = bnxt_dev_info_get_op, .dev_close = bnxt_dev_close_op, .dev_configure = bnxt_dev_configure_op, + .stats_get = bnxt_stats_get_op, + .stats_reset = bnxt_stats_reset_op, .rx_queue_setup = bnxt_rx_queue_setup_op, .rx_queue_release = bnxt_rx_queue_release_op, .tx_queue_setup = bnxt_tx_queue_setup_op, diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 65cd4a7..633683b 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -39,8 +39,11 @@ #include #include "bnxt.h" +#include "bnxt_cpr.h" #include "bnxt_filter.h" #include "bnxt_hwrm.h" +#include "bnxt_rxq.h" +#include "bnxt_txq.h" #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" @@ -480,10 +483,56 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) return rc; } +int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) +{ + int rc = 0; + struct hwrm_stat_ctx_clr_stats_input req = {.req_type = 0 }; + struct hwrm_stat_ctx_clr_stats_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, STAT_CTX_CLR_STATS, -1, resp); + + if (cpr->hw_stats_ctx_id == (uint32_t)HWRM_NA_SIGNATURE) + return rc; + + req.stat_ctx_id = rte_cpu_to_le_16(cpr->hw_stats_ctx_id); + req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + /* * HWRM utility functions */ +int bnxt_clear_al
[dpdk-dev] [PATCH v6 25/38] bnxt: add ring group alloc/free functions
From: Ajit Khaparde Add HWRM API for ring group alloc/free functions, associated structs and definitions. This API allocates and does basic preparation for a ring group in ASIC. A ring group is identified by an index. It consists of Rx ring id, completion ring id and a statistics context. New HWRM calls: bnxt_hwrm_ring_grp_alloc Allocates and does basic preparation for a ring group bnxt_hwrm_ring_grp_free Frees and does cleanup resources of a ring group Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address issues pointed out by checkpatch. v5: Reorder the footer. v6: Correct typos --- drivers/net/bnxt/bnxt_hwrm.c | 84 +++ drivers/net/bnxt/bnxt_hwrm.h | 4 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 185 + 3 files changed, 273 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 565b76f..f335401 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -655,6 +655,47 @@ int bnxt_hwrm_ring_free(struct bnxt *bp, return 0; } +int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx) +{ + int rc = 0; + struct hwrm_ring_grp_alloc_input req = {.req_type = 0 }; + struct hwrm_ring_grp_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_GRP_ALLOC, -1, resp); + + req.cr = rte_cpu_to_le_16(bp->grp_info[idx].cp_fw_ring_id); + req.rr = rte_cpu_to_le_16(bp->grp_info[idx].rx_fw_ring_id); + req.ar = rte_cpu_to_le_16(bp->grp_info[idx].ag_fw_ring_id); + req.sc = rte_cpu_to_le_16(bp->grp_info[idx].fw_stats_ctx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->grp_info[idx].fw_grp_id = + rte_le_to_cpu_16(resp->ring_group_id); + + return rc; +} + +int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx) +{ + int rc; + struct hwrm_ring_grp_free_input req = {.req_type = 0 }; + struct hwrm_ring_grp_free_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_GRP_FREE, -1, resp); + + req.ring_group_id = rte_cpu_to_le_16(bp->grp_info[idx].fw_grp_id); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + bp->grp_info[idx].fw_grp_id = INVALID_HW_RING_ID; + return rc; +} + int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) { int rc = 0; @@ -904,6 +945,49 @@ int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) return rc; } +int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp) +{ + uint16_t i; + uint32_t rc = 0; + + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + unsigned int idx = i + 1; + + if (bp->grp_info[idx].fw_grp_id == INVALID_HW_RING_ID) { + RTE_LOG(ERR, PMD, + "Attempt to free invalid ring group %d\n", + idx); + continue; + } + + rc = bnxt_hwrm_ring_grp_free(bp, idx); + + if (rc) + return rc; + } + return rc; +} + +int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp) +{ + uint16_t i; + uint32_t rc = 0; + + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + unsigned int idx = i + 1; + + if (bp->grp_info[idx].cp_fw_ring_id == INVALID_HW_RING_ID || + bp->grp_info[idx].rx_fw_ring_id == INVALID_HW_RING_ID) + continue; + + rc = bnxt_hwrm_ring_grp_alloc(bp, idx); + + if (rc) + return rc; + } + return rc; +} + void bnxt_free_hwrm_resources(struct bnxt *bp) { /* Release memzone */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index ebde5fb..a9a8dc6 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -68,6 +68,8 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp, uint32_t stats_ctx_id); int bnxt_hwrm_ring_free(struct bnxt *bp, struct bnxt_ring *ring, uint32_t ring_type); +int bnxt_hwrm_ring_grp_alloc(struct bnxt *bp, unsigned int idx); +int bnxt_hwrm_ring_grp_free(struct bnxt *bp, unsigned int idx); int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, @@ -85,6 +87,8 @@ int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); +int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp); +int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); int bnxt_set_hwrm_link
[dpdk-dev] [PATCH v6 19/38] bnxt: add HWRM vnic configure function
From: Ajit Khaparde A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. This patch configures the properties and actions of the vnic allocated by vnic_alloc function from the previous patch. bnxt_hwrm_vnic_cfg: Configure the VNIC structure in hardware. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 34 drivers/net/bnxt/bnxt_hwrm.h | 3 +- drivers/net/bnxt/hsi_struct_def_dpdk.h | 155 + 3 files changed, 191 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index fbbb81d..0c54129 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -553,6 +553,40 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_cfg_input req = {.req_type = 0 }; + struct hwrm_vnic_cfg_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_CFG, -1, resp); + + /* Only RSS support for now TBD: COS & LB */ + req.enables = + rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_ENABLES_DFLT_RING_GRP | +HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE | +HWRM_VNIC_CFG_INPUT_ENABLES_MRU); + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + req.dflt_ring_grp = + rte_cpu_to_le_16(bp->grp_info[vnic->start_grp_id].fw_grp_id); + req.rss_rule = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx); + req.cos_rule = rte_cpu_to_le_16(0x); + req.lb_rule = rte_cpu_to_le_16(0x); + req.mru = rte_cpu_to_le_16(bp->eth_dev->data->mtu + ETHER_HDR_LEN + + ETHER_CRC_LEN + VLAN_TAG_SIZE); + if (vnic->func_default) + req.flags = 1; + if (vnic->vlan_strip) + req.flags |= + rte_cpu_to_le_32(HWRM_VNIC_CFG_INPUT_FLAGS_VLAN_STRIP_MODE); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 93fb759..cdaa295 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,8 +63,9 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_ver_get(struct bnxt *bp); -int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 0771897..ef0b37a 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -91,6 +91,7 @@ struct ctx_hw_stats64 { #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30)) #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_VNIC_FREE (UINT32_C(0x41)) +#define HWRM_VNIC_CFG (UINT32_C(0x42)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3219,6 +3220,160 @@ struct hwrm_vnic_alloc_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_vnic_cfg */ +/* Description: Configure the RX VNIC structure. */ + +/* Input (40 bytes) */ +struct hwrm_vnic_cfg_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This
[dpdk-dev] [PATCH v6 27/38] bnxt: add HWRM API to set and clear filters
From: Ajit Khaparde New HWRM call: bnxt_clear_hwrm_vnic_filters This patch adds code to set and clear L2 filters from the corresponding VNIC. These filters will determine the Rx flows Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Separated this code from the previous patch as it had nothing to do with freeing of statistics context. v5: Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 26 ++ drivers/net/bnxt/bnxt_hwrm.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index cb30109..13f9e1c 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -1059,6 +1059,32 @@ int bnxt_alloc_hwrm_resources(struct bnxt *bp) return 0; } +int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + struct bnxt_filter_info *filter; + int rc = 0; + + STAILQ_FOREACH(filter, &vnic->filter, next) { + rc = bnxt_hwrm_clear_filter(bp, filter); + if (rc) + break; + } + return rc; +} + +int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + struct bnxt_filter_info *filter; + int rc = 0; + + STAILQ_FOREACH(filter, &vnic->filter, next) { + rc = bnxt_hwrm_set_filter(bp, vnic, filter); + if (rc) + break; + } + return rc; +} + static uint16_t bnxt_parse_eth_link_duplex(uint32_t conf_link_speed) { uint8_t hw_link_duplex = HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH; diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index ffb45b1..9c26118 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -92,6 +92,9 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_free_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp); int bnxt_alloc_all_hwrm_ring_grps(struct bnxt *bp); +int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_clear_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic); +void bnxt_free_all_hwrm_resources(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up); -- 1.9.1
[dpdk-dev] [PATCH v6 29/38] bnxt: add HWRM port PHY config call and helpers
From: Ajit Khaparde Add HWRM calls to query the port's PHY and link configuration. New HWRM call: bnxt_hwrm_port_phy_qcfg This command queries the PHY configuration for the port Also adding helper function like bnxt_get_hwrm_link_config() and bnxt_parse_hw_link_speed() parse the link state. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. v5: Reorder footer Rewrite the patch description. --- drivers/net/bnxt/bnxt_hwrm.c | 120 + drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 790 + 3 files changed, 911 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index fcc4811..5d81a60 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -521,6 +521,43 @@ static int bnxt_hwrm_port_phy_cfg(struct bnxt *bp, struct bnxt_link_info *conf) return rc; } +static int bnxt_hwrm_port_phy_qcfg(struct bnxt *bp, + struct bnxt_link_info *link_info) +{ + int rc = 0; + struct hwrm_port_phy_qcfg_input req = {.req_type = 0}; + struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, PORT_PHY_QCFG, -1, resp); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + link_info->phy_link_status = resp->link; + if (link_info->phy_link_status == HWRM_PORT_PHY_QCFG_OUTPUT_LINK_LINK) { + link_info->link_up = 1; + link_info->link_speed = rte_le_to_cpu_16(resp->link_speed); + } else { + link_info->link_up = 0; + link_info->link_speed = 0; + } + link_info->duplex = resp->duplex; + link_info->pause = resp->pause; + link_info->auto_pause = resp->auto_pause; + link_info->force_pause = resp->force_pause; + link_info->auto_mode = resp->auto_mode; + + link_info->support_speeds = rte_le_to_cpu_16(resp->support_speeds); + link_info->auto_link_speed = rte_le_to_cpu_16(resp->auto_link_speed); + link_info->preemphasis = rte_le_to_cpu_32(resp->preemphasis); + link_info->phy_ver[0] = resp->phy_maj; + link_info->phy_ver[1] = resp->phy_min; + link_info->phy_ver[2] = resp->phy_bld; + + return rc; +} + int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) { int rc = 0; @@ -1326,6 +1363,89 @@ static uint16_t bnxt_parse_eth_link_speed_mask(uint32_t link_speed) return ret; } +static uint32_t bnxt_parse_hw_link_speed(uint16_t hw_link_speed) +{ + uint32_t eth_link_speed = ETH_SPEED_NUM_NONE; + + switch (hw_link_speed) { + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_100MB: + eth_link_speed = ETH_SPEED_NUM_100M; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_1GB: + eth_link_speed = ETH_SPEED_NUM_1G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2_5GB: + eth_link_speed = ETH_SPEED_NUM_2_5G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_10GB: + eth_link_speed = ETH_SPEED_NUM_10G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_20GB: + eth_link_speed = ETH_SPEED_NUM_20G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_25GB: + eth_link_speed = ETH_SPEED_NUM_25G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_40GB: + eth_link_speed = ETH_SPEED_NUM_40G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_50GB: + eth_link_speed = ETH_SPEED_NUM_50G; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_LINK_SPEED_2GB: + default: + RTE_LOG(ERR, PMD, "HWRM link speed %d not defined\n", + hw_link_speed); + break; + } + return eth_link_speed; +} + +static uint16_t bnxt_parse_hw_link_duplex(uint16_t hw_link_duplex) +{ + uint16_t eth_link_duplex = ETH_LINK_FULL_DUPLEX; + + switch (hw_link_duplex) { + case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_BOTH: + case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_FULL: + eth_link_duplex = ETH_LINK_FULL_DUPLEX; + break; + case HWRM_PORT_PHY_CFG_INPUT_AUTO_DUPLEX_HALF: + eth_link_duplex = ETH_LINK_HALF_DUPLEX; + break; + default: + RTE_LOG(ERR, PMD, "HWRM link duplex %d not defined\n", + hw_link_duplex); + break; + } + return eth_link_duplex; +} + +int bnxt_get_hwrm_link_config(struct bnxt *bp, struct rte_eth_link *link) +{ + int rc = 0; +
[dpdk-dev] [PATCH v6 38/38] bnxt: add flow control operations
From: Ajit Khaparde Add flow_ctrl_get and flow_ctrl_set dev_ops. Uses the bnxt_set_hwrm_link_config() HWRM API added in earlier patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 83 ++ 1 file changed, 83 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3c7f868..406e38a 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -755,6 +755,87 @@ static int bnxt_rss_hash_conf_get_op(struct rte_eth_dev *eth_dev, return 0; } +static int bnxt_flow_ctrl_get_op(struct rte_eth_dev *dev, + struct rte_eth_fc_conf *fc_conf __rte_unused) +{ + struct bnxt *bp = (struct bnxt *)dev->data->dev_private; + struct rte_eth_link link_info; + int rc; + + rc = bnxt_get_hwrm_link_config(bp, &link_info); + if (rc) + return rc; + + memset(fc_conf, 0, sizeof(*fc_conf)); + if (bp->link_info.auto_pause) + fc_conf->autoneg = 1; + switch (bp->link_info.pause) { + case 0: + fc_conf->mode = RTE_FC_NONE; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX: + fc_conf->mode = RTE_FC_TX_PAUSE; + break; + case HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX: + fc_conf->mode = RTE_FC_RX_PAUSE; + break; + case (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_TX | + HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX): + fc_conf->mode = RTE_FC_FULL; + break; + } + return 0; +} + +static int bnxt_flow_ctrl_set_op(struct rte_eth_dev *dev, + struct rte_eth_fc_conf *fc_conf) +{ + struct bnxt *bp = (struct bnxt *)dev->data->dev_private; + + switch (fc_conf->mode) { + case RTE_FC_NONE: + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = 0; + break; + case RTE_FC_RX_PAUSE: + if (fc_conf->autoneg) { + bp->link_info.auto_pause = + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX; + bp->link_info.force_pause = 0; + } else { + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX; + } + break; + case RTE_FC_TX_PAUSE: + if (fc_conf->autoneg) { + bp->link_info.auto_pause = + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX; + bp->link_info.force_pause = 0; + } else { + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX; + } + break; + case RTE_FC_FULL: + if (fc_conf->autoneg) { + bp->link_info.auto_pause = + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_TX | + HWRM_PORT_PHY_CFG_INPUT_AUTO_PAUSE_RX; + bp->link_info.force_pause = 0; + } else { + bp->link_info.auto_pause = 0; + bp->link_info.force_pause = + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_TX | + HWRM_PORT_PHY_CFG_INPUT_FORCE_PAUSE_RX; + } + break; + } + return bnxt_set_hwrm_link_config(bp, true); +} + /* * Initialization */ @@ -784,6 +865,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .allmulticast_disable = bnxt_allmulticast_disable_op, .mac_addr_add = bnxt_mac_addr_add_op, .mac_addr_remove = bnxt_mac_addr_remove_op, + .flow_ctrl_get = bnxt_flow_ctrl_get_op, + .flow_ctrl_set = bnxt_flow_ctrl_set_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v6 32/38] bnxt: add all multicast enable/disable operations
From: Ajit Khaparde This patch adds dev_ops to enable/disable multicast traffic. Uses the bnxt_hwrm_cfa_l2_set_rx_mask() API added in the earlier patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder footer Rewrite the patch description. --- drivers/net/bnxt/bnxt_ethdev.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 3fce540..d3a624f 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -465,6 +465,34 @@ static void bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev) bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); } +static void bnxt_allmulticast_enable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags |= BNXT_VNIC_INFO_ALLMULTI; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + +static void bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + /* * Initialization */ @@ -484,6 +512,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .link_update = bnxt_link_update_op, .promiscuous_enable = bnxt_promiscuous_enable_op, .promiscuous_disable = bnxt_promiscuous_disable_op, + .allmulticast_enable = bnxt_allmulticast_enable_op, + .allmulticast_disable = bnxt_allmulticast_disable_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v6 22/38] bnxt: add API for L2 Rx mask set/clear functions
From: Ajit Khaparde Add API to set/clear L2 Rx mask. New HWRM calls: bnxt_hwrm_cfa_l2_clear_rx_mask bnxt_hwrm_cfa_l2_set_rx_mask These HWRM APIs allow setting and clearing of Rx masks in L2 context per VNIC. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 45 +++ drivers/net/bnxt/bnxt_hwrm.h | 3 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 135 + 3 files changed, 183 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 29b0729..2c43159 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -141,6 +141,51 @@ static int bnxt_hwrm_send_message(struct bnxt *bp, void *msg, uint32_t msg_len) } \ } +int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 }; + struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, CFA_L2_SET_RX_MASK, -1, resp); + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + req.mask = 0; + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + +int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_cfa_l2_set_rx_mask_input req = {.req_type = 0 }; + struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr; + uint32_t mask = 0; + + HWRM_PREP(req, CFA_L2_SET_RX_MASK, -1, resp); + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + + /* FIXME add multicast flag, when multicast adding options is supported +* by ethtool. +*/ + if (vnic->flags & BNXT_VNIC_INFO_PROMISC) + mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS; + if (vnic->flags & BNXT_VNIC_INFO_ALLMULTI) + mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST; + req.mask = rte_cpu_to_le_32(HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST | + HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST | + mask); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + int bnxt_hwrm_clear_filter(struct bnxt *bp, struct bnxt_filter_info *filter) { diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 8c7b939..8037242 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -43,6 +43,9 @@ struct bnxt_cp_ring_info; #define HWRM_SEQ_ID_INVALID -1U +int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp, + struct bnxt_vnic_info *vnic); +int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_clear_filter(struct bnxt *bp, struct bnxt_filter_info *filter); int bnxt_hwrm_set_filter(struct bnxt *bp, diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 72d4984..f8f6a3f 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -1732,6 +1732,141 @@ struct hwrm_cfa_l2_filter_free_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_cfa_l2_set_rx_mask */ +/* Description: This command will set rx mask of the function. */ + +/* Input (40 bytes) */ +struct hwrm_cfa_l2_set_rx_mask_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero before the request is made. +*/ + uint64_t resp_addr; + + /* VNIC ID */ + uint32_t vnic_id; + + /* Reserved for future use. */ + #define HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_RESERVED UINT32_C(0x1) + /* +* Whe
[dpdk-dev] [PATCH v6 34/38] bnxt: add MAC address add/remove dev ops
From: Ajit Khaparde This patch adds dev_ops to Add/Remove MAC addresses. These use the bnxt_hwrm_set_filter() defined in the previous patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 71 ++ 1 file changed, 71 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4254531..34a5873 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -402,6 +402,75 @@ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) bnxt_shutdown_nic(bp); } +static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev, + uint32_t index) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + uint64_t pool_mask = eth_dev->data->mac_pool_sel[index]; + struct bnxt_vnic_info *vnic; + struct bnxt_filter_info *filter, *temp_filter; + int i; + + /* +* Loop through all VNICs from the specified filter flow pools to +* remove the corresponding MAC addr filter +*/ + for (i = 0; i < MAX_FF_POOLS; i++) { + if (!(pool_mask & (1 << i))) + continue; + + STAILQ_FOREACH(vnic, &bp->ff_pool[i], next) { + filter = STAILQ_FIRST(&vnic->filter); + while (filter) { + temp_filter = STAILQ_NEXT(filter, next); + if (filter->mac_index == index) { + STAILQ_REMOVE(&vnic->filter, filter, + bnxt_filter_info, next); + bnxt_hwrm_clear_filter(bp, filter); + filter->mac_index = INVALID_MAC_INDEX; + memset(&filter->l2_addr, 0, + ETHER_ADDR_LEN); + STAILQ_INSERT_TAIL( + &bp->free_filter_list, + filter, next); + } + filter = temp_filter; + } + } + } +} + +static void bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev, +struct ether_addr *mac_addr, +uint32_t index, uint32_t pool) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic = STAILQ_FIRST(&bp->ff_pool[pool]); + struct bnxt_filter_info *filter; + + if (!vnic) { + RTE_LOG(ERR, PMD, "VNIC not found for pool %d!\n", pool); + return; + } + /* Attach requested MAC address to the new l2_filter */ + STAILQ_FOREACH(filter, &vnic->filter, next) { + if (filter->mac_index == index) { + RTE_LOG(ERR, PMD, + "MAC addr already existed for pool %d\n", pool); + return; + } + } + filter = bnxt_alloc_filter(bp); + if (!filter) { + RTE_LOG(ERR, PMD, "L2 filter alloc failed\n"); + return; + } + STAILQ_INSERT_TAIL(&vnic->filter, filter, next); + filter->mac_index = index; + memcpy(filter->l2_addr, mac_addr, ETHER_ADDR_LEN); + bnxt_hwrm_set_filter(bp, vnic, filter); +} + static int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) { @@ -516,6 +585,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .promiscuous_disable = bnxt_promiscuous_disable_op, .allmulticast_enable = bnxt_allmulticast_enable_op, .allmulticast_disable = bnxt_allmulticast_disable_op, + .mac_addr_add = bnxt_mac_addr_add_op, + .mac_addr_remove = bnxt_mac_addr_remove_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v6 23/38] bnxt: add HWRM API for stats context allocation
From: Ajit Khaparde Add HWRM API code to allocate a statistics context in the ASIC. This API will be called by the previously submitted "add statistics operations patch". New HWRM call: bnxt_hwrm_stat_ctx_alloc: This command allocates and does basic preparation for a stat context. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 52 drivers/net/bnxt/bnxt_hwrm.h | 3 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 89 ++ 3 files changed, 144 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 2c43159..420a1cc 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -568,6 +568,31 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) return rc; } +int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, +struct bnxt_cp_ring_info *cpr, unsigned int idx) +{ + int rc; + struct hwrm_stat_ctx_alloc_input req = {.req_type = 0 }; + struct hwrm_stat_ctx_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, STAT_CTX_ALLOC, -1, resp); + + req.update_period_ms = rte_cpu_to_le_32(1000); + + req.seq_id = rte_cpu_to_le_16(bp->hwrm_cmd_seq++); + req.stats_dma_addr = + rte_cpu_to_le_64(cpr->hw_stats_map); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + cpr->hw_stats_ctx_id = rte_le_to_cpu_16(resp->stat_ctx_id); + bp->grp_info[idx].fw_stats_ctx = cpr->hw_stats_ctx_id; + + return rc; +} + int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) { int rc = 0, i, j; @@ -744,6 +769,33 @@ int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp) return 0; } +int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp) +{ + unsigned int i; + int rc = 0; + + for (i = 0; i < bp->rx_cp_nr_rings + bp->tx_cp_nr_rings; i++) { + struct bnxt_tx_queue *txq; + struct bnxt_rx_queue *rxq; + struct bnxt_cp_ring_info *cpr; + unsigned int idx = i + 1; + + if (i >= bp->rx_cp_nr_rings) { + txq = bp->tx_queues[i - bp->rx_cp_nr_rings]; + cpr = txq->cp_ring; + } else { + rxq = bp->rx_queues[i]; + cpr = rxq->cp_ring; + } + + rc = bnxt_hwrm_stat_ctx_alloc(bp, cpr, idx); + + if (rc) + return rc; + } + return rc; +} + void bnxt_free_hwrm_resources(struct bnxt *bp) { /* Release memzone */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 8037242..49966f5 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,6 +63,8 @@ int bnxt_hwrm_func_driver_unregister(struct bnxt *bp, uint32_t flags); int bnxt_hwrm_queue_qportcfg(struct bnxt *bp); int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); +int bnxt_hwrm_stat_ctx_alloc(struct bnxt *bp, +struct bnxt_cp_ring_info *cpr, unsigned int idx); int bnxt_hwrm_ver_get(struct bnxt *bp); @@ -74,6 +76,7 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_alloc_all_hwrm_stat_ctxs(struct bnxt *bp); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); int bnxt_alloc_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index f8f6a3f..28362c9 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -99,6 +99,7 @@ struct ctx_hw_stats64 { #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) #define HWRM_CFA_L2_SET_RX_MASK(UINT32_C(0x93)) +#define HWRM_STAT_CTX_ALLOC(UINT32_C(0xb0)) #define HWRM_STAT_CTX_CLR_STATS(UINT32_C(0xb3)) #define HWRM_EXEC_FWD_RESP (UINT32_C(0xd0)) @@ -3183,6 +3184,94 @@ struct hwrm_queue_qportcfg_input { uint16_t unused_0; } __attribute__((packed)); +/* hwrm_stat_ctx_alloc */ +/* + * Description: This command allocates and does basic preparation for a stat + * context. + */ + +/* Input (32 bytes) */ +struct hwrm_stat_ctx_alloc_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command i
[dpdk-dev] [PATCH v6 31/38] bnxt: add promiscuous enable/disable operations
From: Ajit Khaparde This patch adds the promiscuous mode enable and disable dev_ops. Uses the bnxt_hwrm_cfa_l2_set_rx_mask() API added in the earlier patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix couple of typos in the commit message. v5: Reorder footer Rewrite the patch description. --- drivers/net/bnxt/bnxt_ethdev.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index ac82876..3fce540 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -437,6 +437,34 @@ out: return rc; } +static void bnxt_promiscuous_enable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags |= BNXT_VNIC_INFO_PROMISC; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + +static void bnxt_promiscuous_disable_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic; + + if (bp->vnic_info == NULL) + return; + + vnic = &bp->vnic_info[0]; + + vnic->flags &= ~BNXT_VNIC_INFO_PROMISC; + bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + /* * Initialization */ @@ -454,6 +482,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .tx_queue_setup = bnxt_tx_queue_setup_op, .tx_queue_release = bnxt_tx_queue_release_op, .link_update = bnxt_link_update_op, + .promiscuous_enable = bnxt_promiscuous_enable_op, + .promiscuous_disable = bnxt_promiscuous_disable_op, }; static bool bnxt_vf_pciid(uint16_t id) -- 1.9.1
[dpdk-dev] [PATCH v6 35/38] bnxt: add set link up/down operations
From: Ajit Khaparde Adds dev_ops to set link UP or DOWN as appropriate. Uses the bnxt_set_hwrm_link_config() API added in previous patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 20 1 file changed, 20 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 34a5873..b04010c 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -380,6 +380,24 @@ error: return rc; } +static int bnxt_dev_set_link_up_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + + eth_dev->data->dev_link.link_status = 1; + bnxt_set_hwrm_link_config(bp, true); + return 0; +} + +static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + + eth_dev->data->dev_link.link_status = 0; + bnxt_set_hwrm_link_config(bp, false); + return 0; +} + static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) { struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; @@ -574,6 +592,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .dev_configure = bnxt_dev_configure_op, .dev_start = bnxt_dev_start_op, .dev_stop = bnxt_dev_stop_op, + .dev_set_link_up = bnxt_dev_set_link_up_op, + .dev_set_link_down = bnxt_dev_set_link_down_op, .stats_get = bnxt_stats_get_op, .stats_reset = bnxt_stats_reset_op, .rx_queue_setup = bnxt_rx_queue_setup_op, -- 1.9.1
[dpdk-dev] [PATCH v6 02/38] bnxt: add HWRM init code
From: Ajit Khaparde Start adding support to use the HWRM API. Hardware Resource Manager or HWRM in short, is a set of API provided by the firmware running in the ASIC to manage the various resources. Initial commit just performs necessary HWRM queries for init, then fails as before. Now that struct bnxt is non-zero size, we can set dev_private_size correctly. The used HWRM calls so far: bnxt_hwrm_func_qcaps: This command returns capabilities of a function. bnxt_hwrm_ver_get: This function is called by a driver to determine the HWRM interface version supported by the HWRM firmware, the version of HWRM firmware implementation, the name of HWRM firmware, the versions of other embedded firmwares, and the names of other embedded firmwares, etc. Gets the firmware version and interface specifications. Returns an error if the firmware on the device is not supported by the driver and ensures the response space is large enough for the largest possible response. bnxt_hwrm_queue_qportcfg: This function is called by a driver to query queue configuration of a port. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix few issues highlighted by checkpatch. v5: Fix footer formatting Switch to using the HWRM function descriptions from the source documentation --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 114 drivers/net/bnxt/bnxt_ethdev.c | 111 +++- drivers/net/bnxt/bnxt_hwrm.c | 324 +++ drivers/net/bnxt/bnxt_hwrm.h | 53 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 954 + 6 files changed, 1555 insertions(+), 2 deletions(-) create mode 100644 drivers/net/bnxt/bnxt.h create mode 100644 drivers/net/bnxt/bnxt_hwrm.c create mode 100644 drivers/net/bnxt/bnxt_hwrm.h create mode 100644 drivers/net/bnxt/hsi_struct_def_dpdk.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index f6333fd..9965597 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -49,6 +49,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c # # Export include files diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h new file mode 100644 index 000..8cb7f5b --- /dev/null +++ b/drivers/net/bnxt/bnxt.h @@ -0,0 +1,114 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _BNXT_H_ +#define _BNXT_H_ + +#include +#include + +#include +#include +#include +#include + +struct bnxt_vf_info { + uint16_tfw_fid; + uint8_t mac_addr[ETHER_ADDR_LEN]; + uint16_tmax_rsscos_ctx; + uint16_tmax_cp_rings; + uint16_tmax_tx_rings; + uint16_tmax_rx_rings; + uint16_tmax_l2_ctx; + uint16_tmax_vnics; + struct bnxt_pf_info *pf; +}; + +struct bnxt_pf_info { +#define BNXT_FIRST_PF_FID 1 +#define BNXT_MAX_VFS(bp) (bp->pf.max_vfs) +#define BNXT_FIRST_VF_FID 128 +#define BNXT_PF_
[dpdk-dev] [PATCH v6 08/38] bnxt: add completion ring support
From: Ajit Khaparde Structures, macros, and functions for working with completion rings in the driver. Completion Ring is used by the Ethernet controller to provide the status of transmitted & received packets, report errors, report status changes to the host software, and inter-function forwarding requests. In addition to the generic ring features, a completion ring can have a statistics context that has statistics periodically DMAed to host memory, along with a consumer index. bnxt_handle_async_event() handles completions not related to a specific transmit or receive ring such as link status changes which arrive on the default completion ring. Other physical or virtual functions on the same device may send an HWRM command forward request. In this case, we will pass it through unvalidated. In the future, we will be able to have the PF monitor and control VF access to the HWRM interface if needed. New HWRM Calls: bnxt_hwrm_exec_fwd_resp: Execute an encapsulated command and forward the response. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Reorder footer Expand patch description --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 5 + drivers/net/bnxt/bnxt_cpr.c| 140 drivers/net/bnxt/bnxt_cpr.h| 88 + drivers/net/bnxt/bnxt_hwrm.c | 18 +++ drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 227 + 7 files changed, 481 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_cpr.c create mode 100644 drivers/net/bnxt/bnxt_cpr.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 757ea62..afd1690 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -48,6 +48,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # # all source are stored in SRCS-y # +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_cpr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index d0f84f4..bdd355f 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -42,6 +42,8 @@ #include #include +#include "bnxt_cpr.h" + #define BNXT_MAX_MTU 9000 #define VLAN_TAG_SIZE 4 @@ -137,6 +139,9 @@ struct bnxt { unsigned inttx_cp_nr_rings; struct bnxt_tx_queue **tx_queues; + /* Default completion ring */ + struct bnxt_cp_ring_info*def_cp_ring; + struct bnxt_vnic_info *vnic_info; STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c new file mode 100644 index 000..7de2b9c --- /dev/null +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -0,0 +1,140 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bnxt.h" +#include "bnxt_cpr.h" +#include "bnxt_hwrm.h" +#include "bnxt_ring.h" + +/* + * Async event handling + */ +void bnxt_handle_async_event(struct bnxt *bp __rte_unused, +
[dpdk-dev] [PATCH v6 21/38] bnxt: add HWRM API to configure RSS
From: Ajit Khaparde A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. New HWRM call: bnxt_hwrm_vnic_rss_cfg: Used to enable RSS configuration of the VNIC. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Expand the commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 24 drivers/net/bnxt/bnxt_hwrm.h | 2 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h | 1 + 3 files changed, 27 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 5a5063f..29b0729 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -646,6 +646,30 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, + struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_rss_cfg_input req = {.req_type = 0 }; + struct hwrm_vnic_rss_cfg_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, VNIC_RSS_CFG, -1, resp); + + req.hash_type = rte_cpu_to_le_32(vnic->hash_type); + + req.ring_grp_tbl_addr = + rte_cpu_to_le_64(vnic->rss_table_dma_addr); + req.hash_key_tbl_addr = + rte_cpu_to_le_64(vnic->rss_hash_key_dma_addr); + req.rss_ctx_idx = rte_cpu_to_le_16(vnic->fw_rss_cos_lb_ctx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + return rc; +} + /* * HWRM utility functions */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index fbb8aba..8c7b939 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -68,6 +68,8 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); +int bnxt_hwrm_vnic_rss_cfg(struct bnxt *bp, + struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); void bnxt_free_hwrm_resources(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 6412df2..72d4984 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -92,6 +92,7 @@ struct ctx_hw_stats64 { #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) #define HWRM_VNIC_FREE (UINT32_C(0x41)) #define HWRM_VNIC_CFG (UINT32_C(0x42)) +#define HWRM_VNIC_RSS_CFG (UINT32_C(0x46)) #define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC (UINT32_C(0x70)) #define HWRM_VNIC_RSS_COS_LB_CTX_FREE (UINT32_C(0x71)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) -- 1.9.1
[dpdk-dev] [PATCH v6 14/38] bnxt: add initial Rx code implementation
From: Ajit Khaparde This patch adds initial implementation of rx_pkt_burst() function for Rx. bnxt_recv_pkts() is the top level function for doing Rx. This patch also adds code to allocate rings in the ASIC. For each Rx queue allocated in the PMD driver, a corresponding ring in hardware will be created. Every time a frame is received a Rx ring is selected based on the hardware configuration like RSS, MAC or VLAN, COS and such. The hardware uses a completion ring to indicate the availability of a packet. This patch also brings in functions like bnxt_init_one_rx_ring() bnxt_init_rx_ring_struct() which initializes various structures before a Rx can begin. bnxt_init_rxbds() initializes the Rx Buffer Descriptors while bnxt_alloc_rx_data() allocates a buffer in the host to receive the incoming packet. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Use rte_mbuf_raw_alloc instead of the now depricated __rte_mbuf_raw_alloc and fix issues pointed out by checkpatch. v5: Expand the patch description Reorder footer v6: Correct typos --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt_ethdev.c | 3 +- drivers/net/bnxt/bnxt_ring.c | 61 ++--- drivers/net/bnxt/bnxt_rxq.c| 34 ++- drivers/net/bnxt/bnxt_rxr.c| 341 drivers/net/bnxt/bnxt_rxr.h| 62 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 474 + 7 files changed, 936 insertions(+), 40 deletions(-) create mode 100644 drivers/net/bnxt/bnxt_rxr.c create mode 100644 drivers/net/bnxt/bnxt_rxr.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index 0785681..4d35412 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxq.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_rxr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_stats.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txq.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_txr.c diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4ace543..6888363 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -42,6 +42,7 @@ #include "bnxt.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_rxr.h" #include "bnxt_stats.h" #include "bnxt_txq.h" #include "bnxt_txr.h" @@ -269,7 +270,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev) goto error; } eth_dev->dev_ops = &bnxt_dev_ops; - /* eth_dev->rx_pkt_burst = &bnxt_recv_pkts; */ + eth_dev->rx_pkt_burst = &bnxt_recv_pkts; eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; rc = bnxt_alloc_hwrm_resources(bp); diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index 2645dda..f547a9e 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -36,6 +36,7 @@ #include "bnxt.h" #include "bnxt_cpr.h" #include "bnxt_ring.h" +#include "bnxt_rxr.h" #include "bnxt_txr.h" #include "hsi_struct_def_dpdk.h" @@ -74,8 +75,7 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, { struct bnxt_ring *cp_ring = cp_ring_info->cp_ring_struct; struct bnxt_ring *tx_ring; - /* TODO: RX ring */ - /* struct bnxt_ring *rx_ring; */ + struct bnxt_ring *rx_ring; struct rte_pci_device *pdev = bp->pdev; const struct rte_memzone *mz = NULL; char mz_name[RTE_MEMZONE_NAMESIZE]; @@ -92,12 +92,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, tx_ring_struct->vmem_size) : 0; int rx_vmem_start = tx_vmem_start + tx_vmem_len; - /* TODO: RX ring */ - int rx_vmem_len = 0; - /* -* rx_ring_info ? RTE_CACHE_LINE_ROUNDUP(rx_ring_info-> -* rx_ring_struct->vmem_size) : 0; -*/ + int rx_vmem_len = rx_ring_info ? + RTE_CACHE_LINE_ROUNDUP(rx_ring_info-> + rx_ring_struct->vmem_size) : 0; int cp_ring_start = rx_vmem_start + rx_vmem_len; int cp_ring_len = RTE_CACHE_LINE_ROUNDUP(cp_ring->ring_size * @@ -109,13 +106,9 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, sizeof(struct tx_bd_long)) : 0; int rx_ring_start = tx_ring_start + tx_ring_len; - /* TODO: RX ring */ - int rx_ring_len = 0; - /* -* rx_ring_info ? -* RTE_CACHE_LINE_ROUNDUP(rx_ring_info->rx_ring_struct->ring_size * -* sizeof(struct rx_prod_pkt_bd)) :
[dpdk-dev] [PATCH v6 18/38] bnxt: add HWRM vnic free function
From: Ajit Khaparde In this patch we add a new HWRM API to free a VNIC. A VNIC represents a virtual interface. It is a resource in the RX path of the chip and is used to setup various target actions such as RSS, MAC filtering etc.. for the physical function in use. New HWRM call: bnxt_hwrm_vnic_free: Frees a vnic allocated by the bnxt_hwrm_vnic_alloc() function. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Add more description in commit log Reorder footer --- drivers/net/bnxt/bnxt_hwrm.c | 21 + drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 82 ++ 3 files changed, 104 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index fb0b7bf..fbbb81d 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -553,6 +553,27 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic) return rc; } +int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic) +{ + int rc = 0; + struct hwrm_vnic_free_input req = {.req_type = 0 }; + struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr; + + if (vnic->fw_vnic_id == INVALID_HW_RING_ID) + return rc; + + HWRM_PREP(req, VNIC_FREE, -1, resp); + + req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + HWRM_CHECK_RESULT; + + vnic->fw_vnic_id = INVALID_HW_RING_ID; + return rc; +} + /* * HWRM utility functions */ diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 7d09773..93fb759 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -63,6 +63,7 @@ int bnxt_hwrm_stat_clear(struct bnxt *bp, struct bnxt_cp_ring_info *cpr); int bnxt_hwrm_ver_get(struct bnxt *bp); +int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_clear_all_hwrm_stat_ctxs(struct bnxt *bp); diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index eedd368..0771897 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -90,6 +90,7 @@ struct ctx_hw_stats64 { #define HWRM_PORT_PHY_CFG (UINT32_C(0x20)) #define HWRM_QUEUE_QPORTCFG(UINT32_C(0x30)) #define HWRM_VNIC_ALLOC(UINT32_C(0x40)) +#define HWRM_VNIC_FREE (UINT32_C(0x41)) #define HWRM_CFA_L2_FILTER_ALLOC (UINT32_C(0x90)) #define HWRM_CFA_L2_FILTER_FREE(UINT32_C(0x91)) #define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92)) @@ -3218,6 +3219,87 @@ struct hwrm_vnic_alloc_output { uint8_t valid; } __attribute__((packed)); +/* hwrm_vnic_free */ +/* + * Description: Free a VNIC resource. Idle any resources associated with the + * VNIC as well as the VNIC. Reset and release all resources associated with the + * VNIC. + */ + +/* Input (24 bytes) */ +struct hwrm_vnic_free_input { + /* +* This value indicates what type of request this is. The format for the +* rest of the command is determined by this field. +*/ + uint16_t req_type; + + /* +* This value indicates the what completion ring the request will be +* optionally completed on. If the value is -1, then no CR completion +* will be generated. Any other value must be a valid CR ring_id value +* for this function. +*/ + uint16_t cmpl_ring; + + /* This value indicates the command sequence number. */ + uint16_t seq_id; + + /* +* Target ID of this command. 0x0 - 0xFFF8 - Used for function ids +* 0xFFF8 - 0xFFFE - Reserved for internal processors 0x - HWRM +*/ + uint16_t target_id; + + /* +* This is the host address where the response will be written when the +* request is complete. This area must be 16B aligned and must be +* cleared to zero before the request is made. +*/ + uint64_t resp_addr; + + /* Logical vnic ID */ + uint32_t vnic_id; + + uint32_t unused_0; +} __attribute__((packed)); + +/* Output (16 bytes) */ +struct hwrm_vnic_free_output { + /* +* Pass/Fail or error type Note: receiver to verify the in parameters, +* and fail the call with an error when appropriate +*/ + uint16_t error_code; + + /* This field returns the type of original request. */ + uint16_t req_type; + + /* This field provides original sequence number of the command. */ + uint16_t seq_id; + + /* +* This field is the length of the response in bytes. The last byte of +* the response is a valid flag that will read as
[dpdk-dev] [PATCH v6 09/38] bnxt: add L2 filter alloc/init/free
From: Ajit Khaparde Add the L2 filter structure and the alloc/init/free functions for dealing with them. A filter is used to identify traffic that contains a matching set of parameters like unicast or broadcast MAC address or a VLAN tag amongst other things which then allows the ASIC to direct the incoming traffic to an appropriate VNIC or Rx ring. New HWRM calls: bnxt_hwrm_clear_filter: Free a L2 filter. bnxt_hwrm_set_filter Allocate an An L2 filter or a L2 context. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments and fix issues pointed out by checkpatch. v5: Move bnxt_hwrm_set_filter() into this patch Add short descriptions of new HWRM calls Reorder footer --- drivers/net/bnxt/Makefile | 1 + drivers/net/bnxt/bnxt.h| 3 + drivers/net/bnxt/bnxt_filter.c | 175 + drivers/net/bnxt/bnxt_filter.h | 74 ++ drivers/net/bnxt/bnxt_hwrm.c | 65 + drivers/net/bnxt/bnxt_hwrm.h | 6 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 456 + 7 files changed, 780 insertions(+) create mode 100644 drivers/net/bnxt/bnxt_filter.c create mode 100644 drivers/net/bnxt/bnxt_filter.h diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile index afd1690..b7834b1 100644 --- a/drivers/net/bnxt/Makefile +++ b/drivers/net/bnxt/Makefile @@ -50,6 +50,7 @@ EXPORT_MAP := rte_pmd_bnxt_version.map # SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_cpr.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_filter.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_hwrm.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_ring.c SRCS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt_vnic.c diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index bdd355f..49aa38b 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -145,6 +145,9 @@ struct bnxt { struct bnxt_vnic_info *vnic_info; STAILQ_HEAD(, bnxt_vnic_info) free_vnic_list; + struct bnxt_filter_info *filter_info; + STAILQ_HEAD(, bnxt_filter_info) free_filter_list; + /* VNIC pointer for flow filter (VMDq) pools */ #define MAX_FF_POOLS ETH_64_POOLS STAILQ_HEAD(, bnxt_vnic_info) ff_pool[MAX_FF_POOLS]; diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c new file mode 100644 index 000..f03a1dc --- /dev/null +++ b/drivers/net/bnxt/bnxt_filter.c @@ -0,0 +1,175 @@ +/*- + * BSD LICENSE + * + * Copyright(c) Broadcom Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Broadcom Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include + +#include "bnxt.h" +#include "bnxt_filter.h" +#include "bnxt_hwrm.h" +#include "bnxt_vnic.h" +#include "hsi_struct_def_dpdk.h" + +/* + * Filter Functions + */ + +struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp) +{ + struct bnxt_filter_info *filter; + + /* Find the 1st unused filter from the free_filter_list pool*/ + filter = STAILQ_FIRST(&bp->free_filter_list); + if (!filter) { + RTE_LOG(ERR, PMD, "No more free filter resources\n"); + return NULL; + } + STAILQ_REMOVE_HEAD(&bp->free_filter_list, next); + + /* Default to L2 MAC
[dpdk-dev] [PATCH v6 28/38] bnxt: allocate and free all HWRM rings and groups
From: Ajit Khaparde Add a top level functions to initialize ring groups, and functions to allocate and free all the rings via HWRM. A ring group is identified by an index. It consists of Rx or Tx ring id, completion ring id and a statistics context. Once a ring group is initialized, use this group index while creating the rings in the ASIC using the appropriate HWRM API added via earlier patches. Functions added: bnxt_free_cp_ring Calls the HWRM function generic ring free with arguments specific to a completion ring and sanitizes the host completion structure bnxt_free_all_hwrm_rings Frees all the HWRM allocated hardware rings bnxt_free_all_hwrm_resources Frees all the resources allocated via the HRM in the hardware bnxt_alloc_hwrm_rings Allocates all the HWRM rings needed in the current configuration This should be the last functionality needed to add start/stop device operations. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comment to merge another patch into this to avoid a compilation issue. Fix issues pointed out by checkpatch. v5: Reorder the footer. Remove instances of bnxt_ring_struct v6: Correct typos --- drivers/net/bnxt/bnxt_hwrm.c | 112 +++- drivers/net/bnxt/bnxt_hwrm.h | 1 + drivers/net/bnxt/bnxt_ring.c | 119 +++ drivers/net/bnxt/bnxt_ring.h | 2 + 4 files changed, 233 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 13f9e1c..fcc4811 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -43,8 +43,10 @@ #include "bnxt_filter.h" #include "bnxt_hwrm.h" #include "bnxt_rxq.h" +#include "bnxt_rxr.h" #include "bnxt_ring.h" #include "bnxt_txq.h" +#include "bnxt_txr.h" #include "bnxt_vnic.h" #include "hsi_struct_def_dpdk.h" @@ -579,7 +581,11 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp, break; case HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL: req.ring_type = ring_type; - req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_POLL; + /* +* TODO: Some HWRM versions crash with +* HWRM_RING_ALLOC_INPUT_INT_MODE_POLL +*/ + req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_MSIX; req.length = rte_cpu_to_le_32(ring->ring_size); break; default: @@ -1012,6 +1018,84 @@ int bnxt_free_all_hwrm_ring_grps(struct bnxt *bp) return rc; } +static void bnxt_free_cp_ring(struct bnxt *bp, + struct bnxt_cp_ring_info *cpr, unsigned int idx) +{ + struct bnxt_ring *cp_ring = cpr->cp_ring_struct; + + bnxt_hwrm_ring_free(bp, cp_ring, + HWRM_RING_FREE_INPUT_RING_TYPE_CMPL); + cp_ring->fw_ring_id = INVALID_HW_RING_ID; + bp->grp_info[idx].cp_fw_ring_id = INVALID_HW_RING_ID; + memset(cpr->cp_desc_ring, 0, cpr->cp_ring_struct->ring_size * + sizeof(*cpr->cp_desc_ring)); + cpr->cp_raw_cons = 0; +} + +int bnxt_free_all_hwrm_rings(struct bnxt *bp) +{ + unsigned int i; + int rc = 0; + + for (i = 0; i < bp->tx_cp_nr_rings; i++) { + struct bnxt_tx_queue *txq = bp->tx_queues[i]; + struct bnxt_tx_ring_info *txr = txq->tx_ring; + struct bnxt_ring *ring = txr->tx_ring_struct; + struct bnxt_cp_ring_info *cpr = txq->cp_ring; + unsigned int idx = bp->rx_cp_nr_rings + i + 1; + + if (ring->fw_ring_id != INVALID_HW_RING_ID) { + bnxt_hwrm_ring_free(bp, ring, + HWRM_RING_FREE_INPUT_RING_TYPE_TX); + ring->fw_ring_id = INVALID_HW_RING_ID; + memset(txr->tx_desc_ring, 0, + txr->tx_ring_struct->ring_size * + sizeof(*txr->tx_desc_ring)); + memset(txr->tx_buf_ring, 0, + txr->tx_ring_struct->ring_size * + sizeof(*txr->tx_buf_ring)); + txr->tx_prod = 0; + txr->tx_cons = 0; + } + if (cpr->cp_ring_struct->fw_ring_id != INVALID_HW_RING_ID) + bnxt_free_cp_ring(bp, cpr, idx); + } + + for (i = 0; i < bp->rx_cp_nr_rings; i++) { + struct bnxt_rx_queue *rxq = bp->rx_queues[i]; + struct bnxt_rx_ring_info *rxr = rxq->rx_ring; + struct bnxt_ring *ring = rxr->rx_ring_struct; + struct bn
[dpdk-dev] [PATCH v6 24/38] bnxt: add HWRM ring alloc/free functions
From: Ajit Khaparde Add HWRM API calls to allocate and free TX, RX and Completion rings in the hardware along with the associated structs and definitions. This informs the hardware of how the specific rings were set up in the host and allocates them in the HWRM, setting up the doorbell registers etc. as needed, returning an ID for the ring. Basic ring alloc/free calls: bnxt_hwrm_ring_alloc This command allocates and does basic preparation for a ring. bnxt_hwrm_ring_free This command is used to free a ring and associated resources. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Address review comments. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_hwrm.c | 108 drivers/net/bnxt/bnxt_hwrm.h | 7 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 305 + 3 files changed, 420 insertions(+) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 420a1cc..565b76f 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -547,6 +547,114 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp) return rc; } +int bnxt_hwrm_ring_alloc(struct bnxt *bp, +struct bnxt_ring *ring, +uint32_t ring_type, uint32_t map_index, +uint32_t stats_ctx_id) +{ + int rc = 0; + struct hwrm_ring_alloc_input req = {.req_type = 0 }; + struct hwrm_ring_alloc_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_ALLOC, -1, resp); + + req.enables = rte_cpu_to_le_32(0); + + req.page_tbl_addr = rte_cpu_to_le_64(ring->bd_dma); + req.fbo = rte_cpu_to_le_32(0); + /* Association of ring index with doorbell index */ + req.logical_id = rte_cpu_to_le_16(map_index); + + switch (ring_type) { + case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX: + req.queue_id = bp->cos_queue[0].id; + case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX: + req.ring_type = ring_type; + req.cmpl_ring_id = + rte_cpu_to_le_16(bp->grp_info[map_index].cp_fw_ring_id); + req.length = rte_cpu_to_le_32(ring->ring_size); + req.stat_ctx_id = rte_cpu_to_le_16(stats_ctx_id); + req.enables = rte_cpu_to_le_32(rte_le_to_cpu_32(req.enables) | + HWRM_RING_ALLOC_INPUT_ENABLES_STAT_CTX_ID_VALID); + break; + case HWRM_RING_ALLOC_INPUT_RING_TYPE_CMPL: + req.ring_type = ring_type; + req.int_mode = HWRM_RING_ALLOC_INPUT_INT_MODE_POLL; + req.length = rte_cpu_to_le_32(ring->ring_size); + break; + default: + RTE_LOG(ERR, PMD, "hwrm alloc invalid ring type %d\n", + ring_type); + return -1; + } + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + if (rc || resp->error_code) { + if (rc == 0 && resp->error_code) + rc = rte_le_to_cpu_16(resp->error_code); + switch (ring_type) { + case HWRM_RING_FREE_INPUT_RING_TYPE_CMPL: + RTE_LOG(ERR, PMD, + "hwrm_ring_alloc cp failed. rc:%d\n", rc); + return rc; + case HWRM_RING_FREE_INPUT_RING_TYPE_RX: + RTE_LOG(ERR, PMD, + "hwrm_ring_alloc rx failed. rc:%d\n", rc); + return rc; + case HWRM_RING_FREE_INPUT_RING_TYPE_TX: + RTE_LOG(ERR, PMD, + "hwrm_ring_alloc tx failed. rc:%d\n", rc); + return rc; + default: + RTE_LOG(ERR, PMD, "Invalid ring. rc:%d\n", rc); + return rc; + } + } + + ring->fw_ring_id = rte_le_to_cpu_16(resp->ring_id); + return rc; +} + +int bnxt_hwrm_ring_free(struct bnxt *bp, + struct bnxt_ring *ring, uint32_t ring_type) +{ + int rc; + struct hwrm_ring_free_input req = {.req_type = 0 }; + struct hwrm_ring_free_output *resp = bp->hwrm_cmd_resp_addr; + + HWRM_PREP(req, RING_FREE, -1, resp); + + req.ring_type = ring_type; + req.ring_id = rte_cpu_to_le_16(ring->fw_ring_id); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req)); + + if (rc || resp->error_code) { + if (rc == 0 && resp->error_code) + rc = rte_le_to_cpu_16(resp->error_code); + + switch (ring_type) { + case HWRM_RING_FREE_INPUT_RING_TYPE_CMPL: + RTE_LOG(ERR, PMD, "hwrm_ring_free cp failed. rc:%d\n&q
[dpdk-dev] [PATCH v6 36/38] bnxt: add reta update/query operations
From: Ajit Khaparde Add code to Update/query reta dev_ops Uses the bnxt_hwrm_vnic_rss_cfg() HWRM API added earlier. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 56 ++ 1 file changed, 56 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b04010c..b3b76f1 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -582,6 +582,60 @@ static void bnxt_allmulticast_disable_op(struct rte_eth_dev *eth_dev) bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); } +static int bnxt_reta_update_op(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; + struct bnxt_vnic_info *vnic; + int i; + + if (!(dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)) + return -EINVAL; + + if (reta_size != HW_HASH_INDEX_SIZE) { + RTE_LOG(ERR, PMD, "The configured hash table lookup size " + "(%d) must equal the size supported by the hardware " + "(%d)\n", reta_size, HW_HASH_INDEX_SIZE); + return -EINVAL; + } + /* Update the RSS VNIC(s) */ + for (i = 0; i < MAX_FF_POOLS; i++) { + STAILQ_FOREACH(vnic, &bp->ff_pool[i], next) { + memcpy(vnic->rss_table, reta_conf, reta_size); + + bnxt_hwrm_vnic_rss_cfg(bp, vnic); + } + } + return 0; +} + +static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; + + /* Retrieve from the default VNIC */ + if (!vnic) + return -EINVAL; + if (!vnic->rss_table) + return -EINVAL; + + if (reta_size != HW_HASH_INDEX_SIZE) { + RTE_LOG(ERR, PMD, "The configured hash table lookup size " + "(%d) must equal the size supported by the hardware " + "(%d)\n", reta_size, HW_HASH_INDEX_SIZE); + return -EINVAL; + } + /* EW - need to revisit here copying from u64 to u16 */ + memcpy(reta_conf, vnic->rss_table, reta_size); + + return 0; +} + /* * Initialization */ @@ -600,6 +654,8 @@ static struct eth_dev_ops bnxt_dev_ops = { .rx_queue_release = bnxt_rx_queue_release_op, .tx_queue_setup = bnxt_tx_queue_setup_op, .tx_queue_release = bnxt_tx_queue_release_op, + .reta_update = bnxt_reta_update_op, + .reta_query = bnxt_reta_query_op, .link_update = bnxt_link_update_op, .promiscuous_enable = bnxt_promiscuous_enable_op, .promiscuous_disable = bnxt_promiscuous_disable_op, -- 1.9.1
[dpdk-dev] [PATCH v6 33/38] bnxt: free memory in close operation
From: Ajit Khaparde This patch adds code to free all resources except the one corresponding to HWRM, which are required to notify the HWRM that the driver is unloaded (these are freed in uninit()). Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v5: Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index d3a624f..4254531 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -62,14 +62,6 @@ static struct rte_pci_id bnxt_pci_id_map[] = { {.device_id = 0}, }; -static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) -{ - struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; - - rte_free(eth_dev->data->mac_addrs); - bnxt_free_hwrm_resources(bp); -} - /***/ /* @@ -388,6 +380,16 @@ error: return rc; } +static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + + bnxt_free_tx_mbufs(bp); + bnxt_free_rx_mbufs(bp); + bnxt_free_mem(bp); + rte_free(eth_dev->data->mac_addrs); +} + /* Unload the driver, release resources */ static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev) { -- 1.9.1
[dpdk-dev] [PATCH v6 30/38] bnxt: add start/stop/link update operations
From: Ajit Khaparde This patch adds code to add the start, stop and link update dev_ops. Also adds wrapper functions like bnxt_init_chip(), bnxt_init_nic(), bnxt_alloc_mem(), bnxt_free_mem() The BNXT driver will now minimally pass traffic with testpmd. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. Shorten the string passed for reserving memzone when default completion ring is created. v5: Reorder footer v6: Correct typos --- drivers/net/bnxt/bnxt_ethdev.c | 269 + 1 file changed, 269 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 6888363..ac82876 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -40,12 +40,17 @@ #include #include "bnxt.h" +#include "bnxt_cpr.h" +#include "bnxt_filter.h" #include "bnxt_hwrm.h" +#include "bnxt_ring.h" #include "bnxt_rxq.h" #include "bnxt_rxr.h" #include "bnxt_stats.h" #include "bnxt_txq.h" #include "bnxt_txr.h" +#include "bnxt_vnic.h" +#include "hsi_struct_def_dpdk.h" #define DRV_MODULE_NAME"bnxt" static const char bnxt_version[] = @@ -65,6 +70,177 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev) bnxt_free_hwrm_resources(bp); } +/***/ + +/* + * High level utility functions + */ + +static void bnxt_free_mem(struct bnxt *bp) +{ + bnxt_free_filter_mem(bp); + bnxt_free_vnic_attributes(bp); + bnxt_free_vnic_mem(bp); + + bnxt_free_stats(bp); + bnxt_free_tx_rings(bp); + bnxt_free_rx_rings(bp); + bnxt_free_def_cp_ring(bp); +} + +static int bnxt_alloc_mem(struct bnxt *bp) +{ + int rc; + + /* Default completion ring */ + rc = bnxt_init_def_ring_struct(bp, SOCKET_ID_ANY); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_rings(bp, 0, NULL, NULL, + bp->def_cp_ring, "def_cp"); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_vnic_mem(bp); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_vnic_attributes(bp); + if (rc) + goto alloc_mem_err; + + rc = bnxt_alloc_filter_mem(bp); + if (rc) + goto alloc_mem_err; + + return 0; + +alloc_mem_err: + bnxt_free_mem(bp); + return rc; +} + +static int bnxt_init_chip(struct bnxt *bp) +{ + unsigned int i, rss_idx, fw_idx; + int rc; + + rc = bnxt_alloc_all_hwrm_stat_ctxs(bp); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM stat ctx alloc failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_alloc_hwrm_rings(bp); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM ring alloc failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_alloc_all_hwrm_ring_grps(bp); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM ring grp alloc failure: %x\n", rc); + goto err_out; + } + + rc = bnxt_mq_rx_configure(bp); + if (rc) { + RTE_LOG(ERR, PMD, "MQ mode configure failure rc: %x\n", rc); + goto err_out; + } + + /* VNIC configuration */ + for (i = 0; i < bp->nr_vnics; i++) { + struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; + + rc = bnxt_hwrm_vnic_alloc(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM vnic alloc failure rc: %x\n", + rc); + goto err_out; + } + + rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, + "HWRM vnic ctx alloc failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_hwrm_vnic_cfg(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM vnic cfg failure rc: %x\n", rc); + goto err_out; + } + + rc = bnxt_set_hwrm_vnic_filters(bp, vnic); + if (rc) { + RTE_LOG(ERR, PMD, "HWRM vnic filter failure rc: %x\n", + rc); + goto err_out; + } + if (vnic->rss_table && vnic->hash_type) { + /* +* Fill the RSS hash & redirection table with +* ring group ids for all VNICs +*/ + for (rss_idx = 0, fw_idx = 0; +
[dpdk-dev] [PATCH v6 37/38] bnxt: add RSS device operations
From: Ajit Khaparde Add rss_hash_update and rss_hash_conf_get dev_ops Uses the bnxt_hwrm_vnic_rss_cfg() HWRM API added in the previous patch. Signed-off-by: Ajit Khaparde Signed-off-by: Stephen Hurd Reviewed-by: David Christensen -- v4: Fix issues pointed out by checkpatch. v5: Rewrite the patch description. Reorder the footer. --- drivers/net/bnxt/bnxt_ethdev.c | 121 + 1 file changed, 121 insertions(+) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b3b76f1..3c7f868 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -62,6 +62,14 @@ static struct rte_pci_id bnxt_pci_id_map[] = { {.device_id = 0}, }; +#define BNXT_ETH_RSS_SUPPORT ( \ + ETH_RSS_IPV4 | \ + ETH_RSS_NONFRAG_IPV4_TCP | \ + ETH_RSS_NONFRAG_IPV4_UDP | \ + ETH_RSS_IPV6 | \ + ETH_RSS_NONFRAG_IPV6_TCP | \ + ETH_RSS_NONFRAG_IPV6_UDP) + /***/ /* @@ -636,6 +644,117 @@ static int bnxt_reta_query_op(struct rte_eth_dev *eth_dev, return 0; } +static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; + struct bnxt_vnic_info *vnic; + uint16_t hash_type = 0; + int i; + + /* +* If RSS enablement were different than dev_configure, +* then return -EINVAL +*/ + if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) { + if (!rss_conf->rss_hf) + return -EINVAL; + } else { + if (rss_conf->rss_hf & BNXT_ETH_RSS_SUPPORT) + return -EINVAL; + } + if (rss_conf->rss_hf & ETH_RSS_IPV4) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_UDP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4; + if (rss_conf->rss_hf & ETH_RSS_IPV6) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV6; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV6; + if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_UDP) + hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV6; + + /* Update the RSS VNIC(s) */ + for (i = 0; i < MAX_FF_POOLS; i++) { + STAILQ_FOREACH(vnic, &bp->ff_pool[i], next) { + vnic->hash_type = hash_type; + + /* +* Use the supplied key if the key length is +* acceptable and the rss_key is not NULL +*/ + if (rss_conf->rss_key && + rss_conf->rss_key_len <= HW_HASH_KEY_SIZE) + memcpy(vnic->rss_hash_key, rss_conf->rss_key, + rss_conf->rss_key_len); + + bnxt_hwrm_vnic_rss_cfg(bp, vnic); + } + } + return 0; +} + +static int bnxt_rss_hash_conf_get_op(struct rte_eth_dev *eth_dev, +struct rte_eth_rss_conf *rss_conf) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; + int len; + uint32_t hash_types; + + /* RSS configuration is the same for all VNICs */ + if (vnic && vnic->rss_hash_key) { + if (rss_conf->rss_key) { + len = rss_conf->rss_key_len <= HW_HASH_KEY_SIZE ? + rss_conf->rss_key_len : HW_HASH_KEY_SIZE; + memcpy(rss_conf->rss_key, vnic->rss_hash_key, len); + } + + hash_types = vnic->hash_type; + rss_conf->rss_hf = 0; + if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4) { + rss_conf->rss_hf |= ETH_RSS_IPV4; + hash_types &= ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4; + } + if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4) { + rss_conf->rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP; + hash_types &= + ~HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_TCP_IPV4; + } + if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_UDP_IPV4) { + rss_co
[dpdk-dev] New driver (large patch) question.
I submitted a new driver on Friday, and it was rejected for being over 300k. The rejection email suggested contacing dev-owner at dpdk.org, which I did on Monday with no reply. What's the process to submit patches larger than the mailing list size limit? -- Stephen Hurd Principal Engineer - Software Development Broadcom Corporation 949-926-8039 stephen.hurd at broadcom.com
[dpdk-dev] New driver (large patch) question.
The bulk of the patch is the hardware interface header file. With all the comments, it weighs in around 800k. If I strip the comments, it's around 300k. If I both strip all the comments and remove all the currently unused structures, I can get the entire patch down just below 300k, but that makes it much harder for someone to do further development. I'm willing to do that though if it's what's preferred. The other large file (560k) is just a bunch of extra debug output that makes it easier to debug issues. It's normally not compiled, so it sounds like it's not wanted either. I'll submit without comments in the hardware interface file and take it from there. On Wed, Mar 2, 2016 at 8:24 AM, Stephen Hemminger < stephen at networkplumber.org> wrote: > On Wed, 02 Mar 2016 11:21:26 +0100 > Thomas Monjalon wrote: > > > Hi, > > > > 2016-03-01 19:56, Stephen Hurd: > > > I submitted a new driver on Friday, and it was rejected for being over > 300k. > > > > > > The rejection email suggested contacing dev-owner at dpdk.org, which I > did on > > > Monday with no reply. > > > > > > What's the process to submit patches larger than the mailing list size > > > limit? > > > > A patch has two lives: > > 1/ it must be reviewed and accepted > > 2/ it will stay in the git history for future reference > > > > Those 2 periods require the patch to be well explained, with a > > reasonnable scope and a human readable size. > > The primary rule to think about is to introduce only one feature > > per patch. > > So the size should be naturally small and the mailing list don't need > > to accept greater sizes. > > > > To make it short, please split your driver in several introduction steps. > > > > Too many of the DPDK drivers are bloated. > Recall the venerable paraphrase of Pascal, "I made this so long because I > did not have time to make it shorter." > https://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn%27t_read > > Linux went through similar stages. Many drivers ended up being rewritten > for brevity (e1000, skge, tg3). Vendor drivers seem to want to engage all > features > even if they have no value. > -- Stephen Hurd Principal Engineer - Software Development Broadcom Corporation 949-926-8039 stephen.hurd at broadcom.com
[dpdk-dev] [PATCH] drivers/net/bnxt New driver for Broadcom bnxt
Initial new driver for Broadcom bnxt (Cumulus) devices. - Adds drivers/net/bnxt and the librte_pmd_bnxt - Adds bnxt PCI IDs - Adds support for 2/2.5/25/50Gbps modes to rte_ethdev.h Signed-off-by: Stephen Hurd --- MAINTAINERS |4 + config/common_bsdapp|5 + config/common_linuxapp |5 + drivers/net/Makefile|1 + drivers/net/bnxt/Makefile | 79 + drivers/net/bnxt/bnxt.h | 217 +++ drivers/net/bnxt/bnxt_cpr.c | 138 ++ drivers/net/bnxt/bnxt_cpr.h | 117 ++ drivers/net/bnxt/bnxt_ethdev.c | 1434 + drivers/net/bnxt/bnxt_filter.c | 175 +++ drivers/net/bnxt/bnxt_filter.h | 74 + drivers/net/bnxt/bnxt_hwrm.c| 1536 +++ drivers/net/bnxt/bnxt_hwrm.h| 103 ++ drivers/net/bnxt/bnxt_irq.c | 155 ++ drivers/net/bnxt/bnxt_irq.h | 51 + drivers/net/bnxt/bnxt_ring.c| 305 drivers/net/bnxt/bnxt_ring.h| 104 ++ drivers/net/bnxt/bnxt_rxq.c | 384 + drivers/net/bnxt/bnxt_rxq.h | 77 + drivers/net/bnxt/bnxt_rxr.c | 370 + drivers/net/bnxt/bnxt_rxr.h | 73 + drivers/net/bnxt/bnxt_stats.c | 222 +++ drivers/net/bnxt/bnxt_stats.h | 44 + drivers/net/bnxt/bnxt_txq.c | 165 ++ drivers/net/bnxt/bnxt_txq.h | 81 + drivers/net/bnxt/bnxt_txr.c | 316 drivers/net/bnxt/bnxt_txr.h | 71 + drivers/net/bnxt/bnxt_vnic.c| 284 drivers/net/bnxt/bnxt_vnic.h| 79 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 1869 +++ drivers/net/bnxt/rte_pmd_bnxt_version.map |4 + lib/librte_eal/common/include/rte_pci_dev_ids.h | 45 +- lib/librte_ether/rte_ethdev.h |4 + mk/rte.app.mk |1 + 34 files changed, 8587 insertions(+), 5 deletions(-) create mode 100644 drivers/net/bnxt/Makefile create mode 100644 drivers/net/bnxt/bnxt.h create mode 100644 drivers/net/bnxt/bnxt_cpr.c create mode 100644 drivers/net/bnxt/bnxt_cpr.h create mode 100644 drivers/net/bnxt/bnxt_ethdev.c create mode 100644 drivers/net/bnxt/bnxt_filter.c create mode 100644 drivers/net/bnxt/bnxt_filter.h create mode 100644 drivers/net/bnxt/bnxt_hwrm.c create mode 100644 drivers/net/bnxt/bnxt_hwrm.h create mode 100644 drivers/net/bnxt/bnxt_irq.c create mode 100644 drivers/net/bnxt/bnxt_irq.h create mode 100644 drivers/net/bnxt/bnxt_ring.c create mode 100644 drivers/net/bnxt/bnxt_ring.h create mode 100644 drivers/net/bnxt/bnxt_rxq.c create mode 100644 drivers/net/bnxt/bnxt_rxq.h create mode 100644 drivers/net/bnxt/bnxt_rxr.c create mode 100644 drivers/net/bnxt/bnxt_rxr.h create mode 100644 drivers/net/bnxt/bnxt_stats.c create mode 100644 drivers/net/bnxt/bnxt_stats.h create mode 100644 drivers/net/bnxt/bnxt_txq.c create mode 100644 drivers/net/bnxt/bnxt_txq.h create mode 100644 drivers/net/bnxt/bnxt_txr.c create mode 100644 drivers/net/bnxt/bnxt_txr.h create mode 100644 drivers/net/bnxt/bnxt_vnic.c create mode 100644 drivers/net/bnxt/bnxt_vnic.h create mode 100644 drivers/net/bnxt/hsi_struct_def_dpdk.h create mode 100644 drivers/net/bnxt/rte_pmd_bnxt_version.map diff --git a/MAINTAINERS b/MAINTAINERS index 628bc05..6ee6c3c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -359,6 +359,10 @@ F: drivers/crypto/aesni_mb/ Intel QuickAssist F: drivers/crypto/qat/ +Broadcom bnxt +M: Stephen Hurd +F: drivers/net/bnxt/ + Packet processing - diff --git a/config/common_bsdapp b/config/common_bsdapp index 696382c..f37c7bb 100644 --- a/config/common_bsdapp +++ b/config/common_bsdapp @@ -276,6 +276,11 @@ CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n # +# Compile burst-oriented BNXT PMD driver +# +CONFIG_RTE_LIBRTE_BNXT_PMD=y + +# # Compile example software rings based PMD # CONFIG_RTE_LIBRTE_PMD_RING=y diff --git a/config/common_linuxapp b/config/common_linuxapp index f1638db..35f544b 100644 --- a/config/common_linuxapp +++ b/config/common_linuxapp @@ -280,6 +280,11 @@ CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n # +# Compile burst-oriented BNXT PMD driver +# +CONFIG_RTE_LIBRTE_BNXT_PMD=y + +# # Compile example software rings based PMD # CONFIG_RTE_LIBRTE_PMD_RING=y diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 6e4497e..6f0d64b 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k DIRS
[dpdk-dev] New driver (large patch) question.
The issue is that the big header in question is the whole hardware/firmware interface definition. The comments in it are the only publicly available documentation on the hardware I'm aware of. The driver itself doesn't have a lot of optional features in it, it's the header file that's too big. On Wed, Mar 2, 2016 at 1:54 PM, Thomas Monjalon wrote: > 2016-03-02 13:30, Stephen Hurd: > > The bulk of the patch is the hardware interface header file. With all > the > > comments, it weighs in around 800k. If I strip the comments, it's around > > 300k. If I both strip all the comments and remove all the currently > unused > > structures, I can get the entire patch down just below 300k, but that > makes > > it much harder for someone to do further development. I'm willing to do > > that though if it's what's preferred. > > > > The other large file (560k) is just a bunch of extra debug output that > > makes it easier to debug issues. It's normally not compiled, so it > sounds > > like it's not wanted either. > > If the code is not needed, it's obviously better to not submit it :) > > > I'll submit without comments in the hardware interface file and take it > > from there. > > I don't think removing the comments is a good option. > Please try to split per-feature to make it readable. > You can check how fm10k was introduced as an example: > http://thread.gmane.org/gmane.comp.networking.dpdk.devel/13447 > or mlx5: > http://thread.gmane.org/gmane.comp.networking.dpdk.devel/26986 > -- Stephen Hurd Principal Engineer - Software Development Broadcom Corporation 949-926-8039 stephen.hurd at broadcom.com
[dpdk-dev] New driver (large patch) question.
On Wed, Mar 2, 2016 at 2:15 PM, Thomas Monjalon wrote: > > The comments in it are the only publicly available > > documentation on the hardware I'm aware of. > > So you must keep the comments. > That's my goal, but the comments are well over the 300k limit. > > The driver itself doesn't have a lot of optional features in it, it's the > > header file that's too big. > > It is big because there are many different things. > You can split the file in different patches. > Examples: > - a patch for RSS will bring the hardware structures for RSS > - a patch for the stats will bring the hardware stats structures > etc > Should I split additional definitions/documentation that's not currently used in the driver as well? Or should it stay as only enough to document what the driver already does? The header file is expected to be publicly released in the future, so I tried to keep it as close to the original as possible. I'm not strongly attached to this approach, but it does make it easier to support future firmware releases. It's a fairly work-intensive project to deconstruct the existing driver into a series of small patches that work at each step, is this a hard requirement? (if so, I'd better get cracking) PS: please answer inline > Sorry, $work just switched us to GMail and I'm still learning the ropes.
[dpdk-dev] New driver (large patch) question.
On Wed, Mar 2, 2016 at 4:29 PM, Thomas Monjalon wrote: > > Should I split additional definitions/documentation that's not currently > > used in the driver as well? Or should it stay as only enough to document > > what the driver already does? > > I don't understand the question. > If something is not used, it should not been there. > Basically, since the header is the only current public documentation on the hardware, if someone without access to the whole header was interested in adding features to the driver, they wouldn't have the documentation to allow them to do so. I understand that a header file in DPDK is not the right way for Broadcom to release documentation on their hardware and firmware, but I was thinking it would be better than nothing. Further, as mentioned in another email, this header file is mechanically derived from one that is planned to be released separately, so it would be a slightly lower support burden to use the mechanically derived one rather than manually importing changes. No problems slimming it down though. > > It's a fairly work-intensive project to deconstruct the existing driver > > into a series of small patches that work at each step, is this a hard > > requirement? (if so, I'd better get cracking) > > There is no hard requirement. I'm just giving you some advices to get > some reviewers and make them confident when accepting your patches. > By the way, you would get more attention by introducing the device with > some web links and performance numbers in the cover letter. > It is also appreciated to provide a documentation in doc/guides/nics/. > You could also fill the (new) table in overview.rst. > Thanks for the pointers, I'll try to get as many of the suggestions done as possible and talk to marketing to find web resources for the device and its performance. -- Stephen Hurd Principal Engineer - Software Development Broadcom Corporation 949-926-8039 stephen.hurd at broadcom.com
[dpdk-dev] [PATCH 1/7] lib/librte_ether: Add 2/2.5/25/50Gbps link speeds
Add additional ETH_LINK_SPEED_* macros for 2, 2.5, 25, and 50 Gbps links Signed-off-by: Stephen Hurd --- lib/librte_ether/rte_ethdev.h | 4 1 file changed, 4 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 16da821..cb40bbb 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -254,10 +254,14 @@ struct rte_eth_link { #define ETH_LINK_SPEED_10 10 /**< 10 megabits/second. */ #define ETH_LINK_SPEED_100 100 /**< 100 megabits/second. */ #define ETH_LINK_SPEED_1000 1000/**< 1 gigabits/second. */ +#define ETH_LINK_SPEED_2000 2000/**< 2 gigabits/second. */ +#define ETH_LINK_SPEED_2500 2500/**< 2.5 gigabits/second. */ #define ETH_LINK_SPEED_11 /**< 10 gigabits/second. */ #define ETH_LINK_SPEED_10G 1 /**< alias of 10 gigabits/second. */ #define ETH_LINK_SPEED_20G 2 /**< 20 gigabits/second. */ +#define ETH_LINK_SPEED_25G 25000 /**< 25 gigabits/second. */ #define ETH_LINK_SPEED_40G 4 /**< 40 gigabits/second. */ +#define ETH_LINK_SPEED_50G 5 /**< 50 gigabits/second. */ #define ETH_LINK_AUTONEG_DUPLEX 0 /**< Auto-negotiate duplex. */ #define ETH_LINK_HALF_DUPLEX1 /**< Half-duplex connection. */ -- 1.9.1
[dpdk-dev] [PATCH 0/7] drivers/net/bnxt: new Broadcom bnxt driver
New driver for Broadcom NetXtreme-C family of controllers and cards capable of up to 50Gbps link with 30Mpps throughput. v2: * Split into multiple patches * Add nic guide * Add features in overview.rst Stephen Hurd (7): lib/librte_ether: Add 2/2.5/25/50Gbps link speeds lib/librte_eal: Add PCI IDs for Broadcom bnxt drivers/net/bnxt new driver for Broadcom bnxt maintainers: claim drivers/net/bnxt build: add bnxt PMD to build doc: Add bnxt to overview table doc: add guide for new bnxt driver MAINTAINERS |4 + config/common_bsdapp|5 + config/common_linuxapp |5 + doc/guides/nics/bnxt.rst| 49 + doc/guides/nics/overview.rst| 64 +- drivers/net/Makefile|1 + drivers/net/bnxt/Makefile | 79 + drivers/net/bnxt/bnxt.h | 217 +++ drivers/net/bnxt/bnxt_cpr.c | 138 ++ drivers/net/bnxt/bnxt_cpr.h | 117 ++ drivers/net/bnxt/bnxt_ethdev.c | 1381 + drivers/net/bnxt/bnxt_filter.c | 175 +++ drivers/net/bnxt/bnxt_filter.h | 74 + drivers/net/bnxt/bnxt_hwrm.c| 1554 +++ drivers/net/bnxt/bnxt_hwrm.h| 105 ++ drivers/net/bnxt/bnxt_irq.c | 154 ++ drivers/net/bnxt/bnxt_irq.h | 51 + drivers/net/bnxt/bnxt_ring.c| 306 drivers/net/bnxt/bnxt_ring.h| 104 ++ drivers/net/bnxt/bnxt_rxq.c | 383 + drivers/net/bnxt/bnxt_rxq.h | 75 + drivers/net/bnxt/bnxt_rxr.c | 369 + drivers/net/bnxt/bnxt_rxr.h | 73 + drivers/net/bnxt/bnxt_stats.c | 190 +++ drivers/net/bnxt/bnxt_stats.h | 44 + drivers/net/bnxt/bnxt_txq.c | 164 ++ drivers/net/bnxt/bnxt_txq.h | 76 + drivers/net/bnxt/bnxt_txr.c | 326 drivers/net/bnxt/bnxt_txr.h | 71 + drivers/net/bnxt/bnxt_vnic.c| 285 drivers/net/bnxt/bnxt_vnic.h| 80 + drivers/net/bnxt/hsi_struct_def_dpdk.h | 1832 +++ drivers/net/bnxt/rte_pmd_bnxt_version.map |4 + lib/librte_eal/common/include/rte_pci_dev_ids.h | 45 +- lib/librte_ether/rte_ethdev.h |4 + mk/rte.app.mk |1 + 36 files changed, 8568 insertions(+), 37 deletions(-) create mode 100644 doc/guides/nics/bnxt.rst create mode 100644 drivers/net/bnxt/Makefile create mode 100644 drivers/net/bnxt/bnxt.h create mode 100644 drivers/net/bnxt/bnxt_cpr.c create mode 100644 drivers/net/bnxt/bnxt_cpr.h create mode 100644 drivers/net/bnxt/bnxt_ethdev.c create mode 100644 drivers/net/bnxt/bnxt_filter.c create mode 100644 drivers/net/bnxt/bnxt_filter.h create mode 100644 drivers/net/bnxt/bnxt_hwrm.c create mode 100644 drivers/net/bnxt/bnxt_hwrm.h create mode 100644 drivers/net/bnxt/bnxt_irq.c create mode 100644 drivers/net/bnxt/bnxt_irq.h create mode 100644 drivers/net/bnxt/bnxt_ring.c create mode 100644 drivers/net/bnxt/bnxt_ring.h create mode 100644 drivers/net/bnxt/bnxt_rxq.c create mode 100644 drivers/net/bnxt/bnxt_rxq.h create mode 100644 drivers/net/bnxt/bnxt_rxr.c create mode 100644 drivers/net/bnxt/bnxt_rxr.h create mode 100644 drivers/net/bnxt/bnxt_stats.c create mode 100644 drivers/net/bnxt/bnxt_stats.h create mode 100644 drivers/net/bnxt/bnxt_txq.c create mode 100644 drivers/net/bnxt/bnxt_txq.h create mode 100644 drivers/net/bnxt/bnxt_txr.c create mode 100644 drivers/net/bnxt/bnxt_txr.h create mode 100644 drivers/net/bnxt/bnxt_vnic.c create mode 100644 drivers/net/bnxt/bnxt_vnic.h create mode 100644 drivers/net/bnxt/hsi_struct_def_dpdk.h create mode 100644 drivers/net/bnxt/rte_pmd_bnxt_version.map -- 1.9.1
[dpdk-dev] [PATCH 2/7] lib/librte_eal: Add PCI IDs for Broadcom bnxt
Add Broadcom Vendor ID and RTE_PCI_DEV_ID_DECL_BNXT() macro. Add Device IDs for Broadcom bnxt devices. Signed-off-by: Stephen Hurd --- lib/librte_eal/common/include/rte_pci_dev_ids.h | 45 ++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h b/lib/librte_eal/common/include/rte_pci_dev_ids.h index d088191..9a8f254 100644 --- a/lib/librte_eal/common/include/rte_pci_dev_ids.h +++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h @@ -63,11 +63,11 @@ * This file contains a list of the PCI device IDs recognised by DPDK, which * can be used to fill out an array of structures describing the devices. * - * Currently four families of devices are recognised: those supported by the - * IGB driver, by EM driver, those supported by the IXGBE driver, and by virtio - * driver which is a para virtualization driver running in guest virtual machine. - * The inclusion of these in an array built using this file depends on the - * definition of + * Currently five families of devices are recognised: those supported by the + * IGB driver, by EM driver, those supported by the IXGBE driver, by BNXT + * driver, and by virtio driver which is a para virtualization driver running + * in guest virtual machine. The inclusion of these in an array built using + * this file depends on the definition of * RTE_PCI_DEV_ID_DECL_EM * RTE_PCI_DEV_ID_DECL_IGB * RTE_PCI_DEV_ID_DECL_IGBVF @@ -76,6 +76,7 @@ * RTE_PCI_DEV_ID_DECL_I40E * RTE_PCI_DEV_ID_DECL_I40EVF * RTE_PCI_DEV_ID_DECL_VIRTIO + * RTE_PCI_DEV_ID_DECL_BNXT * at the time when this file is included. * * In order to populate an array, the user of this file must define this macro: @@ -167,6 +168,15 @@ #define PCI_VENDOR_ID_VMWARE 0x15AD #endif +#ifndef PCI_VENDOR_ID_BROADCOM +/** Vendor ID used by Broadcom devices */ +#define PCI_VENDOR_ID_BROADCOM 0x14E4 +#endif + +#ifndef RTE_PCI_DEV_ID_DECL_BNXT +#define RTE_PCI_DEV_ID_DECL_BNXT(vendor, dev) +#endif + #ifndef PCI_VENDOR_ID_CISCO /** Vendor ID used by Cisco VIC devices */ #define PCI_VENDOR_ID_CISCO 0x1137 @@ -592,6 +602,30 @@ RTE_PCI_DEV_ID_DECL_VIRTIO(PCI_VENDOR_ID_QUMRANET, QUMRANET_DEV_ID_VIRTIO) RTE_PCI_DEV_ID_DECL_VMXNET3(PCI_VENDOR_ID_VMWARE, VMWARE_DEV_ID_VMXNET3) +/** Broadcom BNXT devices **/ + +#define BROADCOM_DEV_ID_57301 0x16c8 +#define BROADCOM_DEV_ID_57302 0x16c9 +#define BROADCOM_DEV_ID_57304_PF 0x16ca +#define BROADCOM_DEV_ID_57304_VF 0x16cb +#define BROADCOM_DEV_ID_57304_MF 0x16cc +#define BROADCOM_DEV_ID_57402 0x16d0 +#define BROADCOM_DEV_ID_57404 0x16d1 +#define BROADCOM_DEV_ID_57406_PF 0x16d2 +#define BROADCOM_DEV_ID_57406_VF 0x16d3 +#define BROADCOM_DEV_ID_57406_MF 0x16d4 + +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57301) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57302) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57304_PF) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57304_VF) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57304_MF) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57402) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57404) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57406_PF) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57406_VF) +RTE_PCI_DEV_ID_DECL_BNXT(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57406_MF) + /*** Virtual FM10K devices from fm10k_type.h ***/ #define FM10K_DEV_ID_VF 0x15A5 @@ -665,5 +699,6 @@ RTE_PCI_DEV_ID_DECL_BNX2X(PCI_VENDOR_ID_BROADCOM, BNX2X_DEV_ID_57840_MF) #undef RTE_PCI_DEV_ID_DECL_I40EVF #undef RTE_PCI_DEV_ID_DECL_VIRTIO #undef RTE_PCI_DEV_ID_DECL_VMXNET3 +#undef RTE_PCI_DEV_ID_DECL_BNXT #undef RTE_PCI_DEV_ID_DECL_FM10K #undef RTE_PCI_DEV_ID_DECL_FM10KVF -- 1.9.1
[dpdk-dev] [PATCH 4/7] maintainers: claim drivers/net/bnxt
Claim ownership of new drivers/net/bnxt driver. Signed-off-by: Stephen Hurd --- MAINTAINERS | 4 1 file changed, 4 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 628bc05..6ee6c3c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -359,6 +359,10 @@ F: drivers/crypto/aesni_mb/ Intel QuickAssist F: drivers/crypto/qat/ +Broadcom bnxt +M: Stephen Hurd +F: drivers/net/bnxt/ + Packet processing - -- 1.9.1
[dpdk-dev] [PATCH 3/7] drivers/net/bnxt new driver for Broadcom bnxt
New driver for Broadcom bnxt (NexXtreme C-series) devices. Standards-compliant 10/25/50G support with 30MPPS full-duplex throughput http://www.broadcom.com/press/release.php?id=s923886 Signed-off-by: Stephen Hurd --- drivers/net/bnxt/Makefile | 79 ++ drivers/net/bnxt/bnxt.h | 217 drivers/net/bnxt/bnxt_cpr.c | 138 +++ drivers/net/bnxt/bnxt_cpr.h | 117 ++ drivers/net/bnxt/bnxt_ethdev.c| 1381 ++ drivers/net/bnxt/bnxt_filter.c| 175 +++ drivers/net/bnxt/bnxt_filter.h| 74 ++ drivers/net/bnxt/bnxt_hwrm.c | 1554 drivers/net/bnxt/bnxt_hwrm.h | 105 ++ drivers/net/bnxt/bnxt_irq.c | 154 +++ drivers/net/bnxt/bnxt_irq.h | 51 + drivers/net/bnxt/bnxt_ring.c | 306 + drivers/net/bnxt/bnxt_ring.h | 104 ++ drivers/net/bnxt/bnxt_rxq.c | 383 ++ drivers/net/bnxt/bnxt_rxq.h | 75 ++ drivers/net/bnxt/bnxt_rxr.c | 369 ++ drivers/net/bnxt/bnxt_rxr.h | 73 ++ drivers/net/bnxt/bnxt_stats.c | 190 +++ drivers/net/bnxt/bnxt_stats.h | 44 + drivers/net/bnxt/bnxt_txq.c | 164 +++ drivers/net/bnxt/bnxt_txq.h | 76 ++ drivers/net/bnxt/bnxt_txr.c | 326 + drivers/net/bnxt/bnxt_txr.h | 71 ++ drivers/net/bnxt/bnxt_vnic.c | 285 + drivers/net/bnxt/bnxt_vnic.h | 80 ++ drivers/net/bnxt/hsi_struct_def_dpdk.h| 1832 + drivers/net/bnxt/rte_pmd_bnxt_version.map |4 + 27 files changed, 8427 insertions(+) create mode 100644 drivers/net/bnxt/Makefile create mode 100644 drivers/net/bnxt/bnxt.h create mode 100644 drivers/net/bnxt/bnxt_cpr.c create mode 100644 drivers/net/bnxt/bnxt_cpr.h create mode 100644 drivers/net/bnxt/bnxt_ethdev.c create mode 100644 drivers/net/bnxt/bnxt_filter.c create mode 100644 drivers/net/bnxt/bnxt_filter.h create mode 100644 drivers/net/bnxt/bnxt_hwrm.c create mode 100644 drivers/net/bnxt/bnxt_hwrm.h create mode 100644 drivers/net/bnxt/bnxt_irq.c create mode 100644 drivers/net/bnxt/bnxt_irq.h create mode 100644 drivers/net/bnxt/bnxt_ring.c create mode 100644 drivers/net/bnxt/bnxt_ring.h create mode 100644 drivers/net/bnxt/bnxt_rxq.c create mode 100644 drivers/net/bnxt/bnxt_rxq.h create mode 100644 drivers/net/bnxt/bnxt_rxr.c create mode 100644 drivers/net/bnxt/bnxt_rxr.h create mode 100644 drivers/net/bnxt/bnxt_stats.c create mode 100644 drivers/net/bnxt/bnxt_stats.h create mode 100644 drivers/net/bnxt/bnxt_txq.c create mode 100644 drivers/net/bnxt/bnxt_txq.h create mode 100644 drivers/net/bnxt/bnxt_txr.c create mode 100644 drivers/net/bnxt/bnxt_txr.h create mode 100644 drivers/net/bnxt/bnxt_vnic.c create mode 100644 drivers/net/bnxt/bnxt_vnic.h create mode 100644 drivers/net/bnxt/hsi_struct_def_dpdk.h create mode 100644 drivers/net/bnxt/rte_pmd_bnxt_version.map diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile new file mode 100644 index 000..74de642 --- /dev/null +++ b/drivers/net/bnxt/Makefile @@ -0,0 +1,79 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# Copyright(c) 2014 6WIND S.A. +# Copyright(c) 2015 Broadcom Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
[dpdk-dev] [PATCH 5/7] build: add bnxt PMD to build
Signed-off-by: Stephen Hurd --- config/common_bsdapp | 5 + config/common_linuxapp | 5 + drivers/net/Makefile | 1 + mk/rte.app.mk | 1 + 4 files changed, 12 insertions(+) diff --git a/config/common_bsdapp b/config/common_bsdapp index 696382c..f37c7bb 100644 --- a/config/common_bsdapp +++ b/config/common_bsdapp @@ -276,6 +276,11 @@ CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n # +# Compile burst-oriented BNXT PMD driver +# +CONFIG_RTE_LIBRTE_BNXT_PMD=y + +# # Compile example software rings based PMD # CONFIG_RTE_LIBRTE_PMD_RING=y diff --git a/config/common_linuxapp b/config/common_linuxapp index f1638db..35f544b 100644 --- a/config/common_linuxapp +++ b/config/common_linuxapp @@ -280,6 +280,11 @@ CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_TX_FREE=n CONFIG_RTE_LIBRTE_VMXNET3_DEBUG_DRIVER=n # +# Compile burst-oriented BNXT PMD driver +# +CONFIG_RTE_LIBRTE_BNXT_PMD=y + +# # Compile example software rings based PMD # CONFIG_RTE_LIBRTE_PMD_RING=y diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 6e4497e..6f0d64b 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -41,6 +41,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe DIRS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4 +DIRS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += bnxt DIRS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5 DIRS-$(CONFIG_RTE_LIBRTE_MPIPE_PMD) += mpipe DIRS-$(CONFIG_RTE_LIBRTE_NFP_PMD) += nfp diff --git a/mk/rte.app.mk b/mk/rte.app.mk index 8ecab41..2b5153e 100644 --- a/mk/rte.app.mk +++ b/mk/rte.app.mk @@ -144,6 +144,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += -lrte_pmd_i40e _LDLIBS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += -lrte_pmd_fm10k _LDLIBS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += -lrte_pmd_ixgbe _LDLIBS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += -lrte_pmd_e1000 +_LDLIBS-$(CONFIG_RTE_LIBRTE_BNXT_PMD) += -lrte_pmd_bnxt _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += -lrte_pmd_mlx4 _LDLIBS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += -lrte_pmd_mlx5 _LDLIBS-$(CONFIG_RTE_LIBRTE_NFP_PMD)+= -lrte_pmd_nfp -- 1.9.1
[dpdk-dev] [PATCH 6/7] doc: Add bnxt to overview table
Signed-off-by: Stephen Hurd --- doc/guides/nics/overview.rst | 64 ++-- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst index d4c6ff4..e606bdf 100644 --- a/doc/guides/nics/overview.rst +++ b/doc/guides/nics/overview.rst @@ -74,38 +74,38 @@ Most of these differences are summarized below. .. table:: Features availability in networking drivers - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - Feature a b b b c e e i i i i i i i i i i f f m m m n n p r s v v v x -f n n o x 1 n 4 4 4 4 g g x x x x m m l l p f u c i z i i m e -p x x n g 0 i 0 0 0 0 b b g g g g 1 1 x x i p l a n e r r x n -a 2 2 d b 0 c e e e e v b b b b 0 0 4 5 p l p g d t t n v -c x x i e 0 . v v f e e e e k k e a i i e i -k v n . f f . v v . t o o t r -e f g . . . f f . a . 3 t -t v v v v v 2 v -e e e e e e -c c c c c c - = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = - link status + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + Feature a b b b b c e e i i i i i i i i i i f f m m m n n p r s v v v x +f n n n o x 1 n 4 4 4 4 g g x x x x m m l l p f u c i z i i m e +p x x x n g 0 i 0 0 0 0 b b g g g g 1 1 x x i p l a n e r r x n +a 2 2 t d b 0 c e e e e v b b b b 0 0 4 5 p l p g d t t n v +c x x i e 0 . v v f e e e e k k e a i i e i +k v n . f f . v v . t o o t r +e f g . . . f f . a . 3 t +t v v v v v 2 v + e e e e e e + c c c c c c + = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = + link statusX link status event Rx interrupt - queue start/stop - MTU update - jumbo frame + queue start/stop X + MTU update X + jumbo frameX scattered Rx LRO TSO - promiscuous mode - allmulticast mode - unicast MAC filter - multicast MAC filter - RSS hash - RSS key update - RSS reta update + promiscuous mode X + allmulticast mode X + unicast MAC filter X + multicast MAC filter X + RSS hash X + RSS key update X + RSS reta updateX VMDq SR-IOV DCB - VLAN filter + VLAN filterX ethertype filter n-tuple filter SYN filter @@ -116,23 +116,23 @@ Most of these differences are summarized below. flow control rate limitation traffic mirroring - CRC offload + CRC offloadX VLAN offload QinQ offload - L3 checksum offload - L4 checksum offload + L3 checksum offloadX + L4 checksum offloadX inner L3 checksum inner L4 checksum packet type parsing timesync - basic stats + basic statsX extended stats - stats per queue + stats per queueX EEPROM dump registers dump multiprocess aware - BSD nic_uio - Linux UIO + BSD nic_uioX + Linux UIO X Linux VFIO other kdrv ARMv7 @@ -140,7 +140,7 @@ Most of these differences are summarized below. Power8 TILE-Gx x86-32 - x86-64 + x86-64 X usage doc design doc perf doc -- 1.9.1
[dpdk-dev] [PATCH 7/7] doc: add guide for new bnxt driver
Initial guide for bnxt driver, documents current limitations and provides information link. Signed-off-by: Stephen Hurd --- doc/guides/nics/bnxt.rst | 49 1 file changed, 49 insertions(+) create mode 100644 doc/guides/nics/bnxt.rst diff --git a/doc/guides/nics/bnxt.rst b/doc/guides/nics/bnxt.rst new file mode 100644 index 000..fdfa3a6 --- /dev/null +++ b/doc/guides/nics/bnxt.rst @@ -0,0 +1,49 @@ +.. BSD LICENSE +Copyright 2016 Broadcom Limited + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +* Neither the name of Broadcom Limited nor the names of its +contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +bnxt poll mode driver library += + +The bnxt poll mode library (**librte_pmd_bnxt**) implements support for +**Broadcom NetXtreme? C-Series**. These adapters support Standards- +compliant 10/25/50Gbps 30MPPS full-duplex throughput. + +Information about this family of adapters can be found in the +`NetXtreme? Brand section <https://www.broadcom.com/products/ethernet-communication-and-switching?technology%5B%5D=88>`_ +of the `Broadcom web site <http://www.broadcom.com/>`_. + +Limitations +--- + +With the current driver, allocated mbufs must be large enough to hold +the entire received frame. If the mbufs are not large enough, the +packets will be dropped. This is most limiting when jumbo frames are +used. + +SR-IOV is not supported. -- 1.9.1
[dpdk-dev] New driver (large patch) question.
Unfortunately no. On Wed, Mar 2, 2016 at 9:53 PM, Qiu, Michael wrote: > On 3/3/2016 7:11 AM, Stephen Hurd wrote: > > On Wed, Mar 2, 2016 at 2:15 PM, Thomas Monjalon < > thomas.monjalon at 6wind.com> > > wrote: > > > >>> The comments in it are the only publicly available > >>> documentation on the hardware I'm aware of. > >> So you must keep the comments. > >> > > That's my goal, but the comments are well over the 300k limit. > > > > > >>> The driver itself doesn't have a lot of optional features in it, it's > the > >>> header file that's too big. > >> It is big because there are many different things. > >> You can split the file in different patches. > >> Examples: > >> - a patch for RSS will bring the hardware structures for RSS > >> - a patch for the stats will bring the hardware stats structures > >> etc > >> > > Should I split additional definitions/documentation that's not currently > > used in the driver as well? Or should it stay as only enough to document > > what the driver already does? > > > > The header file is expected to be publicly released in the future, so I > > tried to keep it as close to the original as possible. I'm not strongly > > attached to this approach, but it does make it easier to support future > > firmware releases. > > > > It's a fairly work-intensive project to deconstruct the existing driver > > into a series of small patches that work at each step, is this a hard > > requirement? (if so, I'd better get cracking) > > Does original header file has it's own commit log(like it in other > project)? If yes, it could make your life simpler. > > Thanks, > Michael > > PS: please answer inline > > Sorry, $work just switched us to GMail and I'm still learning the ropes. > > > > -- Stephen Hurd Principal Engineer - Software Development Broadcom Corporation 949-926-8039 stephen.hurd at broadcom.com