Broadcom RoCE Driver (bnxt_re)
cover Broadcom RoCE Driver (bnxt_re)
Hi Doug,
This series introduces the RoCE driver for the Broadcom NetXtreme-C/E 10/25/40/50 gigabit RoCE HCAs. This driver is dependent on the bnxt_en NIC driver.
This patch series is based on the "bnxt_re" branch on Doug's repository + four pending bnxt_en NIC driver patches that are yet to be pulled into net-next tree.
Please review and consider applying this to linux-rdma repository.
Thanks,
Selvin Xavier
Michael Chan (7):
bnxt_en: Add bnxt_set_max_func_irqs().
bnxt_en: Enable MSIX early in bnxt_init_one().
bnxt_en: Move function reset to bnxt_init_one().
bnxt_en: Improve completion ring allocation for VFs.
bnxt_en: Reserve RDMA resources by default.
bnxt_en: Refactor the driver registration function with firmware.
bnxt_en: Add interface to support RDMA driver.
Selvin Xavier (21):
bnxt_re: Add bnxt_re RoCE driver files
bnxt_re: Introducing autogenerated Host Software Interface(hsi) file
bnxt_re: register with the NIC driver
bnxt_re: Enabling RoCE control path
bnxt_re: Adding Notification Queue support
bnxt_re: Support for PD, ucontext and mmap verbs
bnxt_re: Support for query and modify device verbs
bnxt_re: Adding support for port related verbs
bnxt_re: Support for GID related verbs
bnxt_re: Support for CQ verbs
bnxt_re: Support for AH verbs
bnxt_re: Support memory registration verbs
bnxt_re: Support QP verbs
bnxt_re: Support post_send verb
bnxt_re: Support post_recv
bnxt_re: Support poll_cq verb
bnxt_re: Handling dispatching of events to IB stack and cleanup during
unload
bnxt_re: Support for DCB
bnxt_re: Support debugfs
bnxt_re: Set uverbs command mask
bnxt_re: Add QP event handling
drivers/infiniband/Kconfig | 2 + drivers/infiniband/hw/Makefile | 1 + drivers/infiniband/hw/bnxtre/Kconfig | 9 + drivers/infiniband/hw/bnxtre/Makefile | 6 + drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 2146 +++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 391 ++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c | 660 +++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h | 193 + drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 802 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 197 + drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 811 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 134 + drivers/infiniband/hw/bnxtre/bnxt_re.h | 120 + drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c | 136 + drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h | 25 + drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h | 5201 +++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 3190 +++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 171 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 1339 ++++++ drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 60 + drivers/net/ethernet/broadcom/bnxt/Makefile | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 355 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 22 +- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 14 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 288 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 91 + 26 files changed, 16251 insertions(+), 115 deletions(-) create mode 100644 drivers/infiniband/hw/bnxtre/Kconfig create mode 100644 drivers/infiniband/hw/bnxtre/Makefile create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_main.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1480919912-1079-1-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/[email protected]
PATCH 1/28 bnxt_en: Add bnxt_set_max_func_irqs().
From: Michael Chan <michael.chan-dY08KVG/lbpWk0Htik3J/[email protected]>
By refactoring existing code into this new function. The new function will be used in subsequent patches.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 +++++++++++------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +11 -6
@@ -4743,6 +4743,16 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,return 0 ; } +void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max_irqs) +{ +if (BNXT_PF (bp)) + bp->pf.max_irqs = max_irqs; +#if defined(CONFIG_BNXT_SRIOV ) + else + bp->vf.max_irqs = max_irqs; +#endif +} +static int bnxt_setup_msix (struct bnxt *bp) {struct msix_entry *msix_ent;
@@ -6949,12 +6959,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)bnxt_set_tpa_flags (bp);bnxt_set_ring_params (bp); -if (BNXT_PF (bp)) - bp->pf.max_irqs = max_irqs; -#if defined(CONFIG_BNXT_SRIOV ) - else - bp->vf.max_irqs = max_irqs; -#endif +bnxt_set_max_func_irqs (bp, max_irqs);bnxt_set_dflt_rings (bp);/* Default RSS hash cfg. */
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -1235,6 +1235,7 @@ int hwrm_send_message(struct bnxt *, void *, u32, int);int hwrm_send_message_silent (struct bnxt *,void *,u32 ,int );int bnxt_hwrm_set_coal (struct bnxt *);int bnxt_hwrm_func_qcaps (struct bnxt *); +void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max);void bnxt_tx_disable (struct bnxt *bp);void bnxt_tx_enable (struct bnxt *bp);int bnxt_hwrm_set_pause (struct bnxt *);
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerRe: [PATCH 01/28] bnxt_en: Add bnxt_set_max_func_irqs().
It really doesn't make any sense to only send 7 out of 28 of these patches to the networking list.
In fact I would say that you need to split this series into two components.
One that goes into the networking tree, and once that's accepted you can submit the IB parts to that subsystem's maintainer.
Michael Chan
maintainerRe: [PATCH 01/28] bnxt_en: Add bnxt_set_max_func_irqs().
Quoted 6 lines · David Miller
It really doesn't make any sense to only send 7 out of 28 of these patches to the networking list.
In fact I would say that you need to split this series into two components.
OK. I will resend those bnxt_en patches later today as a separate series.
Quoted 3 lines
One that goes into the networking tree, and once that's accepted you can submit the IB parts to that subsystem's maintainer.
PATCH 6/28 bnxt_en: Refactor the driver registration function with firmware.
In reply to a message not in the archiveFrom: Michael Chan <michael.chan-dY08KVG/lbpWk0Htik3J/[email protected]>
The driver register function with firmware consists of passing version information and registering for async events. To support the RDMA driver, the async events that we need to register may change. Separate the driver register function into 2 parts so that we can just update the async events for the RDMA driver.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 34 ++++++++++++++++++++++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ 2 files changed, 31 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +29 -5
@@ -3117,27 +3117,46 @@ int hwrm_send_message_silent(struct bnxt *bp, void *msg, u32 msg_len,return rc; } -static int bnxt_hwrm_func_drv_rgtr (struct bnxt *bp) +int bnxt_hwrm_func_rgtr_async_events (struct bnxt *bp,unsigned long *bmap, +int bmap_size) {struct hwrm_func_drv_rgtr_input req = {0 }; -int i;DECLARE_BITMAP (async_events_bmap,256 );u32 *events = (u32 *)async_events_bmap; +int i;bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_FUNC_DRV_RGTR ,-1 ,-1 ); req.enables = -cpu_to_le32 (FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | -FUNC_DRV_RGTR_REQ_ENABLES_VER | -FUNC_DRV_RGTR_REQ_ENABLES_ASYNC_EVENT_FWD ); +cpu_to_le32 (FUNC_DRV_RGTR_REQ_ENABLES_ASYNC_EVENT_FWD );memset (async_events_bmap,0 ,sizeof (async_events_bmap));for (i =0 ; i <ARRAY_SIZE (bnxt_async_events_arr); i++)__set_bit (bnxt_async_events_arr[i], async_events_bmap); +if (bmap && bmap_size) { +for (i =0 ; i < bmap_size; i++) { +if (test_bit (i, bmap)) +__set_bit (i, async_events_bmap); + } + } +for (i =0 ; i <8 ; i++) req.async_event_fwd[i] |=cpu_to_le32 (events[i]); +return hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); +} + +static int bnxt_hwrm_func_drv_rgtr (struct bnxt *bp) +{ +struct hwrm_func_drv_rgtr_input req = {0 }; + +bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_FUNC_DRV_RGTR ,-1 ,-1 ); + + req.enables = +cpu_to_le32 (FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE | +FUNC_DRV_RGTR_REQ_ENABLES_VER ); + req.os_type =cpu_to_le16 (FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX ); req.ver_maj =DRV_VER_MAJ ; req.ver_min =DRV_VER_MIN ;
@@ -3146,6 +3165,7 @@ static int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp)if (BNXT_PF (bp)) {DECLARE_BITMAP (vf_req_snif_bmap,256 );u32 *data = (u32 *)vf_req_snif_bmap; +int i;memset (vf_req_snif_bmap,0 ,sizeof (vf_req_snif_bmap));for (i =0 ; i <ARRAY_SIZE (bnxt_vf_req_snif); i++)
@@ -7023,6 +7043,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc) goto init_err; + rc =bnxt_hwrm_func_rgtr_async_events (bp,NULL ,0 ); +if (rc) + goto init_err; +/* Get the MAX capabilities for this function */ rc =bnxt_hwrm_func_qcaps (bp);if (rc) {
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -1240,6 +1240,8 @@ void bnxt_hwrm_cmd_hdr_init(struct bnxt *, void *, u16, u16, u16);int _hwrm_send_message (struct bnxt *,void *,u32 ,int );int hwrm_send_message (struct bnxt *,void *,u32 ,int );int hwrm_send_message_silent (struct bnxt *,void *,u32 ,int ); +int bnxt_hwrm_func_rgtr_async_events (struct bnxt *bp,unsigned long *bmap, +int bmap_size);int bnxt_hwrm_set_coal (struct bnxt *);unsigned int bnxt_get_max_func_stat_ctxs (struct bnxt *bp);unsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp);
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/28 bnxt_re: Add bnxt_re RoCE driver files
In reply to a message not in the archiveThis patch adds the required skeletal files for Broadcom NetXtreme RoCE driver. Also, added the load/unload routines for bnxt_re driver.
--- drivers/infiniband/Kconfig | 2 + drivers/infiniband/hw/Makefile | 1 + drivers/infiniband/hw/bnxtre/Kconfig | 9 +++ drivers/infiniband/hw/bnxtre/Makefile | 5 ++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 12 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 17 +++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c | 12 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h | 17 +++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 12 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 17 +++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 12 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 17 +++++ drivers/infiniband/hw/bnxtre/bnxt_re.h | 17 +++++ drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h | 18 +++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 12 ++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 17 +++++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 96 +++++++++++++++++++++++++ 17 files changed, 293 insertions(+) create mode 100644 drivers/infiniband/hw/bnxtre/Kconfig create mode 100644 drivers/infiniband/hw/bnxtre/Makefile create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_main.c
drivers/infiniband/Kconfig +2 -0
@@ -91,4 +91,6 @@ source "drivers/infiniband/hw/hfi1/Kconfig" source "drivers/infiniband/hw/qedr/Kconfig" +source "drivers/infiniband/hw/bnxtre/Kconfig" + endif # INFINIBAND
drivers/infiniband/hw/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_INFINIBAND_USNIC) += usnic/ obj-$(CONFIG_INFINIBAND_HFI1) += hfi1/ obj-$(CONFIG_INFINIBAND_HNS) += hns/ obj-$(CONFIG_INFINIBAND_QEDR) += qedr/ +obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxtre/
drivers/infiniband/hw/bnxtre/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config INFINIBAND_BNXTRE + tristate "Broadcom Netxtreme HCA support" + depends on ETHERNET && NETDEVICES && PCI && INET + select NET_VENDOR_BROADCOM + select BNXT + ---help--- + This driver supports Broadcom NetXtreme-C/E 10/25/40/50 gigabit + RoCE HCAs. To compile this driver as a module, choose M here: + the module will be called bnxt_re.
drivers/infiniband/hw/bnxtre/Makefile new file +5 -0
@@ -0,0 +1,5 @@ + +obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxt_re.o +bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o \ + bnxt_qplib_res.o bnxt_qplib_rcfw.o \ + bnxt_qplib_sp.o bnxt_qplib_fp.o
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c new file +12 -0
@@ -0,0 +1,12 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: Fast Path Operators +*/
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: Fast Path Operators (header) +*/ + +#ifndef __BNXT_QPLIB_FP_H__ +#define __BNXT_QPLIB_FP_H__ + +#endif /* __BNXT_QPLIB_FP_H__ */
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c new file +12 -0
@@ -0,0 +1,12 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: RDMA Controller HW interface +*/
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: RDMA Controller HW interface (header) +*/ + +#ifndef __BNXT_QPLIB_RCFW_H__ +#define __BNXT_QPLIB_RCFW_H__ + +#endif /* __BNXT_QPLIB_RCFW_H__ */
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c new file +12 -0
@@ -0,0 +1,12 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: QPLib resource manager +*/
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: QPLib resource manager (header) +*/ + +#ifndef __BNXT_QPLIB_RES_H__ +#define __BNXT_QPLIB_RES_H_ + +#endif /* __BNXT_QPLIB_RES_H__ */
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c new file +12 -0
@@ -0,0 +1,12 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: Slow Path Operators +*/
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: Slow Path Operators (header) +*/ + +#ifndef __BNXT_QPLIB_SP_H__ +#define __BNXT_QPLIB_SP_H__ + +#endif /* __BNXT_QPLIB_SP_H__*/
drivers/infiniband/hw/bnxtre/bnxt_re.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Broadcom NetXtreme-C/E network driver. +* +* Copyright (c) 2014-2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +* +*/ + +#ifndef __BNXT_RE_H__ +#define __BNXT_RE_H__ +#define ROCE_DRV_MODULE_NAME "bnxt_re" +#define ROCE_DRV_MODULE_VERSION "1.0.0" + +#define BNXT_RE_DESC "Broadcom NetXtreme-C/E RoCE Driver" +#endif
drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h new file +18 -0
@@ -0,0 +1,18 @@ +/* Broadcom NetXtreme-C/E network driver. +* +* Copyright (c) 2014-2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +* +*/ + +/* +* Description: RoCE HSI File - Autogenerated +*/ + +#ifndef __BNXT_RE_HSI_H__ +#define __BNXT_RE_HSI_H__ + +#endif /* __BNXT_RE_HSI_H__ */
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c new file +12 -0
@@ -0,0 +1,12 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: IB Verbs interpreter +*/
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h new file +17 -0
@@ -0,0 +1,17 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: IB Verbs interpreter (header) +*/ + +#ifndef __BNXT_RE_IB_VERBS_H__ +#define __BNXT_RE_IB_VERBS_H__ + +#endif /* __BNXT_RE_IB_VERBS_H__ */
drivers/infiniband/hw/bnxtre/bnxt_re_main.c new file +96 -0
96 lines not on this page · raw message
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1480919912-1079-9-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [PATCH 08/28] bnxt_re: Add bnxt_re RoCE driver files
Quoted 41 lines · Selvin Xavier
drivers/infiniband/Kconfig +2
-0@@ -91,4 +91,6 @@ source "drivers/infiniband/hw/hfi1/Kconfig" source "drivers/infiniband/hw/qedr/Kconfig" +source "drivers/infiniband/hw/bnxtre/Kconfig" + endif # INFINIBANDdrivers/infiniband/hw/Makefile +1
-0@@ -11,3 +11,4 @@ obj-$(CONFIG_INFINIBAND_USNIC) += usnic/ obj-$(CONFIG_INFINIBAND_HFI1) += hfi1/ obj-$(CONFIG_INFINIBAND_HNS) += hns/ obj-$(CONFIG_INFINIBAND_QEDR) += qedr/ +obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxtre/drivers/infiniband/hw/bnxtre/Kconfig new file +9
-0@@ -0,0 +1,9 @@ +config INFINIBAND_BNXTRE + tristate "Broadcom Netxtreme HCA support" + depends on ETHERNET && NETDEVICES && PCI && INET + select NET_VENDOR_BROADCOM + select BNXT + ---help--- + This driver supports Broadcom NetXtreme-C/E 10/25/40/50 gigabit + RoCE HCAs. To compile this driver as a module, choose M here: + the module will be called bnxt_re.drivers/infiniband/hw/bnxtre/Makefile new file +0
-0
drivers/infiniband/hw/bnxtre/Makefile line 5
Quoted 5 lines
drivers/infiniband/hw/bnxtre/Makefile new file +5
-0@@ -0,0 +1,5 @@ + +obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxt_re.o +bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o \ + bnxt_qplib_res.o bnxt_qplib_rcfw.o \ + bnxt_qplib_sp.o bnxt_qplib_fp.o
A lot of times I prefer these files to be the final patch in the series.
It's completely not possible to break bisectability if these are last.
Then again, if I squash this down to one commit it doesn't really matter....
Quoted 6 lines
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c new file +0
-0
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c line 8
Quoted 8 lines
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c new file +8
-0@@ -0,0 +1,12 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/
This copyright, repeated many times in the various skeleton files...
Quoted 22 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c new file +16
-0@@ -0,0 +1,96 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: Main component of the bnxt_re driver +*/ + +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/mutex.h>
drivers/infiniband/hw/bnxtre/bnxt_re_main.c line 26
Quoted 10 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c new file +10
-0+#include <linux/list.h> +#include <linux/rculist.h> +#include "bnxt_re.h" +static char version[] = +BNXT_RE_DESC " v" ROCE_DRV_MODULE_VERSION "\n" ; + + +MODULE_AUTHOR ("Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/[email protected]>" ); +MODULE_DESCRIPTION (BNXT_RE_DESC " Driver" ); +MODULE_LICENSE ("Dual BSD/GPL" );
and this module license description do not agree. Please make everything consistent. I don't care if it's GPLv2 or Dual licensed, it simply needs to be consistent.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD
A message that is not in the archive (sent off-list or not yet received): 09068db2-1a14-9fbb-074b-4cf000fbddfb-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 08/28] bnxt_re: Add bnxt_re RoCE driver files
Hi Doug,
Please find my response inline.
Quoted 2 lines · Doug Ledford
On 12/5/2016 1:38 AM, Selvin Xavier wrote:
...
Quoted 12 lines
drivers/infiniband/hw/bnxtre/Makefile line 5
Quoted 7 lines
+++ b/drivers/infiniband/hw/bnxtre/Makefile
drivers/infiniband/hw/bnxtre/Makefile new file +5
-0@@ -0,0 +1,5 @@ + +obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxt_re.o +bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o \ + bnxt_qplib_res.o bnxt_qplib_rcfw.o \ + bnxt_qplib_sp.o bnxt_qplib_fp.oA lot of times I prefer these files to be the final patch in the series.
It's completely not possible to break bisectability if these are last.
Then again, if I squash this down to one commit it doesn't really matter....
[Selvin Xavier] While splitting the patch series, we made sure that the compilation works after applying each patch.
But i am ok to push these changes to last patch. This can be included in v2 patch set.
....
Quoted 31 lines
This copyright, repeated many times in the various skeleton files...
Quoted 28 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c new file +22
-0@@ -0,0 +1,96 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ + +/* +* Description: Main component of the bnxt_re driver +*/ + +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/mutex.h> +#include <linux/list.h> +#include <linux/rculist.h> +#include "bnxt_re.h" +static char version[] = +BNXT_RE_DESC " v" ROCE_DRV_MODULE_VERSION "\n" ; +
Quoted 9 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c line 26
Quoted 4 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c new file +4
-0+ +MODULE_AUTHOR ("Eddie Wai <eddie.wai-dY08KVG/lbpWk0Htik3J/[email protected]>" ); +MODULE_DESCRIPTION (BNXT_RE_DESC " Driver" ); +MODULE_LICENSE ("Dual BSD/GPL" );and this module license description do not agree. Please make everything consistent. I don't care if it's GPLv2 or Dual licensed, it simply needs to be consistent.
[Selvin Xavier] i will post v2 with this change. We need Dual license. Will edit the license text
accordingly.
Quoted 7 lines
--
Doug Ledford <[email protected]>
GPG Key ID: 0E572FDD
Thanks,
Selvin
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/28 bnxt_re: Introducing autogenerated Host Software Interface(hsi) file
In reply to a message not in the archiveThis patch introduces all the structures used by driver for communicating with the Hardware. This file is the equivalent of the bnxt_en_hsi.h used by bnxt_en driver.
--- drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h | 5183 ++++++++++++++++++++++++++++ 1 file changed, 5183 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h +5183 -0
@@ -14,5 +14,5188 @@ #ifndef __BNXT_RE_HSI_H__ #define __BNXT_RE_HSI_H__ +/* per-context HW statistics -- chip view */ +typedef struct ctx_hw_stats { + __le64 rx_ucast_pkts; + __le64 rx_mcast_pkts; + __le64 rx_bcast_pkts; + __le64 rx_discard_pkts; + __le64 rx_drop_pkts; + __le64 rx_ucast_bytes; + __le64 rx_mcast_bytes; + __le64 rx_bcast_bytes; + __le64 tx_ucast_pkts; + __le64 tx_mcast_pkts; + __le64 tx_bcast_pkts; + __le64 tx_discard_pkts; + __le64 tx_drop_pkts; + __le64 tx_ucast_bytes; + __le64 tx_mcast_bytes; + __le64 tx_bcast_bytes; + __le64 tpa_pkts; + __le64 tpa_bytes; + __le64 tpa_events; + __le64 tpa_aborts; +} ctx_hw_stats_t, *pctx_hw_stats_t; +/* HWRM Completion Record (16 bytes) */ +struct hwrm_cmpl { + __le16 type; + #define HWRM_CMPL_TYPE_MASK 0x3fUL + #define HWRM_CMPL_TYPE_SFT 0 + #define HWRM_CMPL_TYPE_HWRM_DONE 0x20UL + __le16 sequence_id; + __le32 unused_1; + __le32 v; + #define HWRM_CMPL_V 0x1UL + __le32 unused_3; +}; + +/* HWRM Asynchronous Event Completion Record (16 bytes) */ +struct hwrm_async_event_cmpl { + __le16 type; + #define HWRM_ASYNC_EVENT_CMPL_TYPE_MASK 0x3fUL + #define HWRM_ASYNC_EVENT_CMPL_TYPE_SFT 0 + #define HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT 0x2eUL + __le16 event_id; + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE 0x0UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_MTU_CHANGE 0x1UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE 0x2UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE 0x3UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_CONN_NOT_ALLOWED 0x4UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_NOT_ALLOWED 0x5UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CFG_CHANGE 0x6UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE 0x7UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_UNLOAD 0x10UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_DRVR_LOAD 0x11UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_FUNC_FLR_PROC_CMPLT 0x12UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_UNLOAD 0x20UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_DRVR_LOAD 0x21UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_FLR 0x30UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_MAC_ADDR_CHANGE 0x31UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_PF_VF_COMM_STATUS_CHANGE 0x32UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_VF_CFG_CHANGE 0x33UL + #define HWRM_ASYNC_EVENT_CMPL_EVENT_ID_HWRM_ERROR 0xffUL + __le32 event_data2; + u8 opaque_v; + #define HWRM_ASYNC_EVENT_CMPL_V 0x1UL + #define HWRM_ASYNC_EVENT_CMPL_OPAQUE_MASK 0xfeUL + #define HWRM_ASYNC_EVENT_CMPL_OPAQUE_SFT 1 + u8 timestamp_lo; + __le16 timestamp_hi; + __le32 event_data1; +}; + +/* CMP Door Bell Format (4 bytes) */ +struct cmpl_doorbell { + __le32 key_mask_valid_idx; + #define CMPL_DOORBELL_IDX_MASK 0xffffffUL + #define CMPL_DOORBELL_IDX_SFT 0 + #define CMPL_DOORBELL_RESERVED_MASK 0x3000000UL + #define CMPL_DOORBELL_RESERVED_SFT 24 + #define CMPL_DOORBELL_IDX_VALID 0x4000000UL + #define CMPL_DOORBELL_MASK 0x8000000UL + #define CMPL_DOORBELL_KEY_MASK 0xf0000000UL + #define CMPL_DOORBELL_KEY_SFT 28 + #define CMPL_DOORBELL_KEY_CMPL (0x2UL << 28) +}; + +/* Status Door Bell Format (4 bytes) */ +struct status_doorbell { + __le32 key_idx; + #define STATUS_DOORBELL_IDX_MASK 0xffffffUL + #define STATUS_DOORBELL_IDX_SFT 0 + #define STATUS_DOORBELL_RESERVED_MASK 0xf000000UL + #define STATUS_DOORBELL_RESERVED_SFT 24 + #define STATUS_DOORBELL_KEY_MASK 0xf0000000UL + #define STATUS_DOORBELL_KEY_SFT 28 + #define STATUS_DOORBELL_KEY_STAT (0x3UL << 28) +}; + +/* HW Resource Manager Specification 1.5.4 */ +#define HWRM_VERSION_MAJOR 1 +#define HWRM_VERSION_MINOR 5 +#define HWRM_VERSION_UPDATE 4 + +#define HWRM_VERSION_STR "1.5.4" +/* + * Following is the signature for HWRM message field that indicates not + * applicable (All F's). Need to cast it the size of the field if needed. + */ +#define HWRM_NA_SIGNATURE ((__le32)(-1)) +#define HWRM_MAX_REQ_LEN (128) /* hwrm_func_buf_rgtr */ +#define HWRM_MAX_RESP_LEN (176) /* hwrm_func_qstats */ +#define HW_HASH_INDEX_SIZE 0x80 /* 7 bit indirection table index. */ +#define HW_HASH_KEY_SIZE 40 +#define HWRM_RESP_VALID_KEY 1 /* valid key for HWRM response */ + +/* Input (16 bytes) */ +struct input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; +}; + +/* Output (8 bytes) */ +struct output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; +}; + +/* Command numbering (8 bytes) */ +struct cmd_nums { + __le16 req_type; + #define HWRM_VER_GET (0x0UL) + #define HWRM_FUNC_BUF_UNRGTR (0xeUL) + #define HWRM_FUNC_VF_CFG (0xfUL) + #define RESERVED1 (0x10UL) + #define HWRM_FUNC_RESET (0x11UL) + #define HWRM_FUNC_GETFID (0x12UL) + #define HWRM_FUNC_VF_ALLOC (0x13UL) + #define HWRM_FUNC_VF_FREE (0x14UL) + #define HWRM_FUNC_QCAPS (0x15UL) + #define HWRM_FUNC_QCFG (0x16UL) + #define HWRM_FUNC_CFG (0x17UL) + #define HWRM_FUNC_QSTATS (0x18UL) + #define HWRM_FUNC_CLR_STATS (0x19UL) + #define HWRM_FUNC_DRV_UNRGTR (0x1aUL) + #define HWRM_FUNC_VF_RESC_FREE (0x1bUL) + #define HWRM_FUNC_VF_VNIC_IDS_QUERY (0x1cUL) + #define HWRM_FUNC_DRV_RGTR (0x1dUL) + #define HWRM_FUNC_DRV_QVER (0x1eUL) + #define HWRM_FUNC_BUF_RGTR (0x1fUL) + #define HWRM_PORT_PHY_CFG (0x20UL) + #define HWRM_PORT_MAC_CFG (0x21UL) + #define HWRM_PORT_TS_QUERY (0x22UL) + #define HWRM_PORT_QSTATS (0x23UL) + #define HWRM_PORT_LPBK_QSTATS (0x24UL) + #define HWRM_PORT_CLR_STATS (0x25UL) + #define HWRM_PORT_LPBK_CLR_STATS (0x26UL) + #define HWRM_PORT_PHY_QCFG (0x27UL) + #define HWRM_PORT_MAC_QCFG (0x28UL) + #define HWRM_PORT_BLINK_LED (0x29UL) + #define HWRM_PORT_PHY_QCAPS (0x2aUL) + #define HWRM_PORT_PHY_I2C_WRITE (0x2bUL) + #define HWRM_PORT_PHY_I2C_READ (0x2cUL) + #define HWRM_QUEUE_QPORTCFG (0x30UL) + #define HWRM_QUEUE_QCFG (0x31UL) + #define HWRM_QUEUE_CFG (0x32UL) + #define RESERVED2 (0x33UL) + #define RESERVED3 (0x34UL) + #define HWRM_QUEUE_PFCENABLE_QCFG (0x35UL) + #define HWRM_QUEUE_PFCENABLE_CFG (0x36UL) + #define HWRM_QUEUE_PRI2COS_QCFG (0x37UL) + #define HWRM_QUEUE_PRI2COS_CFG (0x38UL) + #define HWRM_QUEUE_COS2BW_QCFG (0x39UL) + #define HWRM_QUEUE_COS2BW_CFG (0x3aUL) + #define HWRM_VNIC_ALLOC (0x40UL) + #define HWRM_VNIC_FREE (0x41UL) + #define HWRM_VNIC_CFG (0x42UL) + #define HWRM_VNIC_QCFG (0x43UL) + #define HWRM_VNIC_TPA_CFG (0x44UL) + #define HWRM_VNIC_TPA_QCFG (0x45UL) + #define HWRM_VNIC_RSS_CFG (0x46UL) + #define HWRM_VNIC_RSS_QCFG (0x47UL) + #define HWRM_VNIC_PLCMODES_CFG (0x48UL) + #define HWRM_VNIC_PLCMODES_QCFG (0x49UL) + #define HWRM_VNIC_QCAPS (0x4aUL) + #define HWRM_RING_ALLOC (0x50UL) + #define HWRM_RING_FREE (0x51UL) + #define HWRM_RING_CMPL_RING_QAGGINT_PARAMS (0x52UL) + #define HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS (0x53UL) + #define HWRM_RING_RESET (0x5eUL) + #define HWRM_RING_GRP_ALLOC (0x60UL) + #define HWRM_RING_GRP_FREE (0x61UL) + #define RESERVED5 (0x64UL) + #define RESERVED6 (0x65UL) + #define HWRM_VNIC_RSS_COS_LB_CTX_ALLOC (0x70UL) + #define HWRM_VNIC_RSS_COS_LB_CTX_FREE (0x71UL) + #define HWRM_CFA_L2_FILTER_ALLOC (0x90UL) + #define HWRM_CFA_L2_FILTER_FREE (0x91UL) + #define HWRM_CFA_L2_FILTER_CFG (0x92UL) + #define HWRM_CFA_L2_SET_RX_MASK (0x93UL) + #define RESERVED4 (0x94UL) + #define HWRM_CFA_TUNNEL_FILTER_ALLOC (0x95UL) + #define HWRM_CFA_TUNNEL_FILTER_FREE (0x96UL) + #define HWRM_CFA_ENCAP_RECORD_ALLOC (0x97UL) + #define HWRM_CFA_ENCAP_RECORD_FREE (0x98UL) + #define HWRM_CFA_NTUPLE_FILTER_ALLOC (0x99UL) + #define HWRM_CFA_NTUPLE_FILTER_FREE (0x9aUL) + #define HWRM_CFA_NTUPLE_FILTER_CFG (0x9bUL) + #define HWRM_CFA_EM_FLOW_ALLOC (0x9cUL) + #define HWRM_CFA_EM_FLOW_FREE (0x9dUL) + #define HWRM_CFA_EM_FLOW_CFG (0x9eUL) + #define HWRM_TUNNEL_DST_PORT_QUERY (0xa0UL) + #define HWRM_TUNNEL_DST_PORT_ALLOC (0xa1UL) + #define HWRM_TUNNEL_DST_PORT_FREE (0xa2UL) + #define HWRM_STAT_CTX_ALLOC (0xb0UL) + #define HWRM_STAT_CTX_FREE (0xb1UL) + #define HWRM_STAT_CTX_QUERY (0xb2UL) + #define HWRM_STAT_CTX_CLR_STATS (0xb3UL) + #define HWRM_FW_RESET (0xc0UL) + #define HWRM_FW_QSTATUS (0xc1UL) + #define HWRM_FW_SET_TIME (0xc8UL) + #define HWRM_FW_GET_TIME (0xc9UL) + #define HWRM_FW_SET_STRUCTURED_DATA (0xcaUL) + #define HWRM_FW_GET_STRUCTURED_DATA (0xcbUL) + #define HWRM_FW_IPC_MAILBOX (0xccUL) + #define HWRM_EXEC_FWD_RESP (0xd0UL) + #define HWRM_REJECT_FWD_RESP (0xd1UL) + #define HWRM_FWD_RESP (0xd2UL) + #define HWRM_FWD_ASYNC_EVENT_CMPL (0xd3UL) + #define HWRM_TEMP_MONITOR_QUERY (0xe0UL) + #define HWRM_WOL_FILTER_ALLOC (0xf0UL) + #define HWRM_WOL_FILTER_FREE (0xf1UL) + #define HWRM_WOL_FILTER_QCFG (0xf2UL) + #define HWRM_WOL_REASON_QCFG (0xf3UL) + #define HWRM_DBG_READ_DIRECT (0xff10UL) + #define HWRM_DBG_READ_INDIRECT (0xff11UL) + #define HWRM_DBG_WRITE_DIRECT (0xff12UL) + #define HWRM_DBG_WRITE_INDIRECT (0xff13UL) + #define HWRM_DBG_DUMP (0xff14UL) + #define HWRM_NVM_GET_VARIABLE (0xfff1UL) + #define HWRM_NVM_SET_VARIABLE (0xfff2UL) + #define HWRM_NVM_INSTALL_UPDATE (0xfff3UL) + #define HWRM_NVM_MODIFY (0xfff4UL) + #define HWRM_NVM_VERIFY_UPDATE (0xfff5UL) + #define HWRM_NVM_GET_DEV_INFO (0xfff6UL) + #define HWRM_NVM_ERASE_DIR_ENTRY (0xfff7UL) + #define HWRM_NVM_MOD_DIR_ENTRY (0xfff8UL) + #define HWRM_NVM_FIND_DIR_ENTRY (0xfff9UL) + #define HWRM_NVM_GET_DIR_ENTRIES (0xfffaUL) + #define HWRM_NVM_GET_DIR_INFO (0xfffbUL) + #define HWRM_NVM_RAW_DUMP (0xfffcUL) + #define HWRM_NVM_READ (0xfffdUL) + #define HWRM_NVM_WRITE (0xfffeUL) + #define HWRM_NVM_RAW_WRITE_BLK (0xffffUL) + __le16 unused_0[3]; +}; + +#define GET_HWRM_ERROR_CODE(x) \ + ((x) == 0xf ? "HWRM_ERROR" : \ + ((x) == 0xffff ? "CMD_NOT_SUPPORTED" : \ + ((x) == 0xfffe ? "UNKNOWN_ERR" : \ + ((x) == 0x4 ? "RESOURCE_ALLOC_ERROR" : \ + ((x) == 0x5 ? "INVALID_FLAGS" : \ + ((x) == 0x6 ? "INVALID_ENABLES" : \ + ((x) == 0x0 ? "SUCCESS" : \ + ((x) == 0x1 ? "FAIL" : \ + ((x) == 0x2 ? "INVALID_PARAMS" : \ + ((x) == 0x3 ? "RESOURCE_ACCESS_DENIED" : \ + "Unknown error_code")))))))))) + +/* Return Codes (8 bytes) */ +struct ret_codes { + __le16 error_code; + #define HWRM_ERR_CODE_SUCCESS (0x0UL) + #define HWRM_ERR_CODE_FAIL (0x1UL) + #define HWRM_ERR_CODE_INVALID_PARAMS (0x2UL) + #define HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED (0x3UL) + #define HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR (0x4UL) + #define HWRM_ERR_CODE_INVALID_FLAGS (0x5UL) + #define HWRM_ERR_CODE_INVALID_ENABLES (0x6UL) + #define HWRM_ERR_CODE_HWRM_ERROR (0xfUL) + #define HWRM_ERR_CODE_UNKNOWN_ERR (0xfffeUL) + #define HWRM_ERR_CODE_CMD_NOT_SUPPORTED (0xffffUL) + __le16 unused_0[3]; +}; + +/* Output (16 bytes) */ +struct hwrm_err_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 opaque_0; + __le16 opaque_1; + u8 cmd_err; + u8 valid; +}; + +/* RoCE Host Structures */ +/* hwrm_ver_get */ +/* Input (24 bytes) */ +struct hwrm_ver_get_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + u8 hwrm_intf_maj; + u8 hwrm_intf_min; + u8 hwrm_intf_upd; + u8 unused_0[5]; +}; + +/* Output (128 bytes) */ +struct hwrm_ver_get_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 hwrm_intf_maj; + u8 hwrm_intf_min; + u8 hwrm_intf_upd; + u8 hwrm_intf_rsvd; + u8 hwrm_fw_maj; + u8 hwrm_fw_min; + u8 hwrm_fw_bld; + u8 hwrm_fw_rsvd; + u8 mgmt_fw_maj; + u8 mgmt_fw_min; + u8 mgmt_fw_bld; + u8 mgmt_fw_rsvd; + u8 netctrl_fw_maj; + u8 netctrl_fw_min; + u8 netctrl_fw_bld; + u8 netctrl_fw_rsvd; + __le32 dev_caps_cfg; + #define VER_GET_RESP_DEV_CAPS_CFG_SECURE_FW_UPD_SUPPORTED 0x1UL + #define VER_GET_RESP_DEV_CAPS_CFG_FW_DCBX_AGENT_SUPPORTED 0x2UL + u8 roce_fw_maj; + u8 roce_fw_min; + u8 roce_fw_bld; + u8 roce_fw_rsvd; + char hwrm_fw_name[16]; + char mgmt_fw_name[16]; + char netctrl_fw_name[16]; + __le32 reserved2[4]; + char roce_fw_name[16]; + __le16 chip_num; + u8 chip_rev; + u8 chip_metal; + u8 chip_bond_id; + u8 chip_platform_type; + #define VER_GET_RESP_CHIP_PLATFORM_TYPE_ASIC 0x0UL + #define VER_GET_RESP_CHIP_PLATFORM_TYPE_FPGA 0x1UL + #define VER_GET_RESP_CHIP_PLATFORM_TYPE_PALLADIUM 0x2UL + __le16 max_req_win_len; + __le16 max_resp_len; + __le16 def_req_timeout; + u8 unused_0; + u8 unused_1; + u8 unused_2; + u8 valid; +}; + +/* hwrm_func_qcaps */ +/* Input (24 bytes) */ +struct hwrm_func_qcaps_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 fid; + __le16 unused_0[3]; +}; + +/* Output (80 bytes) */ +struct hwrm_func_qcaps_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le16 fid; + __le16 port_id; + __le32 flags; + #define FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED 0x1UL + #define FUNC_QCAPS_RESP_FLAGS_GLOBAL_MSIX_AUTOMASKING 0x2UL + #define FUNC_QCAPS_RESP_FLAGS_PTP_SUPPORTED 0x4UL + #define FUNC_QCAPS_RESP_FLAGS_ROCE_V1_SUPPORTED 0x8UL + #define FUNC_QCAPS_RESP_FLAGS_ROCE_V2_SUPPORTED 0x10UL + #define FUNC_QCAPS_RESP_FLAGS_WOL_MAGICPKT_SUPPORTED 0x20UL + #define FUNC_QCAPS_RESP_FLAGS_WOL_BMP_SUPPORTED 0x40UL + #define FUNC_QCAPS_RESP_FLAGS_TX_RING_RL_SUPPORTED 0x80UL + #define FUNC_QCAPS_RESP_FLAGS_TX_BW_CFG_SUPPORTED 0x100UL + #define FUNC_QCAPS_RESP_FLAGS_VF_TX_RING_RL_SUPPORTED 0x200UL + #define FUNC_QCAPS_RESP_FLAGS_VF_BW_CFG_SUPPORTED 0x400UL + u8 mac_address[6]; + __le16 max_rsscos_ctx; + __le16 max_cmpl_rings; + __le16 max_tx_rings; + __le16 max_rx_rings; + __le16 max_l2_ctxs; + __le16 max_vnics; + __le16 first_vf_id; + __le16 max_vfs; + __le16 max_stat_ctx; + __le32 max_encap_records; + __le32 max_decap_records; + __le32 max_tx_em_flows; + __le32 max_tx_wm_flows; + __le32 max_rx_em_flows; + __le32 max_rx_wm_flows; + __le32 max_mcast_filters; + __le32 max_flow_id; + __le32 max_hw_ring_grps; + __le16 max_sp_tx_rings; + u8 unused_0; + u8 valid; +}; + +/* hwrm_func_qcfg */ +/* Input (24 bytes) */ +struct hwrm_func_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 fid; + __le16 unused_0[3]; +}; + +/* hwrm_func_drv_rgtr */ +/* Input (80 bytes) */ +struct hwrm_func_drv_rgtr_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define FUNC_DRV_RGTR_REQ_FLAGS_FWD_ALL_MODE 0x1UL + #define FUNC_DRV_RGTR_REQ_FLAGS_FWD_NONE_MODE 0x2UL + __le32 enables; + #define FUNC_DRV_RGTR_REQ_ENABLES_OS_TYPE 0x1UL + #define FUNC_DRV_RGTR_REQ_ENABLES_VER 0x2UL + #define FUNC_DRV_RGTR_REQ_ENABLES_TIMESTAMP 0x4UL + #define FUNC_DRV_RGTR_REQ_ENABLES_VF_REQ_FWD 0x8UL + #define FUNC_DRV_RGTR_REQ_ENABLES_ASYNC_EVENT_FWD 0x10UL + __le16 os_type; + #define FUNC_DRV_RGTR_REQ_OS_TYPE_UNKNOWN 0x0UL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_OTHER 0x1UL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_MSDOS 0xeUL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_WINDOWS 0x12UL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_SOLARIS 0x1dUL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_LINUX 0x24UL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_FREEBSD 0x2aUL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_ESXI 0x68UL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_WIN864 0x73UL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_WIN2012R2 0x74UL + #define FUNC_DRV_RGTR_REQ_OS_TYPE_UEFI 0x8000UL + u8 ver_maj; + u8 ver_min; + u8 ver_upd; + u8 unused_0; + __le16 unused_1; + __le32 timestamp; + __le32 unused_2; + __le32 vf_req_fwd[8]; + __le32 async_event_fwd[8]; +}; + +/* Output (16 bytes) */ +struct hwrm_func_drv_rgtr_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_func_drv_unrgtr */ +/* Input (24 bytes) */ +struct hwrm_func_drv_unrgtr_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define FUNC_DRV_UNRGTR_REQ_FLAGS_PREPARE_FOR_SHUTDOWN 0x1UL + __le32 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_func_drv_unrgtr_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_func_buf_rgtr */ +/* Input (128 bytes) */ +struct hwrm_func_buf_rgtr_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 enables; + #define FUNC_BUF_RGTR_REQ_ENABLES_VF_ID 0x1UL + #define FUNC_BUF_RGTR_REQ_ENABLES_ERR_BUF_ADDR 0x2UL + __le16 vf_id; + __le16 req_buf_num_pages; + __le16 req_buf_page_size; + #define FUNC_BUF_RGTR_REQ_REQ_BUF_PAGE_SIZE_16B 0x4UL + #define FUNC_BUF_RGTR_REQ_REQ_BUF_PAGE_SIZE_4K 0xcUL + #define FUNC_BUF_RGTR_REQ_REQ_BUF_PAGE_SIZE_8K 0xdUL + #define FUNC_BUF_RGTR_REQ_REQ_BUF_PAGE_SIZE_64K 0x10UL + #define FUNC_BUF_RGTR_REQ_REQ_BUF_PAGE_SIZE_2M 0x15UL + #define FUNC_BUF_RGTR_REQ_REQ_BUF_PAGE_SIZE_4M 0x16UL + #define FUNC_BUF_RGTR_REQ_REQ_BUF_PAGE_SIZE_1G 0x1eUL + __le16 req_buf_len; + __le16 resp_buf_len; + u8 unused_0; + u8 unused_1; + __le64 req_buf_page_addr0; + __le64 req_buf_page_addr1; + __le64 req_buf_page_addr2; + __le64 req_buf_page_addr3; + __le64 req_buf_page_addr4; + __le64 req_buf_page_addr5; + __le64 req_buf_page_addr6; + __le64 req_buf_page_addr7; + __le64 req_buf_page_addr8; + __le64 req_buf_page_addr9; + __le64 error_buf_addr; + __le64 resp_buf_addr; +}; + +/* Output (16 bytes) */ +struct hwrm_func_buf_rgtr_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_func_buf_unrgtr */ +/* Input (24 bytes) */ +struct hwrm_func_buf_unrgtr_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 enables; + #define FUNC_BUF_UNRGTR_REQ_ENABLES_VF_ID 0x1UL + __le16 vf_id; + __le16 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_func_buf_unrgtr_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_func_drv_qver */ +/* Input (24 bytes) */ +struct hwrm_func_drv_qver_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 reserved; + __le16 fid; + __le16 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_func_drv_qver_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le16 os_type; + #define FUNC_DRV_QVER_RESP_OS_TYPE_UNKNOWN 0x0UL + #define FUNC_DRV_QVER_RESP_OS_TYPE_OTHER 0x1UL + #define FUNC_DRV_QVER_RESP_OS_TYPE_MSDOS 0xeUL + #define FUNC_DRV_QVER_RESP_OS_TYPE_WINDOWS 0x12UL + #define FUNC_DRV_QVER_RESP_OS_TYPE_SOLARIS 0x1dUL + #define FUNC_DRV_QVER_RESP_OS_TYPE_LINUX 0x24UL + #define FUNC_DRV_QVER_RESP_OS_TYPE_FREEBSD 0x2aUL + #define FUNC_DRV_QVER_RESP_OS_TYPE_ESXI 0x68UL + #define FUNC_DRV_QVER_RESP_OS_TYPE_WIN864 0x73UL + #define FUNC_DRV_QVER_RESP_OS_TYPE_WIN2012R2 0x74UL + #define FUNC_DRV_QVER_RESP_OS_TYPE_UEFI 0x8000UL + u8 ver_maj; + u8 ver_min; + u8 ver_upd; + u8 unused_0; + u8 unused_1; + u8 valid; +}; + +/* hwrm_port_phy_qcfg */ +/* Input (24 bytes) */ +struct hwrm_port_phy_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 port_id; + __le16 unused_0[3]; +}; + +/* Output (96 bytes) */ +struct hwrm_port_phy_qcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 link; + #define PORT_PHY_QCFG_RESP_LINK_NO_LINK 0x0UL + #define PORT_PHY_QCFG_RESP_LINK_SIGNAL 0x1UL + #define PORT_PHY_QCFG_RESP_LINK_LINK 0x2UL + u8 unused_0; + __le16 link_speed; + #define PORT_PHY_QCFG_RESP_LINK_SPEED_100MB 0x1UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_1GB 0xaUL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_2GB 0x14UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB 0x19UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_10GB 0x64UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_20GB 0xc8UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_25GB 0xfaUL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_40GB 0x190UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_50GB 0x1f4UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_100GB 0x3e8UL + #define PORT_PHY_QCFG_RESP_LINK_SPEED_10MB 0xffffUL + u8 duplex; + #define PORT_PHY_QCFG_RESP_DUPLEX_HALF 0x0UL + #define PORT_PHY_QCFG_RESP_DUPLEX_FULL 0x1UL + u8 pause; + #define PORT_PHY_QCFG_RESP_PAUSE_TX 0x1UL + #define PORT_PHY_QCFG_RESP_PAUSE_RX 0x2UL + __le16 support_speeds; + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MBHD 0x1UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100MB 0x2UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GBHD 0x4UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_1GB 0x8UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2GB 0x10UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_2_5GB 0x20UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10GB 0x40UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_20GB 0x80UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_25GB 0x100UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_40GB 0x200UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_50GB 0x400UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_100GB 0x800UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10MBHD 0x1000UL + #define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS_10MB 0x2000UL + __le16 force_link_speed; + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_100MB 0x1UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_1GB 0xaUL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_2GB 0x14UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_2_5GB 0x19UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_10GB 0x64UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_20GB 0xc8UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_25GB 0xfaUL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_40GB 0x190UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_50GB 0x1f4UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_100GB 0x3e8UL + #define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEED_10MB 0xffffUL + u8 auto_mode; + #define PORT_PHY_QCFG_RESP_AUTO_MODE_NONE 0x0UL + #define PORT_PHY_QCFG_RESP_AUTO_MODE_ALL_SPEEDS 0x1UL + #define PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_SPEED 0x2UL + #define PORT_PHY_QCFG_RESP_AUTO_MODE_ONE_OR_BELOW 0x3UL + #define PORT_PHY_QCFG_RESP_AUTO_MODE_SPEED_MASK 0x4UL + u8 auto_pause; + #define PORT_PHY_QCFG_RESP_AUTO_PAUSE_TX 0x1UL + #define PORT_PHY_QCFG_RESP_AUTO_PAUSE_RX 0x2UL + #define PORT_PHY_QCFG_RESP_AUTO_PAUSE_AUTONEG_PAUSE 0x4UL + __le16 auto_link_speed; + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_100MB 0x1UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_1GB 0xaUL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_2GB 0x14UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_2_5GB 0x19UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_10GB 0x64UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_20GB 0xc8UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_25GB 0xfaUL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_40GB 0x190UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_50GB 0x1f4UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_100GB 0x3e8UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_10MB 0xffffUL + __le16 auto_link_speed_mask; + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_100MBHD 0x1UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_100MB 0x2UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_1GBHD 0x4UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_1GB 0x8UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_2GB 0x10UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_2_5GB 0x20UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_10GB 0x40UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_20GB 0x80UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_25GB 0x100UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_40GB 0x200UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_50GB 0x400UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_100GB 0x800UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_10MBHD 0x1000UL + #define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEED_MASK_10MB 0x2000UL + u8 wirespeed; + #define PORT_PHY_QCFG_RESP_WIRESPEED_OFF 0x0UL + #define PORT_PHY_QCFG_RESP_WIRESPEED_ON 0x1UL + u8 lpbk; + #define PORT_PHY_QCFG_RESP_LPBK_NONE 0x0UL + #define PORT_PHY_QCFG_RESP_LPBK_LOCAL 0x1UL + #define PORT_PHY_QCFG_RESP_LPBK_REMOTE 0x2UL + u8 force_pause; + #define PORT_PHY_QCFG_RESP_FORCE_PAUSE_TX 0x1UL + #define PORT_PHY_QCFG_RESP_FORCE_PAUSE_RX 0x2UL + u8 module_status; + #define PORT_PHY_QCFG_RESP_MODULE_STATUS_NONE 0x0UL + #define PORT_PHY_QCFG_RESP_MODULE_STATUS_DISABLETX 0x1UL + #define PORT_PHY_QCFG_RESP_MODULE_STATUS_WARNINGMSG 0x2UL + #define PORT_PHY_QCFG_RESP_MODULE_STATUS_PWRDOWN 0x3UL + #define PORT_PHY_QCFG_RESP_MODULE_STATUS_NOTINSERTED 0x4UL + #define PORT_PHY_QCFG_RESP_MODULE_STATUS_NOTAPPLICABLE 0xffUL + __le32 preemphasis; + u8 phy_maj; + u8 phy_min; + u8 phy_bld; + u8 phy_type; + #define PORT_PHY_QCFG_RESP_PHY_TYPE_UNKNOWN 0x0UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASECR 0x1UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASEKR4 0x2UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASELR 0x3UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASESR 0x4UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASEKR2 0x5UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASEKX 0x6UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASEKR 0x7UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASET 0x8UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_BASETE 0x9UL + #define PORT_PHY_QCFG_RESP_PHY_TYPE_SGMIIEXTPHY 0xaUL + u8 media_type; + #define PORT_PHY_QCFG_RESP_MEDIA_TYPE_UNKNOWN 0x0UL + #define PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP 0x1UL + #define PORT_PHY_QCFG_RESP_MEDIA_TYPE_DAC 0x2UL + #define PORT_PHY_QCFG_RESP_MEDIA_TYPE_FIBRE 0x3UL + u8 xcvr_pkg_type; + #define PORT_PHY_QCFG_RESP_XCVR_PKG_TYPE_XCVR_INTERNAL 0x1UL + #define PORT_PHY_QCFG_RESP_XCVR_PKG_TYPE_XCVR_EXTERNAL 0x2UL + u8 eee_config_phy_addr; + #define PORT_PHY_QCFG_RESP_PHY_ADDR_MASK 0x1fUL + #define PORT_PHY_QCFG_RESP_PHY_ADDR_SFT 0 + #define PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_ENABLED 0x20UL + #define PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_ACTIVE 0x40UL + #define PORT_PHY_QCFG_RESP_EEE_CONFIG_EEE_TX_LPI 0x80UL + #define PORT_PHY_QCFG_RESP_EEE_CONFIG_MASK 0xe0UL + #define PORT_PHY_QCFG_RESP_EEE_CONFIG_SFT 5 + u8 parallel_detect; + #define PORT_PHY_QCFG_RESP_PARALLEL_DETECT 0x1UL + #define PORT_PHY_QCFG_RESP_RESERVED_MASK 0xfeUL + #define PORT_PHY_QCFG_RESP_RESERVED_SFT 1 + __le16 link_partner_adv_speeds; + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_100MBHD 0x1UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_100MB 0x2UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_1GBHD 0x4UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_1GB 0x8UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_2GB 0x10UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_2_5GB 0x20UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_10GB 0x40UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_20GB 0x80UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_25GB 0x100UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_40GB 0x200UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_50GB 0x400UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_100GB 0x800UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_10MBHD 0x1000UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_SPEEDS_10MB 0x2000UL + u8 link_partner_adv_auto_mode; + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_AUTO_MODE_NONE 0x0UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_AUTO_MODE_ALL_SPEEDS 0x1UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_AUTO_MODE_ONE_SPEED 0x2UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_AUTO_MODE_ONE_OR_BELOW 0x3UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_AUTO_MODE_SPEED_MASK 0x4UL + u8 link_partner_adv_pause; + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_PAUSE_TX 0x1UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_PAUSE_RX 0x2UL + __le16 adv_eee_link_speed_mask; + #define PORT_PHY_QCFG_RESP_ADV_EEE_LINK_SPEED_MASK_RSVD1 0x1UL + #define PORT_PHY_QCFG_RESP_ADV_EEE_LINK_SPEED_MASK_100MB 0x2UL + #define PORT_PHY_QCFG_RESP_ADV_EEE_LINK_SPEED_MASK_RSVD2 0x4UL + #define PORT_PHY_QCFG_RESP_ADV_EEE_LINK_SPEED_MASK_1GB 0x8UL + #define PORT_PHY_QCFG_RESP_ADV_EEE_LINK_SPEED_MASK_RSVD3 0x10UL + #define PORT_PHY_QCFG_RESP_ADV_EEE_LINK_SPEED_MASK_RSVD4 0x20UL + #define PORT_PHY_QCFG_RESP_ADV_EEE_LINK_SPEED_MASK_10GB 0x40UL + __le16 link_partner_adv_eee_link_speed_mask; + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD1 0x1UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_100MB 0x2UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD2 0x4UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_1GB 0x8UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD3 0x10UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_RSVD4 0x20UL + #define PORT_PHY_QCFG_RESP_LINK_PARTNER_ADV_EEE_LINK_SPEED_MASK_10GB 0x40UL + __le32 xcvr_identifier_type_tx_lpi_timer; + #define PORT_PHY_QCFG_RESP_TX_LPI_TIMER_MASK 0xffffffUL + #define PORT_PHY_QCFG_RESP_TX_LPI_TIMER_SFT 0 + #define PORT_PHY_QCFG_RESP_XCVR_IDENTIFIER_TYPE_MASK 0xff000000UL + #define PORT_PHY_QCFG_RESP_XCVR_IDENTIFIER_TYPE_SFT 24 + #define PORT_PHY_QCFG_RESP_XCVR_IDENTIFIER_TYPE_UNKNOWN (0x0UL << 24) + #define PORT_PHY_QCFG_RESP_XCVR_IDENTIFIER_TYPE_SFP (0x3UL << 24) + #define PORT_PHY_QCFG_RESP_XCVR_IDENTIFIER_TYPE_QSFP (0xcUL << 24) + #define PORT_PHY_QCFG_RESP_XCVR_IDENTIFIER_TYPE_QSFPPLUS (0xdUL << 24) + #define PORT_PHY_QCFG_RESP_XCVR_IDENTIFIER_TYPE_QSFP28 (0x11UL << 24) + __le16 fec_cfg; + #define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_NONE_SUPPORTED 0x1UL + #define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_SUPPORTED 0x2UL + #define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_AUTONEG_ENABLED 0x4UL + #define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_SUPPORTED 0x8UL + #define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED 0x10UL + #define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_SUPPORTED 0x20UL + #define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED 0x40UL + u8 unused_1; + u8 unused_2; + char phy_vendor_name[16]; + char phy_vendor_partnumber[16]; + __le32 unused_3; + u8 unused_4; + u8 unused_5; + u8 unused_6; + u8 valid; +}; +/* hwrm_port_qstats */ +/* Input (40 bytes) */ +struct hwrm_port_qstats_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 port_id; + u8 unused_0; + u8 unused_1; + u8 unused_2[3]; + u8 unused_3; + __le64 tx_stat_host_addr; + __le64 rx_stat_host_addr; +}; + +/* Output (16 bytes) */ +struct hwrm_port_qstats_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le16 tx_stat_size; + __le16 rx_stat_size; + u8 unused_0; + u8 unused_1; + u8 unused_2; + u8 valid; +}; + +/* hwrm_port_phy_qcaps */ +/* Input (24 bytes) */ +struct hwrm_port_phy_qcaps_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 port_id; + __le16 unused_0[3]; +}; + +/* Output (24 bytes) */ +struct hwrm_port_phy_qcaps_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 eee_supported; + #define PORT_PHY_QCAPS_RESP_EEE_SUPPORTED 0x1UL + #define PORT_PHY_QCAPS_RESP_RSVD1_MASK 0xfeUL + #define PORT_PHY_QCAPS_RESP_RSVD1_SFT 1 + u8 unused_0; + __le16 supported_speeds_force_mode; + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_100MBHD 0x1UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_100MB 0x2UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_1GBHD 0x4UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_1GB 0x8UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_2GB 0x10UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_2_5GB 0x20UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_10GB 0x40UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_20GB 0x80UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_25GB 0x100UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_40GB 0x200UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_50GB 0x400UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_100GB 0x800UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_10MBHD 0x1000UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_FORCE_MODE_10MB 0x2000UL + __le16 supported_speeds_auto_mode; + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_100MBHD 0x1UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_100MB 0x2UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_1GBHD 0x4UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_1GB 0x8UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_2GB 0x10UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_2_5GB 0x20UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_10GB 0x40UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_20GB 0x80UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_25GB 0x100UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_40GB 0x200UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_50GB 0x400UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_100GB 0x800UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_10MBHD 0x1000UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_AUTO_MODE_10MB 0x2000UL + __le16 supported_speeds_eee_mode; + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_EEE_MODE_RSVD1 0x1UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_EEE_MODE_100MB 0x2UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_EEE_MODE_RSVD2 0x4UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_EEE_MODE_1GB 0x8UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_EEE_MODE_RSVD3 0x10UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_EEE_MODE_RSVD4 0x20UL + #define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS_EEE_MODE_10GB 0x40UL + __le32 tx_lpi_timer_low; + #define PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_LOW_MASK 0xffffffUL + #define PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_LOW_SFT 0 + #define PORT_PHY_QCAPS_RESP_RSVD2_MASK 0xff000000UL + #define PORT_PHY_QCAPS_RESP_RSVD2_SFT 24 + __le32 valid_tx_lpi_timer_high; + #define PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_MASK 0xffffffUL + #define PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_SFT 0 + #define PORT_PHY_QCAPS_RESP_VALID_MASK 0xff000000UL + #define PORT_PHY_QCAPS_RESP_VALID_SFT 24 +}; + +/* hwrm_queue_qportcfg */ +/* Input (24 bytes) */ +struct hwrm_queue_qportcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define QUEUE_QPORTCFG_REQ_FLAGS_PATH 0x1UL + #define QUEUE_QPORTCFG_REQ_FLAGS_PATH_TX 0x0UL + #define QUEUE_QPORTCFG_REQ_FLAGS_PATH_RX 0x1UL + #define QUEUE_QPORTCFG_REQ_FLAGS_PATH_LAST QUEUE_QPORTCFG_REQ_FLAGS_PATH_RX + __le16 port_id; + __le16 unused_0; +}; + +/* Output (32 bytes) */ +struct hwrm_queue_qportcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 max_configurable_queues; + u8 max_configurable_lossless_queues; + u8 queue_cfg_allowed; + u8 queue_cfg_info; + #define QUEUE_QPORTCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG 0x1UL + u8 queue_pfcenable_cfg_allowed; + u8 queue_pri2cos_cfg_allowed; + u8 queue_cos2bw_cfg_allowed; + u8 queue_id0; + u8 queue_id0_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID0_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID0_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID0_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_id1; + u8 queue_id1_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID1_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID1_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID1_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_id2; + u8 queue_id2_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID2_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID2_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID2_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_id3; + u8 queue_id3_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID3_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID3_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID3_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_id4; + u8 queue_id4_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID4_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID4_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID4_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_id5; + u8 queue_id5_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID5_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID5_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID5_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_id6; + u8 queue_id6_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID6_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID6_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID6_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_id7; + u8 queue_id7_service_profile; + #define QUEUE_QPORTCFG_RESP_QUEUE_ID7_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID7_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QPORTCFG_RESP_QUEUE_ID7_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 valid; +}; + +/* hwrm_queue_qcfg */ +/* Input (24 bytes) */ +struct hwrm_queue_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define QUEUE_QCFG_REQ_FLAGS_PATH 0x1UL + #define QUEUE_QCFG_REQ_FLAGS_PATH_TX 0x0UL + #define QUEUE_QCFG_REQ_FLAGS_PATH_RX 0x1UL + #define QUEUE_QCFG_REQ_FLAGS_PATH_LAST QUEUE_QCFG_REQ_FLAGS_PATH_RX + __le32 queue_id; +}; + +/* Output (16 bytes) */ +struct hwrm_queue_qcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 queue_len; + u8 service_profile; + #define QUEUE_QCFG_RESP_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_QCFG_RESP_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_QCFG_RESP_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 queue_cfg_info; + #define QUEUE_QCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG 0x1UL + u8 unused_0; + u8 valid; +}; + +/* hwrm_queue_cfg */ +/* Input (40 bytes) */ +struct hwrm_queue_cfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define QUEUE_CFG_REQ_FLAGS_PATH_MASK 0x3UL + #define QUEUE_CFG_REQ_FLAGS_PATH_SFT 0 + #define QUEUE_CFG_REQ_FLAGS_PATH_TX 0x0UL + #define QUEUE_CFG_REQ_FLAGS_PATH_RX 0x1UL + #define QUEUE_CFG_REQ_FLAGS_PATH_BIDIR 0x2UL + #define QUEUE_CFG_REQ_FLAGS_PATH_LAST QUEUE_CFG_REQ_FLAGS_PATH_BIDIR + __le32 enables; + #define QUEUE_CFG_REQ_ENABLES_DFLT_LEN 0x1UL + #define QUEUE_CFG_REQ_ENABLES_SERVICE_PROFILE 0x2UL + __le32 queue_id; + __le32 dflt_len; + u8 service_profile; + #define QUEUE_CFG_REQ_SERVICE_PROFILE_LOSSY 0x0UL + #define QUEUE_CFG_REQ_SERVICE_PROFILE_LOSSLESS 0x1UL + #define QUEUE_CFG_REQ_SERVICE_PROFILE_UNKNOWN 0xffUL + u8 unused_0[7]; +}; + +/* Output (16 bytes) */ +struct hwrm_queue_cfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_queue_pfcenable_qcfg */ +/* Input (24 bytes) */ +struct hwrm_queue_pfcenable_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 port_id; + __le16 unused_0[3]; +}; + +/* Output (16 bytes) */ +struct hwrm_queue_pfcenable_qcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 flags; + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI0_PFC_ENABLED 0x1UL + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI1_PFC_ENABLED 0x2UL + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI2_PFC_ENABLED 0x4UL + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI3_PFC_ENABLED 0x8UL + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI4_PFC_ENABLED 0x10UL + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI5_PFC_ENABLED 0x20UL + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI6_PFC_ENABLED 0x40UL + #define QUEUE_PFCENABLE_QCFG_RESP_FLAGS_PRI7_PFC_ENABLED 0x80UL + u8 unused_0; + u8 unused_1; + u8 unused_2; + u8 valid; +}; + +/* hwrm_queue_pfcenable_cfg */ +/* Input (24 bytes) */ +struct hwrm_queue_pfcenable_cfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI0_PFC_ENABLED 0x1UL + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI1_PFC_ENABLED 0x2UL + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI2_PFC_ENABLED 0x4UL + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI3_PFC_ENABLED 0x8UL + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI4_PFC_ENABLED 0x10UL + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI5_PFC_ENABLED 0x20UL + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI6_PFC_ENABLED 0x40UL + #define QUEUE_PFCENABLE_CFG_REQ_FLAGS_PRI7_PFC_ENABLED 0x80UL + __le16 port_id; + __le16 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_queue_pfcenable_cfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_queue_pri2cos_qcfg */ +/* Input (24 bytes) */ +struct hwrm_queue_pri2cos_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define QUEUE_PRI2COS_QCFG_REQ_FLAGS_PATH 0x1UL + #define QUEUE_PRI2COS_QCFG_REQ_FLAGS_PATH_TX (0x0UL << 0) + #define QUEUE_PRI2COS_QCFG_REQ_FLAGS_PATH_RX (0x1UL << 0) + #define QUEUE_PRI2COS_QCFG_REQ_FLAGS_PATH_LAST QUEUE_PRI2COS_QCFG_REQ_FLAGS_PATH_RX + #define QUEUE_PRI2COS_QCFG_REQ_FLAGS_IVLAN 0x2UL + u8 port_id; + u8 unused_0[3]; +}; + +/* Output (24 bytes) */ +struct hwrm_queue_pri2cos_qcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 pri0_cos_queue_id; + u8 pri1_cos_queue_id; + u8 pri2_cos_queue_id; + u8 pri3_cos_queue_id; + u8 pri4_cos_queue_id; + u8 pri5_cos_queue_id; + u8 pri6_cos_queue_id; + u8 pri7_cos_queue_id; + u8 queue_cfg_info; + #define QUEUE_PRI2COS_QCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG 0x1UL + u8 unused_0; + __le16 unused_1; + u8 unused_2; + u8 unused_3; + u8 unused_4; + u8 valid; +}; + +/* hwrm_queue_pri2cos_cfg */ +/* Input (40 bytes) */ +struct hwrm_queue_pri2cos_cfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define QUEUE_PRI2COS_CFG_REQ_FLAGS_PATH_MASK 0x3UL + #define QUEUE_PRI2COS_CFG_REQ_FLAGS_PATH_SFT 0 + #define QUEUE_PRI2COS_CFG_REQ_FLAGS_PATH_TX (0x0UL << 0) + #define QUEUE_PRI2COS_CFG_REQ_FLAGS_PATH_RX (0x1UL << 0) + #define QUEUE_PRI2COS_CFG_REQ_FLAGS_PATH_BIDIR (0x2UL << 0) + #define QUEUE_PRI2COS_CFG_REQ_FLAGS_PATH_LAST QUEUE_PRI2COS_CFG_REQ_FLAGS_PATH_BIDIR + #define QUEUE_PRI2COS_CFG_REQ_FLAGS_IVLAN 0x4UL + __le32 enables; + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI0_COS_QUEUE_ID 0x1UL + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI1_COS_QUEUE_ID 0x2UL + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI2_COS_QUEUE_ID 0x4UL + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI3_COS_QUEUE_ID 0x8UL + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI4_COS_QUEUE_ID 0x10UL + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI5_COS_QUEUE_ID 0x20UL + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI6_COS_QUEUE_ID 0x40UL + #define QUEUE_PRI2COS_CFG_REQ_ENABLES_PRI7_COS_QUEUE_ID 0x80UL + u8 port_id; + u8 pri0_cos_queue_id; + u8 pri1_cos_queue_id; + u8 pri2_cos_queue_id; + u8 pri3_cos_queue_id; + u8 pri4_cos_queue_id; + u8 pri5_cos_queue_id; + u8 pri6_cos_queue_id; + u8 pri7_cos_queue_id; + u8 unused_0[7]; +}; + +/* Output (16 bytes) */ +struct hwrm_queue_pri2cos_cfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_queue_cos2bw_qcfg */ +/* Input (24 bytes) */ +struct hwrm_queue_cos2bw_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 port_id; + __le16 unused_0[3]; +}; + +/* Output (112 bytes) */ +struct hwrm_queue_cos2bw_qcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 queue_id0; + u8 unused_0; + __le16 unused_1; + __le32 queue_id0_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id0_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id0_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID0_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id0_pri_lvl; + u8 queue_id0_bw_weight; + u8 queue_id1; + __le32 queue_id1_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id1_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id1_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID1_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id1_pri_lvl; + u8 queue_id1_bw_weight; + u8 queue_id2; + __le32 queue_id2_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id2_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id2_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID2_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id2_pri_lvl; + u8 queue_id2_bw_weight; + u8 queue_id3; + __le32 queue_id3_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id3_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id3_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID3_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id3_pri_lvl; + u8 queue_id3_bw_weight; + u8 queue_id4; + __le32 queue_id4_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id4_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id4_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID4_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id4_pri_lvl; + u8 queue_id4_bw_weight; + u8 queue_id5; + __le32 queue_id5_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id5_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id5_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID5_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id5_pri_lvl; + u8 queue_id5_bw_weight; + u8 queue_id6; + __le32 queue_id6_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id6_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id6_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID6_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id6_pri_lvl; + u8 queue_id6_bw_weight; + u8 queue_id7; + __le32 queue_id7_min_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id7_max_bw; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id7_tsa_assign; + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_QCFG_RESP_QUEUE_ID7_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id7_pri_lvl; + u8 queue_id7_bw_weight; + u8 unused_2; + u8 unused_3; + u8 unused_4; + u8 unused_5; + u8 valid; +}; + +/* hwrm_queue_cos2bw_cfg */ +/* Input (128 bytes) */ +struct hwrm_queue_cos2bw_cfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + __le32 enables; + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID0_VALID 0x1UL + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID1_VALID 0x2UL + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID2_VALID 0x4UL + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID3_VALID 0x8UL + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID4_VALID 0x10UL + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID5_VALID 0x20UL + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID6_VALID 0x40UL + #define QUEUE_COS2BW_CFG_REQ_ENABLES_COS_QUEUE_ID7_VALID 0x80UL + __le16 port_id; + u8 queue_id0; + u8 unused_0; + __le32 queue_id0_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id0_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id0_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID0_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id0_pri_lvl; + u8 queue_id0_bw_weight; + u8 queue_id1; + __le32 queue_id1_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id1_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id1_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID1_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id1_pri_lvl; + u8 queue_id1_bw_weight; + u8 queue_id2; + __le32 queue_id2_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id2_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id2_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID2_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id2_pri_lvl; + u8 queue_id2_bw_weight; + u8 queue_id3; + __le32 queue_id3_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id3_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id3_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID3_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id3_pri_lvl; + u8 queue_id3_bw_weight; + u8 queue_id4; + __le32 queue_id4_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id4_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id4_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID4_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id4_pri_lvl; + u8 queue_id4_bw_weight; + u8 queue_id5; + __le32 queue_id5_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id5_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id5_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID5_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id5_pri_lvl; + u8 queue_id5_bw_weight; + u8 queue_id6; + __le32 queue_id6_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id6_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id6_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID6_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id6_pri_lvl; + u8 queue_id6_bw_weight; + u8 queue_id7; + __le32 queue_id7_min_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MIN_BW_BW_VALUE_UNIT_INVALID + __le32 queue_id7_max_bw; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_SFT 0 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_RSVD 0x10000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_LAST QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_MAX_BW_BW_VALUE_UNIT_INVALID + u8 queue_id7_tsa_assign; + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_TSA_ASSIGN_SP 0x0UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_TSA_ASSIGN_ETS 0x1UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_TSA_ASSIGN_RESERVED_FIRST 0x2UL + #define QUEUE_COS2BW_CFG_REQ_QUEUE_ID7_TSA_ASSIGN_RESERVED_LAST 0xffUL + u8 queue_id7_pri_lvl; + u8 queue_id7_bw_weight; + u8 unused_1[5]; +}; + +/* Output (16 bytes) */ +struct hwrm_queue_cos2bw_cfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_vnic_alloc */ +/* Input (24 bytes) */ +struct hwrm_vnic_alloc_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define VNIC_ALLOC_REQ_FLAGS_DEFAULT 0x1UL + __le32 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_vnic_alloc_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 vnic_id; + u8 unused_0; + u8 unused_1; + u8 unused_2; + u8 valid; +}; + +/* hwrm_vnic_free */ +/* Input (24 bytes) */ +struct hwrm_vnic_free_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 vnic_id; + __le32 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_vnic_free_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_vnic_cfg */ +/* Input (40 bytes) */ +struct hwrm_vnic_cfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 flags; + #define VNIC_CFG_REQ_FLAGS_DEFAULT 0x1UL + #define VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE 0x2UL + #define VNIC_CFG_REQ_FLAGS_BD_STALL_MODE 0x4UL + #define VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE 0x8UL + #define VNIC_CFG_REQ_FLAGS_ROCE_ONLY_VNIC_MODE 0x10UL + #define VNIC_CFG_REQ_FLAGS_RSS_DFLT_CR_MODE 0x20UL + __le32 enables; + #define VNIC_CFG_REQ_ENABLES_DFLT_RING_GRP 0x1UL + #define VNIC_CFG_REQ_ENABLES_RSS_RULE 0x2UL + #define VNIC_CFG_REQ_ENABLES_COS_RULE 0x4UL + #define VNIC_CFG_REQ_ENABLES_LB_RULE 0x8UL + #define VNIC_CFG_REQ_ENABLES_MRU 0x10UL + __le16 vnic_id; + __le16 dflt_ring_grp; + __le16 rss_rule; + __le16 cos_rule; + __le16 lb_rule; + __le16 mru; + __le32 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_vnic_cfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_vnic_qcfg */ +/* Input (32 bytes) */ +struct hwrm_vnic_qcfg_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 enables; + #define VNIC_QCFG_REQ_ENABLES_VF_ID_VALID 0x1UL + __le32 vnic_id; + __le16 vf_id; + __le16 unused_0[3]; +}; + +/* Output (32 bytes) */ +struct hwrm_vnic_qcfg_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le16 dflt_ring_grp; + __le16 rss_rule; + __le16 cos_rule; + __le16 lb_rule; + __le16 mru; + u8 unused_0; + u8 unused_1; + __le32 flags; + #define VNIC_QCFG_RESP_FLAGS_DEFAULT 0x1UL + #define VNIC_QCFG_RESP_FLAGS_VLAN_STRIP_MODE 0x2UL + #define VNIC_QCFG_RESP_FLAGS_BD_STALL_MODE 0x4UL + #define VNIC_QCFG_RESP_FLAGS_ROCE_DUAL_VNIC_MODE 0x8UL + #define VNIC_QCFG_RESP_FLAGS_ROCE_ONLY_VNIC_MODE 0x10UL + #define VNIC_QCFG_RESP_FLAGS_RSS_DFLT_CR_MODE 0x20UL + __le32 unused_2; + u8 unused_3; + u8 unused_4; + u8 unused_5; + u8 valid; +}; + +/* hwrm_vnic_qcaps */ +/* Input (24 bytes) */ +struct hwrm_vnic_qcaps_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 enables; + __le32 unused_0; +}; + +/* Output (24 bytes) */ +struct hwrm_vnic_qcaps_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le16 mru; + u8 unused_0; + u8 unused_1; + __le32 flags; + #define VNIC_QCAPS_RESP_FLAGS_VLAN_STRIP_CAP 0x2UL + #define VNIC_QCAPS_RESP_FLAGS_BD_STALL_CAP 0x4UL + #define VNIC_QCAPS_RESP_FLAGS_ROCE_DUAL_VNIC_CAP 0x8UL + #define VNIC_QCAPS_RESP_FLAGS_ROCE_ONLY_VNIC_CAP 0x10UL + #define VNIC_QCAPS_RESP_FLAGS_RSS_DFLT_CR_CAP 0x20UL + __le32 unused_2; + u8 unused_3; + u8 unused_4; + u8 unused_5; + u8 valid; +}; + +/* hwrm_ring_alloc */ +/* Input (80 bytes) */ +struct hwrm_ring_alloc_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 enables; + #define RING_ALLOC_REQ_ENABLES_RESERVED1 0x1UL + #define RING_ALLOC_REQ_ENABLES_RING_ARB_CFG 0x2UL + #define RING_ALLOC_REQ_ENABLES_RESERVED3 0x4UL + #define RING_ALLOC_REQ_ENABLES_STAT_CTX_ID_VALID 0x8UL + #define RING_ALLOC_REQ_ENABLES_RESERVED4 0x10UL + #define RING_ALLOC_REQ_ENABLES_MAX_BW_VALID 0x20UL + u8 ring_type; + #define RING_ALLOC_REQ_RING_TYPE_CMPL 0x0UL + #define RING_ALLOC_REQ_RING_TYPE_TX 0x1UL + #define RING_ALLOC_REQ_RING_TYPE_RX 0x2UL + u8 unused_0; + __le16 unused_1; + __le64 page_tbl_addr; + __le32 fbo; + u8 page_size; + u8 page_tbl_depth; + u8 unused_2; + u8 unused_3; + __le32 length; + __le16 logical_id; + __le16 cmpl_ring_id; + __le16 queue_id; + u8 unused_4; + u8 unused_5; + __le32 reserved1; + __le16 ring_arb_cfg; + #define RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_MASK 0xfUL + #define RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_SFT 0 + #define RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_SP (0x1UL << 0) + #define RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_WFQ (0x2UL << 0) + #define RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_LAST RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_WFQ + #define RING_ALLOC_REQ_RING_ARB_CFG_RSVD_MASK 0xf0UL + #define RING_ALLOC_REQ_RING_ARB_CFG_RSVD_SFT 4 + #define RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_PARAM_MASK 0xff00UL + #define RING_ALLOC_REQ_RING_ARB_CFG_ARB_POLICY_PARAM_SFT 8 + u8 unused_6; + u8 unused_7; + __le32 reserved3; + __le32 stat_ctx_id; + __le32 reserved4; + __le32 max_bw; + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_MASK 0xfffffffUL + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_SFT 0 + #define RING_ALLOC_REQ_MAX_BW_RSVD 0x10000000UL + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_UNIT_MASK 0xe0000000UL + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_UNIT_SFT 29 + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_UNIT_MBPS (0x0UL << 29) + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_UNIT_PERCENT1_100 (0x1UL << 29) + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_UNIT_INVALID (0x7UL << 29) + #define RING_ALLOC_REQ_MAX_BW_BW_VALUE_UNIT_LAST RING_ALLOC_REQ_MAX_BW_BW_VALUE_UNIT_INVALID + u8 int_mode; + #define RING_ALLOC_REQ_INT_MODE_LEGACY 0x0UL + #define RING_ALLOC_REQ_INT_MODE_RSVD 0x1UL + #define RING_ALLOC_REQ_INT_MODE_MSIX 0x2UL + #define RING_ALLOC_REQ_INT_MODE_POLL 0x3UL + u8 unused_8[3]; +}; + +/* Output (16 bytes) */ +struct hwrm_ring_alloc_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le16 ring_id; + __le16 logical_ring_id; + u8 unused_0; + u8 unused_1; + u8 unused_2; + u8 valid; +}; + +/* hwrm_ring_free */ +/* Input (24 bytes) */ +struct hwrm_ring_free_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + u8 ring_type; + #define RING_FREE_REQ_RING_TYPE_CMPL 0x0UL + #define RING_FREE_REQ_RING_TYPE_TX 0x1UL + #define RING_FREE_REQ_RING_TYPE_RX 0x2UL + u8 unused_0; + __le16 ring_id; + __le32 unused_1; +}; + +/* Output (16 bytes) */ +struct hwrm_ring_free_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_stat_ctx_alloc */ +/* Input (32 bytes) */ +struct hwrm_stat_ctx_alloc_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le64 stats_dma_addr; + __le32 update_period_ms; + __le32 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_stat_ctx_alloc_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 stat_ctx_id; + u8 unused_0; + u8 unused_1; + u8 unused_2; + u8 valid; +}; + +/* hwrm_stat_ctx_free */ +/* Input (24 bytes) */ +struct hwrm_stat_ctx_free_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 stat_ctx_id; + __le32 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_stat_ctx_free_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 stat_ctx_id; + u8 unused_0; + u8 unused_1; + u8 unused_2; + u8 valid; +}; + +/* hwrm_stat_ctx_query */ +/* Input (24 bytes) */ +struct hwrm_stat_ctx_query_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 stat_ctx_id; + __le32 unused_0; +}; + +/* Output (176 bytes) */ +struct hwrm_stat_ctx_query_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le64 tx_ucast_pkts; + __le64 tx_mcast_pkts; + __le64 tx_bcast_pkts; + __le64 tx_err_pkts; + __le64 tx_drop_pkts; + __le64 tx_ucast_bytes; + __le64 tx_mcast_bytes; + __le64 tx_bcast_bytes; + __le64 rx_ucast_pkts; + __le64 rx_mcast_pkts; + __le64 rx_bcast_pkts; + __le64 rx_err_pkts; + __le64 rx_drop_pkts; + __le64 rx_ucast_bytes; + __le64 rx_mcast_bytes; + __le64 rx_bcast_bytes; + __le64 rx_agg_pkts; + __le64 rx_agg_bytes; + __le64 rx_agg_events; + __le64 rx_agg_aborts; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_fw_qstatus */ +/* Input (24 bytes) */ +struct hwrm_fw_qstatus_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + u8 embedded_proc_type; + #define FW_QSTATUS_REQ_EMBEDDED_PROC_TYPE_BOOT 0x0UL + #define FW_QSTATUS_REQ_EMBEDDED_PROC_TYPE_MGMT 0x1UL + #define FW_QSTATUS_REQ_EMBEDDED_PROC_TYPE_NETCTRL 0x2UL + #define FW_QSTATUS_REQ_EMBEDDED_PROC_TYPE_ROCE 0x3UL + #define FW_QSTATUS_REQ_EMBEDDED_PROC_TYPE_RSVD 0x4UL + u8 unused_0[7]; +}; + +/* Output (16 bytes) */ +struct hwrm_fw_qstatus_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 selfrst_status; + #define FW_QSTATUS_RESP_SELFRST_STATUS_SELFRSTNONE 0x0UL + #define FW_QSTATUS_RESP_SELFRST_STATUS_SELFRSTASAP 0x1UL + #define FW_QSTATUS_RESP_SELFRST_STATUS_SELFRSTPCIERST 0x2UL + u8 unused_0; + __le16 unused_1; + u8 unused_2; + u8 unused_3; + u8 unused_4; + u8 valid; +}; +/* hwrm_fw_set_structured_data */ +/* Input (32 bytes) */ +struct hwrm_fw_set_structured_data_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le64 src_data_addr; + __le16 data_len; + u8 hdr_cnt; + u8 unused_0[5]; +}; + +/* Output (16 bytes) */ +struct hwrm_fw_set_structured_data_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_fw_get_structured_data */ +/* Input (32 bytes) */ +struct hwrm_fw_get_structured_data_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le64 dest_data_addr; + __le16 data_len; + __le16 structure_id; + __le16 subtype; + #define FW_GET_STRUCTURED_DATA_REQ_SUBTYPE_ALL 0xffffUL + #define FW_GET_STRUCTURED_DATA_REQ_SUBTYPE_NEAR_BRIDGE_ADMIN 0x100UL + #define FW_GET_STRUCTURED_DATA_REQ_SUBTYPE_NEAR_BRIDGE_PEER 0x101UL + #define FW_GET_STRUCTURED_DATA_REQ_SUBTYPE_NEAR_BRIDGE_OPERATIONAL 0x102UL + #define FW_GET_STRUCTURED_DATA_REQ_SUBTYPE_NON_TPMR_ADMIN 0x200UL + #define FW_GET_STRUCTURED_DATA_REQ_SUBTYPE_NON_TPMR_PEER 0x201UL + #define FW_GET_STRUCTURED_DATA_REQ_SUBTYPE_NON_TPMR_OPERATIONAL 0x202UL + u8 count; + u8 unused_0; +}; + +/* Output (16 bytes) */ +struct hwrm_fw_get_structured_data_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + u8 hdr_cnt; + u8 unused_0; + __le16 unused_1; + u8 unused_2; + u8 unused_3; + u8 unused_4; + u8 valid; +}; + +/* hwrm_exec_fwd_resp */ +/* Input (128 bytes) */ +struct hwrm_exec_fwd_resp_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 encap_request[26]; + __le16 encap_resp_target_id; + __le16 unused_0[3]; +}; + +/* Output (16 bytes) */ +struct hwrm_exec_fwd_resp_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_reject_fwd_resp */ +/* Input (128 bytes) */ +struct hwrm_reject_fwd_resp_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le32 encap_request[26]; + __le16 encap_resp_target_id; + __le16 unused_0[3]; +}; + +/* Output (16 bytes) */ +struct hwrm_reject_fwd_resp_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_fwd_resp */ +/* Input (40 bytes) */ +struct hwrm_fwd_resp_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 encap_resp_target_id; + __le16 encap_resp_cmpl_ring; + __le16 encap_resp_len; + u8 unused_0; + u8 unused_1; + __le64 encap_resp_addr; + __le32 encap_resp[24]; +}; + +/* Output (16 bytes) */ +struct hwrm_fwd_resp_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* hwrm_fwd_async_event_cmpl */ +/* Input (32 bytes) */ +struct hwrm_fwd_async_event_cmpl_input { + __le16 req_type; + __le16 cmpl_ring; + __le16 seq_id; + __le16 target_id; + __le64 resp_addr; + __le16 encap_async_event_target_id; + u8 unused_0; + u8 unused_1; + u8 unused_2[3]; + u8 unused_3; + __le32 encap_async_event_cmpl[4]; +}; + +/* Output (16 bytes) */ +struct hwrm_fwd_async_event_cmpl_output { + __le16 error_code; + __le16 req_type; + __le16 seq_id; + __le16 resp_len; + __le32 unused_0; + u8 unused_1; + u8 unused_2; + u8 unused_3; + u8 valid; +}; + +/* Doorbell Structures */ +/* 64b Doorbell Format (8 bytes) */ +struct dbr_dbr { + __le32 index; + #define DBR_DBR_INDEX_MASK 0xfffffUL + #define DBR_DBR_INDEX_SFT 0 + #define DBR_DBR_RESERVED12_MASK 0xfff00000UL + #define DBR_DBR_RESERVED12_SFT 20 + __le32 type_xid; + #define DBR_DBR_XID_MASK 0xfffffUL + #define DBR_DBR_XID_SFT 0 + #define DBR_DBR_RESERVED8_MASK 0xff00000UL + #define DBR_DBR_RESERVED8_SFT 20 + #define DBR_DBR_TYPE_MASK 0xf0000000UL + #define DBR_DBR_TYPE_SFT 28 + #define DBR_DBR_TYPE_SQ (0x0UL << 28) + #define DBR_DBR_TYPE_RQ (0x1UL << 28) + #define DBR_DBR_TYPE_SRQ (0x2UL << 28) + #define DBR_DBR_TYPE_SRQ_ARM (0x3UL << 28) + #define DBR_DBR_TYPE_CQ (0x4UL << 28) + #define DBR_DBR_TYPE_CQ_ARMSE (0x5UL << 28) + #define DBR_DBR_TYPE_CQ_ARMALL (0x6UL << 28) + #define DBR_DBR_TYPE_CQ_ARMENA (0x7UL << 28) + #define DBR_DBR_TYPE_SRQ_ARMENA (0x8UL << 28) + #define DBR_DBR_TYPE_CQ_CUTOFF_ACK (0x9UL << 28) + #define DBR_DBR_TYPE_NULL (0xfUL << 28) +}; + +/* 32b Doorbell Format (4 bytes) */ +struct dbr_dbr32 { + __le32 type_abs_incr_xid; + #define DBR_DBR32_XID_MASK 0xfffffUL + #define DBR_DBR32_XID_SFT 0 + #define DBR_DBR32_RESERVED4_MASK 0xf00000UL + #define DBR_DBR32_RESERVED4_SFT 20 + #define DBR_DBR32_INCR_MASK 0xf000000UL + #define DBR_DBR32_INCR_SFT 24 + #define DBR_DBR32_ABS 0x10000000UL + #define DBR_DBR32_TYPE_MASK 0xe0000000UL + #define DBR_DBR32_TYPE_SFT 29 + #define DBR_DBR32_TYPE_SQ (0x0UL << 29) +}; + +/* SQ WQE Structures */ +/* Base SQ WQE (8 bytes) */ +struct sq_base { + u8 wqe_type; + #define SQ_BASE_WQE_TYPE_SEND 0x0UL + #define SQ_BASE_WQE_TYPE_SEND_W_IMMEAD 0x1UL + #define SQ_BASE_WQE_TYPE_SEND_W_INVALID 0x2UL + #define SQ_BASE_WQE_TYPE_WRITE_WQE 0x4UL + #define SQ_BASE_WQE_TYPE_WRITE_W_IMMEAD 0x5UL + #define SQ_BASE_WQE_TYPE_READ_WQE 0x6UL + #define SQ_BASE_WQE_TYPE_ATOMIC_CS 0x8UL + #define SQ_BASE_WQE_TYPE_ATOMIC_FA 0xbUL + #define SQ_BASE_WQE_TYPE_LOCAL_INVALID 0xcUL + #define SQ_BASE_WQE_TYPE_FR_PMR 0xdUL + #define SQ_BASE_WQE_TYPE_BIND 0xeUL + u8 unused_0[7]; +}; + +/* WQE SGE (16 bytes) */ +struct sq_sge { + __le64 va_or_pa; + __le32 l_key; + __le32 size; +}; + +/* PSN Search Structure (8 bytes) */ +struct sq_psn_search { + __le32 opcode_start_psn; + #define SQ_PSN_SEARCH_START_PSN_MASK 0xffffffUL + #define SQ_PSN_SEARCH_START_PSN_SFT 0 + #define SQ_PSN_SEARCH_OPCODE_MASK 0xff000000UL + #define SQ_PSN_SEARCH_OPCODE_SFT 24 + __le32 flags_next_psn; + #define SQ_PSN_SEARCH_NEXT_PSN_MASK 0xffffffUL + #define SQ_PSN_SEARCH_NEXT_PSN_SFT 0 + #define SQ_PSN_SEARCH_FLAGS_MASK 0xff000000UL + #define SQ_PSN_SEARCH_FLAGS_SFT 24 +}; + +/* Send SQ WQE (40 bytes) */ +struct sq_send { + u8 wqe_type; + #define SQ_SEND_WQE_TYPE_SEND 0x0UL + #define SQ_SEND_WQE_TYPE_SEND_W_IMMEAD 0x1UL + #define SQ_SEND_WQE_TYPE_SEND_W_INVALID 0x2UL + u8 flags; + #define SQ_SEND_FLAGS_SIGNAL_COMP 0x1UL + #define SQ_SEND_FLAGS_RD_OR_ATOMIC_FENCE 0x2UL + #define SQ_SEND_FLAGS_UC_FENCE 0x4UL + #define SQ_SEND_FLAGS_SE 0x8UL + #define SQ_SEND_FLAGS_INLINE 0x10UL + u8 wqe_size; + u8 reserved8_1; + __le32 inv_key_or_imm_data; + __le32 length; + __le32 q_key; + __le32 dst_qp; + #define SQ_SEND_DST_QP_MASK 0xffffffUL + #define SQ_SEND_DST_QP_SFT 0 + #define SQ_SEND_RESERVED8_2_MASK 0xff000000UL + #define SQ_SEND_RESERVED8_2_SFT 24 + __le32 avid; + #define SQ_SEND_AVID_MASK 0xfffffUL + #define SQ_SEND_AVID_SFT 0 + #define SQ_SEND_RESERVED_AVID_MASK 0xfff00000UL + #define SQ_SEND_RESERVED_AVID_SFT 20 + __le64 reserved64; + __le32 data[24]; +}; + +/* Send Raw Ethernet and QP1 SQ WQE (40 bytes) */ +struct sq_send_raweth_qp1 { + u8 wqe_type; + #define SQ_SEND_RAWETH_QP1_WQE_TYPE_SEND 0x0UL + u8 flags; + #define SQ_SEND_RAWETH_QP1_FLAGS_SIGNAL_COMP 0x1UL + #define SQ_SEND_RAWETH_QP1_FLAGS_RD_OR_ATOMIC_FENCE 0x2UL + #define SQ_SEND_RAWETH_QP1_FLAGS_UC_FENCE 0x4UL + #define SQ_SEND_RAWETH_QP1_FLAGS_SE 0x8UL + #define SQ_SEND_RAWETH_QP1_FLAGS_INLINE 0x10UL + u8 wqe_size; + u8 reserved8; + __le16 lflags; + #define SQ_SEND_RAWETH_QP1_LFLAGS_TCP_UDP_CHKSUM 0x1UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_IP_CHKSUM 0x2UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_NOCRC 0x4UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_STAMP 0x8UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_T_IP_CHKSUM 0x10UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_RESERVED1_1 0x20UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_RESERVED1_2 0x40UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_RESERVED1_3 0x80UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_ROCE_CRC 0x100UL + #define SQ_SEND_RAWETH_QP1_LFLAGS_FCOE_CRC 0x200UL + __le16 cfa_action; + __le32 length; + __le32 reserved32_1; + __le32 cfa_meta; + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_MASK 0xfffUL + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_SFT 0 + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_DE 0x1000UL + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_PRI_MASK 0xe000UL + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_PRI_SFT 13 + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_MASK 0x70000UL + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_SFT 16 + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID88A8 (0x0UL << 16) + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID8100 (0x1UL << 16) + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9100 (0x2UL << 16) + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9200 (0x3UL << 16) + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPID9300 (0x4UL << 16) + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPIDCFG (0x5UL << 16) + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_LAST SQ_SEND_RAWETH_QP1_CFA_META_VLAN_TPID_TPIDCFG + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_RESERVED_MASK 0xff80000UL + #define SQ_SEND_RAWETH_QP1_CFA_META_VLAN_RESERVED_SFT 19 + #define SQ_SEND_RAWETH_QP1_CFA_META_KEY_MASK 0xf0000000UL + #define SQ_SEND_RAWETH_QP1_CFA_META_KEY_SFT 28 + #define SQ_SEND_RAWETH_QP1_CFA_META_KEY_NONE (0x0UL << 28) + #define SQ_SEND_RAWETH_QP1_CFA_META_KEY_VLAN_TAG (0x1UL << 28) + #define SQ_SEND_RAWETH_QP1_CFA_META_KEY_LAST SQ_SEND_RAWETH_QP1_CFA_META_KEY_VLAN_TAG + __le32 reserved32_2; + __le64 reserved64; + __le32 data[24]; +}; + +/* RDMA SQ WQE (40 bytes) */ +struct sq_rdma { + u8 wqe_type; + #define SQ_RDMA_WQE_TYPE_WRITE_WQE 0x4UL + #define SQ_RDMA_WQE_TYPE_WRITE_W_IMMEAD 0x5UL + #define SQ_RDMA_WQE_TYPE_READ_WQE 0x6UL + u8 flags; + #define SQ_RDMA_FLAGS_SIGNAL_COMP 0x1UL + #define SQ_RDMA_FLAGS_RD_OR_ATOMIC_FENCE 0x2UL + #define SQ_RDMA_FLAGS_UC_FENCE 0x4UL + #define SQ_RDMA_FLAGS_SE 0x8UL + #define SQ_RDMA_FLAGS_INLINE 0x10UL + u8 wqe_size; + u8 reserved8; + __le32 imm_data; + __le32 length; + __le32 reserved32_1; + __le64 remote_va; + __le32 remote_key; + __le32 reserved32_2; + __le32 data[24]; +}; + +/* Atomic SQ WQE (40 bytes) */ +struct sq_atomic { + u8 wqe_type; + #define SQ_ATOMIC_WQE_TYPE_ATOMIC_CS 0x8UL + #define SQ_ATOMIC_WQE_TYPE_ATOMIC_FA 0xbUL + u8 flags; + #define SQ_ATOMIC_FLAGS_SIGNAL_COMP 0x1UL + #define SQ_ATOMIC_FLAGS_RD_OR_ATOMIC_FENCE 0x2UL + #define SQ_ATOMIC_FLAGS_UC_FENCE 0x4UL + #define SQ_ATOMIC_FLAGS_SE 0x8UL + #define SQ_ATOMIC_FLAGS_INLINE 0x10UL + __le16 reserved16; + __le32 remote_key; + __le64 remote_va; + __le64 swap_data; + __le64 cmp_data; + __le32 data[24]; +}; + +/* Local Invalidate SQ WQE (40 bytes) */ +struct sq_localinvalidate { + u8 wqe_type; + #define SQ_LOCALINVALIDATE_WQE_TYPE_LOCAL_INVALID 0xcUL + u8 flags; + #define SQ_LOCALINVALIDATE_FLAGS_SIGNAL_COMP 0x1UL + #define SQ_LOCALINVALIDATE_FLAGS_RD_OR_ATOMIC_FENCE 0x2UL + #define SQ_LOCALINVALIDATE_FLAGS_UC_FENCE 0x4UL + #define SQ_LOCALINVALIDATE_FLAGS_SE 0x8UL + #define SQ_LOCALINVALIDATE_FLAGS_INLINE 0x10UL + __le16 reserved16; + __le32 inv_l_key; + __le64 reserved64; + __le32 reserved128[4]; + __le32 data[24]; +}; + +/* FR-PMR SQ WQE (40 bytes) */ +struct sq_fr_pmr { + u8 wqe_type; + #define SQ_FR_PMR_WQE_TYPE_FR_PMR 0xdUL + u8 flags; + #define SQ_FR_PMR_FLAGS_SIGNAL_COMP 0x1UL + #define SQ_FR_PMR_FLAGS_RD_OR_ATOMIC_FENCE 0x2UL + #define SQ_FR_PMR_FLAGS_UC_FENCE 0x4UL + #define SQ_FR_PMR_FLAGS_SE 0x8UL + #define SQ_FR_PMR_FLAGS_INLINE 0x10UL + u8 access_cntl; + #define SQ_FR_PMR_ACCESS_CNTL_LOCAL_WRITE 0x1UL + #define SQ_FR_PMR_ACCESS_CNTL_REMOTE_READ 0x2UL + #define SQ_FR_PMR_ACCESS_CNTL_REMOTE_WRITE 0x4UL + #define SQ_FR_PMR_ACCESS_CNTL_REMOTE_ATOMIC 0x8UL + #define SQ_FR_PMR_ACCESS_CNTL_WINDOW_BIND 0x10UL + u8 zero_based_page_size_log; + #define SQ_FR_PMR_PAGE_SIZE_LOG_MASK 0x1fUL + #define SQ_FR_PMR_PAGE_SIZE_LOG_SFT 0 + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4K 0x0UL + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_8K 0x1UL + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_64K 0x4UL + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_256K 0x6UL + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1M 0x8UL + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_2M 0x9UL + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_4M 0xaUL + #define SQ_FR_PMR_PAGE_SIZE_LOG_PGSZ_1G 0x12UL + #define SQ_FR_PMR_ZERO_BASED 0x20UL + #define SQ_FR_PMR_RESERVED2_MASK 0xc0UL + #define SQ_FR_PMR_RESERVED2_SFT 6 + __le32 l_key; + u8 length[5]; + u8 reserved8_1; + u8 reserved8_2; + u8 numlevels_pbl_page_size_log; + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_MASK 0x1fUL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_SFT 0 + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4K 0x0UL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_8K 0x1UL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_64K 0x4UL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_256K 0x6UL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1M 0x8UL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_2M 0x9UL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_4M 0xaUL + #define SQ_FR_PMR_PBL_PAGE_SIZE_LOG_PGSZ_1G 0x12UL + #define SQ_FR_PMR_RESERVED1 0x20UL + #define SQ_FR_PMR_NUMLEVELS_MASK 0xc0UL + #define SQ_FR_PMR_NUMLEVELS_SFT 6 + #define SQ_FR_PMR_NUMLEVELS_PHYSICAL (0x0UL << 6) + #define SQ_FR_PMR_NUMLEVELS_LAYER1 (0x1UL << 6) + #define SQ_FR_PMR_NUMLEVELS_LAYER2 (0x2UL << 6) + __le64 pblptr; + __le64 va; + __le32 data[24]; +}; + +/* Bind SQ WQE (40 bytes) */ +struct sq_bind { + u8 wqe_type; + #define SQ_BIND_WQE_TYPE_BIND 0xeUL + u8 flags; + #define SQ_BIND_FLAGS_SIGNAL_COMP 0x1UL + #define SQ_BIND_FLAGS_RD_OR_ATOMIC_FENCE 0x2UL + #define SQ_BIND_FLAGS_UC_FENCE 0x4UL + #define SQ_BIND_FLAGS_SE 0x8UL + #define SQ_BIND_FLAGS_INLINE 0x10UL + u8 access_cntl; + #define SQ_BIND_ACCESS_CNTL_LOCAL_WRITE 0x1UL + #define SQ_BIND_ACCESS_CNTL_REMOTE_READ 0x2UL + #define SQ_BIND_ACCESS_CNTL_REMOTE_WRITE 0x4UL + #define SQ_BIND_ACCESS_CNTL_REMOTE_ATOMIC 0x8UL + #define SQ_BIND_ACCESS_CNTL_WINDOW_BIND 0x10UL + u8 reserved8_1; + u8 mw_type_zero_based; + #define SQ_BIND_ZERO_BASED 0x1UL + #define SQ_BIND_MW_TYPE 0x2UL + #define SQ_BIND_MW_TYPE_TYPE1 (0x0UL << 1) + #define SQ_BIND_MW_TYPE_TYPE2 (0x1UL << 1) + #define SQ_BIND_RESERVED6_MASK 0xfcUL + #define SQ_BIND_RESERVED6_SFT 2 + u8 reserved8_2; + __le16 reserved16; + __le32 parent_l_key; + __le32 l_key; + __le64 va; + u8 length[5]; + u8 data_reserved24[99]; + #define SQ_BIND_RESERVED24_MASK 0xffffff00UL + #define SQ_BIND_RESERVED24_SFT 8 + #define SQ_BIND_DATA_MASK 0xffffffffUL + #define SQ_BIND_DATA_SFT 0 +}; + +/* RQ/SRQ WQE Structures */ +/* RQ/SRQ WQE (40 bytes) */ +struct rq_wqe { + u8 wqe_type; + #define RQ_WQE_WQE_TYPE_RCV 0x80UL + u8 flags; + u8 wqe_size; + u8 reserved8; + __le32 reserved32; + __le32 wr_id[2]; + #define RQ_WQE_WR_ID_MASK 0xfffffUL + #define RQ_WQE_WR_ID_SFT 0 + #define RQ_WQE_RESERVED44_MASK 0xfff00000UL + #define RQ_WQE_RESERVED44_SFT 20 + __le32 reserved128[4]; + __le32 data[24]; +}; + +/* CQ CQE Structures */ +/* Base CQE (32 bytes) */ +struct cq_base { + __le64 reserved64_1; + __le64 reserved64_2; + __le64 reserved64_3; + u8 cqe_type_toggle; + #define CQ_BASE_TOGGLE 0x1UL + #define CQ_BASE_CQE_TYPE_MASK 0x1eUL + #define CQ_BASE_CQE_TYPE_SFT 1 + #define CQ_BASE_CQE_TYPE_REQ (0x0UL << 1) + #define CQ_BASE_CQE_TYPE_RES_RC (0x1UL << 1) + #define CQ_BASE_CQE_TYPE_RES_UD (0x2UL << 1) + #define CQ_BASE_CQE_TYPE_RES_RAWETH_QP1 (0x3UL << 1) + #define CQ_BASE_CQE_TYPE_TERMINAL (0xeUL << 1) + #define CQ_BASE_CQE_TYPE_CUT_OFF (0xfUL << 1) + #define CQ_BASE_RESERVED3_MASK 0xe0UL + #define CQ_BASE_RESERVED3_SFT 5 + u8 status; + __le16 reserved16; + __le32 reserved32; +}; + +/* Requester CQ CQE (32 bytes) */ +struct cq_req { + __le64 qp_handle; + __le16 sq_cons_idx; + __le16 reserved16_1; + __le32 reserved32_2; + __le64 reserved64; + u8 cqe_type_toggle; + #define CQ_REQ_TOGGLE 0x1UL + #define CQ_REQ_CQE_TYPE_MASK 0x1eUL + #define CQ_REQ_CQE_TYPE_SFT 1 + #define CQ_REQ_CQE_TYPE_REQ (0x0UL << 1) + #define CQ_REQ_RESERVED3_MASK 0xe0UL + #define CQ_REQ_RESERVED3_SFT 5 + u8 status; + #define CQ_REQ_STATUS_OK 0x0UL + #define CQ_REQ_STATUS_BAD_RESPONSE_ERR 0x1UL + #define CQ_REQ_STATUS_LOCAL_LENGTH_ERR 0x2UL + #define CQ_REQ_STATUS_LOCAL_QP_OPERATION_ERR 0x3UL + #define CQ_REQ_STATUS_LOCAL_PROTECTION_ERR 0x4UL + #define CQ_REQ_STATUS_MEMORY_MGT_OPERATION_ERR 0x5UL + #define CQ_REQ_STATUS_REMOTE_INVALID_REQUEST_ERR 0x6UL + #define CQ_REQ_STATUS_REMOTE_ACCESS_ERR 0x7UL + #define CQ_REQ_STATUS_REMOTE_OPERATION_ERR 0x8UL + #define CQ_REQ_STATUS_RNR_NAK_RETRY_CNT_ERR 0x9UL + #define CQ_REQ_STATUS_TRANSPORT_RETRY_CNT_ERR 0xaUL + #define CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR 0xbUL + __le16 reserved16_2; + __le32 reserved32_1; +}; + +/* Responder RC CQE (32 bytes) */ +struct cq_res_rc { + __le32 length; + __le32 imm_data_or_inv_r_key; + __le64 qp_handle; + __le64 mr_handle; + u8 cqe_type_toggle; + #define CQ_RES_RC_TOGGLE 0x1UL + #define CQ_RES_RC_CQE_TYPE_MASK 0x1eUL + #define CQ_RES_RC_CQE_TYPE_SFT 1 + #define CQ_RES_RC_CQE_TYPE_RES_RC (0x1UL << 1) + #define CQ_RES_RC_RESERVED3_MASK 0xe0UL + #define CQ_RES_RC_RESERVED3_SFT 5 + u8 status; + #define CQ_RES_RC_STATUS_OK 0x0UL + #define CQ_RES_RC_STATUS_LOCAL_ACCESS_ERROR 0x1UL + #define CQ_RES_RC_STATUS_LOCAL_LENGTH_ERR 0x2UL + #define CQ_RES_RC_STATUS_LOCAL_PROTECTION_ERR 0x3UL + #define CQ_RES_RC_STATUS_LOCAL_QP_OPERATION_ERR 0x4UL + #define CQ_RES_RC_STATUS_MEMORY_MGT_OPERATION_ERR 0x5UL + #define CQ_RES_RC_STATUS_REMOTE_INVALID_REQUEST_ERR 0x6UL + #define CQ_RES_RC_STATUS_WORK_REQUEST_FLUSHED_ERR 0x7UL + #define CQ_RES_RC_STATUS_HW_FLUSH_ERR 0x8UL + __le16 flags; + #define CQ_RES_RC_FLAGS_SRQ 0x1UL + #define CQ_RES_RC_FLAGS_SRQ_RQ (0x0UL << 0) + #define CQ_RES_RC_FLAGS_SRQ_SRQ (0x1UL << 0) + #define CQ_RES_RC_FLAGS_SRQ_LAST CQ_RES_RC_FLAGS_SRQ_SRQ + #define CQ_RES_RC_FLAGS_IMM 0x2UL + #define CQ_RES_RC_FLAGS_INV 0x4UL + #define CQ_RES_RC_FLAGS_RDMA 0x8UL + #define CQ_RES_RC_FLAGS_RDMA_SEND (0x0UL << 3) + #define CQ_RES_RC_FLAGS_RDMA_RDMA_WRITE (0x1UL << 3) + #define CQ_RES_RC_FLAGS_RDMA_LAST CQ_RES_RC_FLAGS_RDMA_RDMA_WRITE + __le32 srq_or_rq_wr_id; + #define CQ_RES_RC_SRQ_OR_RQ_WR_ID_MASK 0xfffffUL + #define CQ_RES_RC_SRQ_OR_RQ_WR_ID_SFT 0 + #define CQ_RES_RC_RESERVED12_MASK 0xfff00000UL + #define CQ_RES_RC_RESERVED12_SFT 20 +}; + +/* Responder UD CQE (32 bytes) */ +struct cq_res_ud { + __le32 length; + #define CQ_RES_UD_LENGTH_MASK 0x3fffUL + #define CQ_RES_UD_LENGTH_SFT 0 + #define CQ_RES_UD_RESERVED18_MASK 0xffffc000UL + #define CQ_RES_UD_RESERVED18_SFT 14 + __le32 imm_data; + __le64 qp_handle; + __le16 src_mac[3]; + __le16 src_qp_low; + u8 cqe_type_toggle; + #define CQ_RES_UD_TOGGLE 0x1UL + #define CQ_RES_UD_CQE_TYPE_MASK 0x1eUL + #define CQ_RES_UD_CQE_TYPE_SFT 1 + #define CQ_RES_UD_CQE_TYPE_RES_UD (0x2UL << 1) + #define CQ_RES_UD_RESERVED3_MASK 0xe0UL + #define CQ_RES_UD_RESERVED3_SFT 5 + u8 status; + #define CQ_RES_UD_STATUS_OK 0x0UL + #define CQ_RES_UD_STATUS_LOCAL_ACCESS_ERROR 0x1UL + #define CQ_RES_UD_STATUS_HW_LOCAL_LENGTH_ERR 0x2UL + #define CQ_RES_UD_STATUS_LOCAL_PROTECTION_ERR 0x3UL + #define CQ_RES_UD_STATUS_LOCAL_QP_OPERATION_ERR 0x4UL + #define CQ_RES_UD_STATUS_MEMORY_MGT_OPERATION_ERR 0x5UL + #define CQ_RES_UD_STATUS_WORK_REQUEST_FLUSHED_ERR 0x7UL + #define CQ_RES_UD_STATUS_HW_FLUSH_ERR 0x8UL + __le16 flags; + #define CQ_RES_UD_FLAGS_SRQ 0x1UL + #define CQ_RES_UD_FLAGS_SRQ_RQ (0x0UL << 0) + #define CQ_RES_UD_FLAGS_SRQ_SRQ (0x1UL << 0) + #define CQ_RES_UD_FLAGS_SRQ_LAST CQ_RES_UD_FLAGS_SRQ_SRQ + #define CQ_RES_UD_FLAGS_IMM 0x2UL + #define CQ_RES_UD_FLAGS_ROCE_IP_VER_MASK 0xcUL + #define CQ_RES_UD_FLAGS_ROCE_IP_VER_SFT 2 + #define CQ_RES_UD_FLAGS_ROCE_IP_VER_V1 (0x0UL << 2) + #define CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV4 (0x2UL << 2) + #define CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV6 (0x3UL << 2) + #define CQ_RES_UD_FLAGS_ROCE_IP_VER_LAST CQ_RES_UD_FLAGS_ROCE_IP_VER_V2IPV6 + __le32 src_qp_high_srq_or_rq_wr_id; + #define CQ_RES_UD_SRQ_OR_RQ_WR_ID_MASK 0xfffffUL + #define CQ_RES_UD_SRQ_OR_RQ_WR_ID_SFT 0 + #define CQ_RES_UD_RESERVED4_MASK 0xf00000UL + #define CQ_RES_UD_RESERVED4_SFT 20 + #define CQ_RES_UD_SRC_QP_HIGH_MASK 0xff000000UL + #define CQ_RES_UD_SRC_QP_HIGH_SFT 24 +}; + +/* Responder RawEth and QP1 CQE (32 bytes) */ +struct cq_res_raweth_qp1 { + __le16 length; + #define CQ_RES_RAWETH_QP1_LENGTH_MASK 0x3fffUL + #define CQ_RES_RAWETH_QP1_LENGTH_SFT 0 + #define CQ_RES_RAWETH_QP1_RESERVED2_MASK 0xc000UL + #define CQ_RES_RAWETH_QP1_RESERVED2_SFT 14 + __le16 raweth_qp1_flags; + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ERROR 0x1UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_RESERVED5_1_MASK 0x3eUL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_RESERVED5_1_SFT 1 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_MASK 0x3c0UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_SFT 6 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_NOT_KNOWN (0x0UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_IP (0x1UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_TCP (0x2UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_UDP (0x3UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_FCOE (0x4UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ROCE (0x5UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_ICMP (0x7UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_WO_TIMESTAMP (0x8UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP (0x9UL << 6) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_LAST CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_ITYPE_PTP_W_TIMESTAMP + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_MASK 0x3ffUL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS_SFT 0 + #define CQ_RES_RAWETH_QP1_RESERVED6_MASK 0xfc00UL + #define CQ_RES_RAWETH_QP1_RESERVED6_SFT 10 + __le16 raweth_qp1_errors; + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_RESERVED4_MASK 0xfUL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_RESERVED4_SFT 0 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_IP_CS_ERROR 0x10UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_L4_CS_ERROR 0x20UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_IP_CS_ERROR 0x40UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_L4_CS_ERROR 0x80UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_CRC_ERROR 0x100UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_MASK 0xe00UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_SFT 9 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_NO_ERROR (0x0UL << 9) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1UL << 9) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2UL << 9) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_TUNNEL_TOTAL_ERROR (0x3UL << 9) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x4UL << 9) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x5UL << 9) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x6UL << 9) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_LAST CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_MASK 0xf000UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_SFT 12 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_NO_ERROR (0x0UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8UL << 12) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_LAST CQ_RES_RAWETH_QP1_RAWETH_QP1_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN + __le16 raweth_qp1_cfa_code; + __le64 qp_handle; + __le32 raweth_qp1_flags2; + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_CS_CALC 0x1UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_L4_CS_CALC 0x2UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_T_IP_CS_CALC 0x4UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_T_L4_CS_CALC 0x8UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_MASK 0xf0UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_SFT 4 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_NONE (0x0UL << 4) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_VLAN (0x1UL << 4) + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_LAST CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_META_FORMAT_VLAN + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_FLAGS2_IP_TYPE 0x100UL + __le32 raweth_qp1_metadata; + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_MASK 0xfffUL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_VID_SFT 0 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_DE 0x1000UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_MASK 0xe000UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_PRI_SFT 13 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_MASK 0xffff0000UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_METADATA_TPID_SFT 16 + u8 cqe_type_toggle; + #define CQ_RES_RAWETH_QP1_TOGGLE 0x1UL + #define CQ_RES_RAWETH_QP1_CQE_TYPE_MASK 0x1eUL + #define CQ_RES_RAWETH_QP1_CQE_TYPE_SFT 1 + #define CQ_RES_RAWETH_QP1_CQE_TYPE_RES_RAWETH_QP1 (0x3UL << 1) + #define CQ_RES_RAWETH_QP1_RESERVED3_MASK 0xe0UL + #define CQ_RES_RAWETH_QP1_RESERVED3_SFT 5 + u8 status; + #define CQ_RES_RAWETH_QP1_STATUS_OK 0x0UL + #define CQ_RES_RAWETH_QP1_STATUS_LOCAL_ACCESS_ERROR 0x1UL + #define CQ_RES_RAWETH_QP1_STATUS_HW_LOCAL_LENGTH_ERR 0x2UL + #define CQ_RES_RAWETH_QP1_STATUS_LOCAL_PROTECTION_ERR 0x3UL + #define CQ_RES_RAWETH_QP1_STATUS_LOCAL_QP_OPERATION_ERR 0x4UL + #define CQ_RES_RAWETH_QP1_STATUS_MEMORY_MGT_OPERATION_ERR 0x5UL + #define CQ_RES_RAWETH_QP1_STATUS_WORK_REQUEST_FLUSHED_ERR 0x7UL + #define CQ_RES_RAWETH_QP1_STATUS_HW_FLUSH_ERR 0x8UL + __le16 flags; + #define CQ_RES_RAWETH_QP1_FLAGS_SRQ 0x1UL + #define CQ_RES_RAWETH_QP1_FLAGS_SRQ_RQ 0x0UL + #define CQ_RES_RAWETH_QP1_FLAGS_SRQ_SRQ 0x1UL + #define CQ_RES_RAWETH_QP1_FLAGS_SRQ_LAST CQ_RES_RAWETH_QP1_FLAGS_SRQ_SRQ + __le32 raweth_qp1_payload_offset_srq_or_rq_wr_id; + #define CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_MASK 0xfffffUL + #define CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_SFT 0 + #define CQ_RES_RAWETH_QP1_RESERVED4_MASK 0xf00000UL + #define CQ_RES_RAWETH_QP1_RESERVED4_SFT 20 + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_PAYLOAD_OFFSET_MASK 0xff000000UL + #define CQ_RES_RAWETH_QP1_RAWETH_QP1_PAYLOAD_OFFSET_SFT 24 +}; + +/* Terminal CQE (32 bytes) */ +struct cq_terminal { + __le64 qp_handle; + __le16 sq_cons_idx; + __le16 rq_cons_idx; + __le32 reserved32_1; + __le64 reserved64_3; + u8 cqe_type_toggle; + #define CQ_TERMINAL_TOGGLE 0x1UL + #define CQ_TERMINAL_CQE_TYPE_MASK 0x1eUL + #define CQ_TERMINAL_CQE_TYPE_SFT 1 + #define CQ_TERMINAL_CQE_TYPE_TERMINAL (0xeUL << 1) + #define CQ_TERMINAL_RESERVED3_MASK 0xe0UL + #define CQ_TERMINAL_RESERVED3_SFT 5 + u8 status; + #define CQ_TERMINAL_STATUS_OK 0x0UL + __le16 reserved16; + __le32 reserved32_2; +}; + +/* Cutoff CQE (32 bytes) */ +struct cq_cutoff { + __le64 reserved64_1; + __le64 reserved64_2; + __le64 reserved64_3; + u8 cqe_type_toggle; + #define CQ_CUTOFF_TOGGLE 0x1UL + #define CQ_CUTOFF_CQE_TYPE_MASK 0x1eUL + #define CQ_CUTOFF_CQE_TYPE_SFT 1 + #define CQ_CUTOFF_CQE_TYPE_CUT_OFF (0xfUL << 1) + #define CQ_CUTOFF_RESERVED3_MASK 0xe0UL + #define CQ_CUTOFF_RESERVED3_SFT 5 + u8 status; + #define CQ_CUTOFF_STATUS_OK 0x0UL + __le16 reserved16; + __le32 reserved32; +}; + +/* Notification Queue (NQ) Structures */ +/* Base NQ Record (16 bytes) */ +struct nq_base { + __le16 info10_type; + #define NQ_BASE_TYPE_MASK 0x3fUL
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Part of the diff is not shown here. View the raw message.
A message that is not in the archive (sent off-list or not yet received): 1480919912-1079-10-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [PATCH 09/28] bnxt_re: Introducing autogenerated Host Software Interface(hsi) file
Quoted 3 lines · Selvin Xavier
This patch introduces all the structures used by driver for communicating with the Hardware. This file is the equivalent of the
bnxt_en_hsi.hused bybnxt_endriver.
There are a fair number of structures that are the same between this file and drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h, for example:
bnxt_re_hsi.h vs. bnxt_hsi.h struct ctx_hw_stats struct ctx_hw_stats struct hwrm_async_event_cmpl struct hwrm_async_event_cmpl
struct cmd_nums
...
Does it make sense to have these two drivers reuse the sections that are common?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 9d151718-c357-d1c4-bbe5-5265e6d2b6ca-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 09/28] bnxt_re: Introducing autogenerated Host Software Interface(hsi) file
Quoted 11 lines · Jonathan Toppins
There are a fair number of structures that are the same between this file and
drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h, for example:bnxt_re_hsi.h vs. bnxt_hsi.h struct ctx_hw_stats struct ctx_hw_stats struct hwrm_async_event_cmpl struct hwrm_async_event_cmplstruct
cmd_nums
...Does it make sense to have these two drivers reuse the sections that are common?
Sure.. will take care of this in v2.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/28 bnxt_re: register with the NIC driver
In reply to a message not in the archiveThis patch handles the registration with bnxt_en driver. The driver registers with netdev notifier chain. Upon receiving NETDEV_REGISTER event, the driver in turn registers with bnxt_en driver.
1. bnxt_en's ulp_probe function returns a structure that contains information about the device and additional entry points.
2. bnxt_en driver returns 'struct bnxt_eth_dev' that contains set of operation vectors that RocE driver invokes later.
3. bnxt_request_msix() allows the RoCE driver to specify the number of MSI-X vectors that are needed.
4. bnxt_send_fw_msg () can be used to send messages to the FW
5. bnxt_register_async_events() can be used to register for async event callbacks.
--- drivers/infiniband/hw/bnxtre/Makefile | 1 + drivers/infiniband/hw/bnxtre/bnxt_re.h | 48 +++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 460 ++++++++++++++++++++++++++++ 3 files changed, 509 insertions(+)
drivers/infiniband/hw/bnxtre/Makefile +1 -0
@@ -1,4 +1,5 @@ +ccflags-y := -Idrivers/net/ethernet/broadcom/bnxt obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxt_re.o bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o \ bnxt_qplib_res.o bnxt_qplib_rcfw.o \
drivers/infiniband/hw/bnxtre/bnxt_re.h +48 -0
53 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +460 -0
482 lines not on this page · raw message
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1480919912-1079-11-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [PATCH 10/28] bnxt_re: register with the NIC driver
Quoted 24 lines · Selvin Xavier
This patch handles the registration with
bnxt_endriver. The driver registers with netdev notifier chain. Upon receivingNETDEV_REGISTERevent, the driver in turn registers withbnxt_endriver.
1. bnxt_en'sulp_probefunction returns a structure that contains information about the device and additional entry points.
2.bnxt_endriver returns 'structbnxt_eth_dev' that contains set of operation vectors that RocE driver invokes later.
3.bnxt_request_msix()allows the RoCE driver to specify the number of MSI-X vectors that are needed.
4.bnxt_send_fw_msg() can be used to send messages to the FW
5.bnxt_register_async_events()can be used to register for async event callbacks.--- drivers/infiniband/hw/bnxtre/Makefile | 1 + drivers/infiniband/hw/bnxtre/bnxt_re.h | 48 +++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 460 ++++++++++++++++++++++++++++ 3 files changed, 509 insertions(+)
[...]
Quoted 48 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +29
-0@@ -13,10 +13,24 @@#include <linux/module.h> #include <linux/netdevice.h> +#include <linux/ethtool.h> #include <linux/mutex.h> #include <linux/list.h> #include <linux/rculist.h> +#include <linux/spinlock.h> +#include <linux/pci.h> +#include <net/ipv6.h> +#include <net/addrconf.h> + +#include <rdma/ib_verbs.h> +#include <rdma/ib_user_verbs.h> +#include <rdma/ib_umem.h> +#include <rdma/ib_addr.h> + +#include "bnxt_ulp.h" +#include "bnxt_re_hsi.h" #include "bnxt_re.h" +#include "bnxt.h" static char version[] =BNXT_RE_DESC " v" ROCE_DRV_MODULE_VERSION "\n" ;@@ -30,6 +44,396 @@ MODULE_VERSION(ROCE_DRV_MODULE_VERSION);struct list_head bnxt_re_dev_list =LIST_HEAD_INIT (bnxt_re_dev_list);DEFINE_MUTEX (bnxt_re_dev_lock);static struct workqueue_struct *bnxt_re_wq; + +const char *bnxt_re_event2str[] = {"NONE" ,"UP" ,"DOWN" ,"REBOOT" , +"CHANGE" ,"REGISTER" ,"UNREGISTER" , +"CHANGEMTU" ,"CHANGEADDR" ,"GOING_DOWN" , +"CHANGENAME" ,"FEAT_CHANGE" , +"BONDING_FAILOVER" ,"PRE_UP" , +"PRE_TYPE_CHANGE" ,"POST_TYPE_CHANGE" , +"POST_INIT" ,"UNREGISTER_FINAL" ,"RELEASE" , +"NOTIFY_PEERS" ,"JOIN" ,"CHANGEUPPER" , +"RESEND_IGMP" ,"PRECHANGEMTU" , +"CHANGEINFODATA" ,"BONDING_INFO" , +"UNKNOWN" }; + +#define NETDEV_UNKNOWN 25 +
[...]
drivers/infiniband/hw/bnxtre/bnxt_re_main.c MODULE_VERSION(ROCE_DRV_MODULE_VERSION); · line 86
Quoted 7 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +7
-0+ +static inline const char *bnxt_re_netevent (unsigned long event) +{ +if (event >=ARRAY_SIZE (bnxt_re_event2str)) + event =NETDEV_UNKNOWN ; +return bnxt_re_event2str[(event)]; +}
Where is this function ever used in the series?
$ git log -1 --oneline 8b8b72dd6226 bnxt_re: Add QP event handling $ git grep "bnxt_re_netevent" drivers/infiniband/hw/bnxtre/bnxt_re_main.c:static inline const char *bnxt_re_netevent(unsigned long event) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): ad3d577c-760f-c003-394a-d80efe96400c-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 10/28] bnxt_re: register with the NIC driver
Quoted 7 lines · Jonathan Toppins
Where is this function ever used in the series?
$ git log -1 --oneline 8b8b72dd6226 bnxt_re: Add QP event handling $ git grep "bnxt_re_netevent" drivers/infiniband/hw/bnxtre/bnxt_re_main.c:static inline const char *bnxt_re_netevent(unsigned long event)
this function is not used. Removing it in V2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 11/28 bnxt_re: Enabling RoCE control path
In reply to a message not in the archiveThis patch implements the basic initialization for RocE HW interface. Some of the slow path FW commands required for the HW intialization are implemented. It also handles registration with the IB stack.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c | 599 ++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h | 176 ++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 740 +++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 164 ++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 163 ++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 42 ++ drivers/infiniband/hw/bnxtre/bnxt_re.h | 15 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 430 +++++++++++++- 8 files changed, 2321 insertions(+), 8 deletions(-)
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c +599 -0
@@ -10,3 +10,602 @@/* * Description: RDMA Controller HW interface */ +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/pci.h> +#include "bnxt_re_hsi.h" +#include "bnxt_qplib_res.h" +#include "bnxt_qplib_rcfw.h" +static void bnxt_qplib_service_creq (unsigned long data); + +/* Hardware communication channel */ +int bnxt_qplib_rcfw_wait_for_resp (struct bnxt_qplib_rcfw *rcfw,u16 cookie) +{ +u16 cbit; +int rc; + + cookie &=RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (!test_bit (cbit, rcfw->cmdq_bitmap)) +dev_warn (&rcfw->pdev->dev, +"QPLIB: CMD bit %d for cookie 0x%x is not set?" , + cbit, cookie); + + rc =wait_event_timeout (rcfw->waitq, + !test_bit (cbit, rcfw->cmdq_bitmap), +msecs_to_jiffies (RCFW_CMD_WAIT_TIME_MS )); +if (!rc) { +dev_warn (&rcfw->pdev->dev, +"QPLIB: Bono Error: timeout %d msec, msg {0x%x}\n" , +RCFW_CMD_WAIT_TIME_MS , cookie); + } + +return rc; +}; + +int bnxt_qplib_rcfw_block_for_resp (struct bnxt_qplib_rcfw *rcfw,u16 cookie) +{ +u32 count =-1 ; +u16 cbit; + + cookie &=RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (!test_bit (cbit, rcfw->cmdq_bitmap)) + goto done; +do { +bnxt_qplib_service_creq ((unsigned long )rcfw); + }while (test_bit (cbit, rcfw->cmdq_bitmap) && --count); +done: +return count; +}; + +void *bnxt_qplib_rcfw_send_message (struct bnxt_qplib_rcfw *rcfw, +struct cmdq_base *req,void **crsbe, +u8 is_block) +{ +struct bnxt_qplib_crsq *crsq = &rcfw->crsq; +struct bnxt_qplib_cmdqe *cmdqe, **cmdq_ptr; +struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq; +struct bnxt_qplib_hwq *crsb = &rcfw->crsb; +struct bnxt_qplib_crsqe *crsqe =NULL ; +struct bnxt_qplib_crsbe **crsb_ptr; +u32 sw_prod, cmdq_prod; +dma_addr_t dma_addr; +unsigned long flags; +u32 size, opcode; +u16 cookie, cbit; +int pg, idx; +u8 *preq; + +retry: + opcode = req->opcode; +if (!test_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags) && + (opcode !=CMDQ_BASE_OPCODE_QUERY_FUNC && + opcode !=CMDQ_BASE_OPCODE_INITIALIZE_FW )) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW not initialized, reject opcode 0x%x" , + opcode); +return NULL ; + } + +if (test_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags) && + opcode ==CMDQ_BASE_OPCODE_INITIALIZE_FW ) { +dev_err (&rcfw->pdev->dev,"QPLIB: RCFW already initialized!" ); +return NULL ; + } + +/* Cmdq are in 16-byte units, each request can consume 1 or more +* cmdqe +*/ +spin_lock_irqsave (&cmdq->lock, flags); +if (req->cmd_size > cmdq->max_elements - + ((HWQ_CMP (cmdq->prod, cmdq) -HWQ_CMP (cmdq->cons, cmdq)) & + (cmdq->max_elements -1 ))) { +dev_err (&rcfw->pdev->dev,"QPLIB: RCFW: CMDQ is full!" ); +spin_unlock_irqrestore (&cmdq->lock, flags); + goto retry; + } + + cookie =atomic_inc_return (&rcfw->seq_num) &RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (is_block) + cookie |=RCFW_CMD_IS_BLOCKING ; + req->cookie =cpu_to_le16 (cookie); +if (test_and_set_bit (cbit, rcfw->cmdq_bitmap)) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW MAX outstanding cmd reached!" ); +atomic_dec (&rcfw->seq_num); +spin_unlock_irqrestore (&cmdq->lock, flags); + goto retry; + } +/* Reserve a resp buffer slot if requested */ +if (req->resp_size && crsbe) { +spin_lock_irqsave (&crsb->lock, flags); + sw_prod =HWQ_CMP (crsb->prod, crsb); + crsb_ptr = (struct bnxt_qplib_crsbe **)crsb->pbl_ptr; + *crsbe = (void *)&crsb_ptr[CRSB_PG (sw_prod)][CRSB_IDX (sw_prod)]; +BNXT_QPLIB_CRSB_DMA_NEXT (crsb->pbl_dma_ptr, sw_prod, dma_addr); + req->resp_addr =cpu_to_le64 (dma_addr); + crsb->prod++; +spin_unlock_irqrestore (&crsb->lock, flags); + + req->resp_size = (sizeof (struct bnxt_qplib_crsbe ) + +BNXT_QPLIB_CMDQE_UNITS -1 ) / +BNXT_QPLIB_CMDQE_UNITS ; + } + cmdq_ptr = (struct bnxt_qplib_cmdqe **)cmdq->pbl_ptr; + preq = (u8 *)req; + size = req->cmd_size *BNXT_QPLIB_CMDQE_UNITS ; +do { + pg =0 ; + idx =0 ; + +/* Locate the next cmdq slot */ + sw_prod =HWQ_CMP (cmdq->prod, cmdq); + cmdqe = &cmdq_ptr[CMDQ_PG (sw_prod)][CMDQ_IDX (sw_prod)]; +if (!cmdqe) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW request failed with no cmdqe!" ); + goto done; + } +/* Copy a segment of the req cmd to the cmdq */ +memset (cmdqe,0 ,sizeof (*cmdqe)); +memcpy (cmdqe, preq,min_t (u32, size,sizeof (*cmdqe))); + preq +=min_t (u32, size,sizeof (*cmdqe)); + size -=min_t (u32, size,sizeof (*cmdqe)); + cmdq->prod++; + }while (size >0 ); + + cmdq_prod = cmdq->prod; +if (rcfw->flags &FIRMWARE_FIRST_FLAG ) { +/* The very first doorbell write is required to set this flag +* which prompts the FW to reset its internal pointers +*/ + cmdq_prod |=FIRMWARE_FIRST_FLAG ; + rcfw->flags &= ~FIRMWARE_FIRST_FLAG ; + } + sw_prod =HWQ_CMP (crsq->prod, crsq); + crsqe = &crsq->crsq[sw_prod]; +memset (crsqe,0 ,sizeof (*crsqe)); + crsq->prod++; + crsqe->req_size = req->cmd_size; + +/* ring CMDQ DB */ +writel (cmdq_prod, rcfw->cmdq_bar_reg_iomem + + rcfw->cmdq_bar_reg_prod_off); +writel (RCFW_CMDQ_TRIG_VAL , rcfw->cmdq_bar_reg_iomem + + rcfw->cmdq_bar_reg_trig_off); +done: +spin_unlock_irqrestore (&cmdq->lock, flags); +/* Return the CREQ response pointer */ +return crsqe ? &crsqe->qp_event :NULL ; +} + +/* Completions */ +static int bnxt_qplib_process_func_event (struct bnxt_qplib_rcfw *rcfw, +struct creq_func_event *func_event) +{ +switch (func_event->event) { +case CREQ_FUNC_EVENT_EVENT_TX_WQE_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TX_DATA_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_RX_WQE_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_RX_DATA_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CQ_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TQM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCQ_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCS_ERROR : +/* SRQ ctx error, call srq_handler?? +* But there's no SRQ handle! +*/ +break ; +case CREQ_FUNC_EVENT_EVENT_CFCC_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TIM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_VF_COMM_REQUEST : +break ; +case CREQ_FUNC_EVENT_EVENT_RESOURCE_EXHAUSTED : +break ; +default : +return -EINVAL ; + } +return 0 ; +} + +/* SP - CREQ Completion handlers */ +static void bnxt_qplib_service_creq (unsigned long data) +{ +struct bnxt_qplib_rcfw *rcfw = (struct bnxt_qplib_rcfw *)data; +struct bnxt_qplib_hwq *creq = &rcfw->creq; +struct creq_base *creqe, **creq_ptr; +u32 sw_cons, raw_cons; +unsigned long flags; +u32 type; + +/* Service the CREQ until empty */ +spin_lock_irqsave (&creq->lock, flags); + raw_cons = creq->cons; +while (1 ) { + sw_cons =HWQ_CMP (raw_cons, creq); + creq_ptr = (struct creq_base **)creq->pbl_ptr; + creqe = &creq_ptr[CREQ_PG (sw_cons)][CREQ_IDX (sw_cons)]; +if (!CREQ_CMP_VALID (creqe, raw_cons, creq->max_elements)) +break ; + + type = creqe->type &CREQ_BASE_TYPE_MASK ; +switch (type) { +case CREQ_BASE_TYPE_QP_EVENT : +break ; +case CREQ_BASE_TYPE_FUNC_EVENT : +if (!bnxt_qplib_process_func_event + (rcfw, (struct creq_func_event *)creqe)) + rcfw->creq_func_event_processed++; +else { +dev_warn (&rcfw->pdev->dev,"QPLIB: aeqe with" ); +dev_warn (&rcfw->pdev->dev, +"QPLIB: type = 0x%x not handled" , + type); + } +break ; +default : +dev_warn (&rcfw->pdev->dev,"QPLIB: creqe with " ); +dev_warn (&rcfw->pdev->dev, +"QPLIB: op_event = 0x%x not handled" , type); +break ; + } + raw_cons++; + } +if (creq->cons != raw_cons) { + creq->cons = raw_cons; +CREQ_DB_REARM (rcfw->creq_bar_reg_iomem, raw_cons, + creq->max_elements); + } +spin_unlock_irqrestore (&creq->lock, flags); +} + +static irqreturn_t bnxt_qplib_creq_irq (int irq,void *dev_instance) +{ +struct bnxt_qplib_rcfw *rcfw = dev_instance; +struct bnxt_qplib_hwq *creq = &rcfw->creq; +struct creq_base **creq_ptr; +u32 sw_cons; + +/* Prefetch the CREQ element */ + sw_cons =HWQ_CMP (creq->cons, creq); + creq_ptr = (struct creq_base **)rcfw->creq.pbl_ptr; +prefetch (&creq_ptr[CREQ_PG (sw_cons)][CREQ_IDX (sw_cons)]); + +tasklet_schedule (&rcfw->worker); + +return IRQ_HANDLED ; +} + +/* RCFW */ +int bnxt_qplib_deinit_rcfw (struct bnxt_qplib_rcfw *rcfw) +{ +struct creq_deinitialize_fw_resp *resp; +struct cmdq_deinitialize_fw req; +u16 cmd_flags =0 ; + +RCFW_CMD_PREP (req,DEINITIALIZE_FW , cmd_flags); + resp = (struct creq_deinitialize_fw_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) +return -EINVAL ; + +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) +return -ETIMEDOUT ; + +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) +return -EFAULT ; + +clear_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags); +return 0 ; +} + +static int __get_pbl_pg_idx (struct bnxt_qplib_pbl *pbl) +{ +return (pbl->pg_size ==ROCE_PG_SIZE_4K ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K : + pbl->pg_size ==ROCE_PG_SIZE_8K ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8K : + pbl->pg_size ==ROCE_PG_SIZE_64K ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_64K : + pbl->pg_size ==ROCE_PG_SIZE_2M ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_2M : + pbl->pg_size ==ROCE_PG_SIZE_8M ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8M : + pbl->pg_size ==ROCE_PG_SIZE_1G ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_1G : +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K ); +} + +int bnxt_qplib_init_rcfw (struct bnxt_qplib_rcfw *rcfw, +struct bnxt_qplib_ctx *ctx,int is_virtfn) +{ +struct creq_initialize_fw_resp *resp; +struct cmdq_initialize_fw req; +u16 cmd_flags =0 , level; + +RCFW_CMD_PREP (req,INITIALIZE_FW , cmd_flags); + +/* +* VFs need not setup the HW context area, PF +* shall setup this area for VF. Skipping the +* HW programming +*/ +if (is_virtfn) + goto skip_ctx_setup; + + level = ctx->qpc_tbl.level; + req.qpc_pg_size_qpc_lvl = (level <<CMDQ_INITIALIZE_FW_QPC_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->qpc_tbl.pbl[level]); + level = ctx->mrw_tbl.level; + req.mrw_pg_size_mrw_lvl = (level <<CMDQ_INITIALIZE_FW_MRW_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->mrw_tbl.pbl[level]); + level = ctx->srqc_tbl.level; + req.srq_pg_size_srq_lvl = (level <<CMDQ_INITIALIZE_FW_SRQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->srqc_tbl.pbl[level]); + level = ctx->cq_tbl.level; + req.cq_pg_size_cq_lvl = (level <<CMDQ_INITIALIZE_FW_CQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->cq_tbl.pbl[level]); + level = ctx->srqc_tbl.level; + req.srq_pg_size_srq_lvl = (level <<CMDQ_INITIALIZE_FW_SRQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->srqc_tbl.pbl[level]); + level = ctx->cq_tbl.level; + req.cq_pg_size_cq_lvl = (level <<CMDQ_INITIALIZE_FW_CQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->cq_tbl.pbl[level]); + level = ctx->tim_tbl.level; + req.tim_pg_size_tim_lvl = (level <<CMDQ_INITIALIZE_FW_TIM_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->tim_tbl.pbl[level]); + level = ctx->tqm_pde_level; + req.tqm_pg_size_tqm_lvl = (level <<CMDQ_INITIALIZE_FW_TQM_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->tqm_pde.pbl[level]); + + req.qpc_page_dir = +cpu_to_le64 (ctx->qpc_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.mrw_page_dir = +cpu_to_le64 (ctx->mrw_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.srq_page_dir = +cpu_to_le64 (ctx->srqc_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.cq_page_dir = +cpu_to_le64 (ctx->cq_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.tim_page_dir = +cpu_to_le64 (ctx->tim_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.tqm_page_dir = +cpu_to_le64 (ctx->tqm_pde.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + + req.number_of_qp =cpu_to_le32 (ctx->qpc_tbl.max_elements); + req.number_of_mrw =cpu_to_le32 (ctx->mrw_tbl.max_elements); + req.number_of_srq =cpu_to_le32 (ctx->srqc_tbl.max_elements); + req.number_of_cq =cpu_to_le32 (ctx->cq_tbl.max_elements); + + req.max_qp_per_vf =cpu_to_le32 (ctx->vf_res.max_qp_per_vf); + req.max_mrw_per_vf =cpu_to_le32 (ctx->vf_res.max_mrw_per_vf); + req.max_srq_per_vf =cpu_to_le32 (ctx->vf_res.max_srq_per_vf); + req.max_cq_per_vf =cpu_to_le32 (ctx->vf_res.max_cq_per_vf); + req.max_gid_per_vf =cpu_to_le32 (ctx->vf_res.max_gid_per_vf); + +skip_ctx_setup: + req.stat_ctx_id =cpu_to_le32 (ctx->stats.fw_id); + resp = (struct creq_initialize_fw_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW: INITIALIZE_FW send failed" ); +return -EINVAL ; + } +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW: INITIALIZE_FW timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW: INITIALIZE_FW failed" ); +return -EINVAL ; + } +set_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags); +return 0 ; +} + +void bnxt_qplib_free_rcfw_channel (struct bnxt_qplib_rcfw *rcfw) +{ +bnxt_qplib_free_hwq (rcfw->pdev, &rcfw->crsb); +kfree (rcfw->crsq.crsq); +bnxt_qplib_free_hwq (rcfw->pdev, &rcfw->cmdq); +bnxt_qplib_free_hwq (rcfw->pdev, &rcfw->creq); + + rcfw->pdev =NULL ; +} + +int bnxt_qplib_alloc_rcfw_channel (struct pci_dev *pdev, +struct bnxt_qplib_rcfw *rcfw) +{ + rcfw->pdev = pdev; + rcfw->creq.max_elements =BNXT_QPLIB_CREQE_MAX_CNT ; +if (bnxt_qplib_alloc_init_hwq (rcfw->pdev, &rcfw->creq,NULL ,0 , + &rcfw->creq.max_elements, +BNXT_QPLIB_CREQE_UNITS ,0 ,PAGE_SIZE , +HWQ_TYPE_L2_CMPL )) { +dev_err (&rcfw->pdev->dev, +"QPLIB: HW channel CREQ allocation failed" ); + goto fail; + } + rcfw->cmdq.max_elements =BNXT_QPLIB_CMDQE_MAX_CNT ; +if (bnxt_qplib_alloc_init_hwq (rcfw->pdev, &rcfw->cmdq,NULL ,0 , + &rcfw->cmdq.max_elements, +BNXT_QPLIB_CMDQE_UNITS ,0 ,PAGE_SIZE , +HWQ_TYPE_CTX )) { +dev_err (&rcfw->pdev->dev, +"QPLIB: HW channel CMDQ allocation failed" ); + goto fail; + } + + rcfw->crsq.max_elements = rcfw->cmdq.max_elements; + rcfw->crsq.crsq =kcalloc (rcfw->crsq.max_elements, +sizeof (*rcfw->crsq.crsq),GFP_KERNEL ); +if (!rcfw->crsq.crsq) + goto fail; + + rcfw->crsb.max_elements =BNXT_QPLIB_CRSBE_MAX_CNT ; +if (bnxt_qplib_alloc_init_hwq (rcfw->pdev, &rcfw->crsb,NULL ,0 , + &rcfw->crsb.max_elements, +BNXT_QPLIB_CRSBE_UNITS ,0 ,PAGE_SIZE , +HWQ_TYPE_CTX )) { +dev_err (&rcfw->pdev->dev, +"QPLIB: HW channel CRSB allocation failed" ); + goto fail; + } +return 0 ; + +fail: +bnxt_qplib_free_rcfw_channel (rcfw); +return -ENOMEM ; +} + +void bnxt_qplib_disable_rcfw_channel (struct bnxt_qplib_rcfw *rcfw) +{ +unsigned long indx; + +/* Make sure the HW channel is stopped! */ +synchronize_irq (rcfw->vector); +tasklet_disable (&rcfw->worker); +tasklet_kill (&rcfw->worker); + +if (rcfw->requested) { +free_irq (rcfw->vector, rcfw); + rcfw->requested = false; + } +if (rcfw->cmdq_bar_reg_iomem) +iounmap (rcfw->cmdq_bar_reg_iomem); + rcfw->cmdq_bar_reg_iomem =NULL ; + +if (rcfw->creq_bar_reg_iomem) +iounmap (rcfw->creq_bar_reg_iomem); + rcfw->creq_bar_reg_iomem =NULL ; + + indx =find_first_bit (rcfw->cmdq_bitmap, rcfw->bmap_size); +if (indx != rcfw->bmap_size) +dev_err (&rcfw->pdev->dev, +"QPLIB: disabling RCFW with pending cmd-bit %lx" , indx); +kfree (rcfw->cmdq_bitmap); + rcfw->bmap_size =0 ; + + rcfw->aeq_handler =NULL ; + rcfw->vector =0 ; +} + +int bnxt_qplib_enable_rcfw_channel (struct pci_dev *pdev, +struct bnxt_qplib_rcfw *rcfw, +int msix_vector, +int cp_bar_reg_off,int virt_fn, +int (*aeq_handler)(struct bnxt_qplib_rcfw *, +struct creq_func_event *)) +{ +resource_size_t res_base; +struct cmdq_init init; +u16 bmap_size; +int rc; + +/* General */ +atomic_set (&rcfw->seq_num,0 ); + rcfw->flags =FIRMWARE_FIRST_FLAG ; + bmap_size =BITS_TO_LONGS (RCFW_MAX_OUTSTANDING_CMD * +sizeof (unsigned long )); + rcfw->cmdq_bitmap =kzalloc (bmap_size,GFP_KERNEL ); +if (!rcfw->cmdq_bitmap) +return -ENOMEM ; + rcfw->bmap_size = bmap_size; + +/* CMDQ */ + rcfw->cmdq_bar_reg =RCFW_COMM_PCI_BAR_REGION ; + res_base =pci_resource_start (pdev, rcfw->cmdq_bar_reg); +if (!res_base) +return -ENOMEM ; + + rcfw->cmdq_bar_reg_iomem =ioremap_nocache (res_base + +RCFW_COMM_BASE_OFFSET , +RCFW_COMM_SIZE ); +if (!rcfw->cmdq_bar_reg_iomem) { +dev_err (&rcfw->pdev->dev, +"QPLIB: CMDQ BAR region %d mapping failed" , + rcfw->cmdq_bar_reg); +return -ENOMEM ; + } + + rcfw->cmdq_bar_reg_prod_off = virt_fn ?RCFW_VF_COMM_PROD_OFFSET : +RCFW_PF_COMM_PROD_OFFSET ; + + rcfw->cmdq_bar_reg_trig_off =RCFW_COMM_TRIG_OFFSET ; + +/* CRSQ */ + rcfw->crsq.prod =0 ; + rcfw->crsq.cons =0 ; + +/* CREQ */ + rcfw->creq_bar_reg =RCFW_COMM_CONS_PCI_BAR_REGION ; + res_base =pci_resource_start (pdev, rcfw->creq_bar_reg); +if (!res_base) +dev_err (&rcfw->pdev->dev, +"QPLIB: CREQ BAR region %d resc start is 0!" , + rcfw->creq_bar_reg); + rcfw->creq_bar_reg_iomem =ioremap_nocache (res_base + cp_bar_reg_off, +4 ); +if (!rcfw->creq_bar_reg_iomem) { +dev_err (&rcfw->pdev->dev, +"QPLIB: CREQ BAR region %d mapping failed" , + rcfw->creq_bar_reg); +return -ENOMEM ; + } + rcfw->creq_qp_event_processed =0 ; + rcfw->creq_func_event_processed =0 ; + + rcfw->vector = msix_vector; +if (aeq_handler) + rcfw->aeq_handler = aeq_handler; + +tasklet_init (&rcfw->worker, bnxt_qplib_service_creq, + (unsigned long )rcfw); + + rcfw->requested = false; + rc =request_irq (rcfw->vector, bnxt_qplib_creq_irq,0 , +"bnxt_qplib_creq" , rcfw); +if (rc) { +dev_err (&rcfw->pdev->dev, +"QPLIB: Failed to request IRQ for CREQ rc = 0x%x" , rc); +bnxt_qplib_disable_rcfw_channel (rcfw); +return rc; + } + rcfw->requested = true; + +init_waitqueue_head (&rcfw->waitq); + +CREQ_DB_REARM (rcfw->creq_bar_reg_iomem,0 , rcfw->creq.max_elements); + + init.cmdq_pbl =cpu_to_le64 (rcfw->cmdq.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + init.cmdq_size_cmdq_lvl =cpu_to_le16 ( + ((BNXT_QPLIB_CMDQE_MAX_CNT <<CMDQ_INIT_CMDQ_SIZE_SFT ) & +CMDQ_INIT_CMDQ_SIZE_MASK ) | + ((rcfw->cmdq.level <<CMDQ_INIT_CMDQ_LVL_SFT ) & +CMDQ_INIT_CMDQ_LVL_MASK )); + init.creq_ring_id =cpu_to_le16 (rcfw->creq_ring_id); + +/* Write to the Bono mailbox register */ +__iowrite32_copy (rcfw->cmdq_bar_reg_iomem, &init,sizeof (init) /4 ); +return 0 ; +}
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h +176 -0
180 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c +740 -0
743 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h +164 -0
169 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c +163 -0
166 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h +42 -0
46 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re.h +15 -0
@@ -16,6 +16,11 @@#define BNXT_RE_REF_WAIT_COUNT 10#define BNXT_RE_DESC "Broadcom NetXtreme-C/E RoCE Driver" +#define BNXT_RE_MAX_QPC_COUNT (64 * 1024) +#define BNXT_RE_MAX_MRW_COUNT (64 * 1024) +#define BNXT_RE_MAX_SRQC_COUNT (64 * 1024) +#define BNXT_RE_MAX_CQ_COUNT (64 * 1024) +struct bnxt_re_work {struct work_struct work;unsigned long event;
@@ -25,6 +30,7 @@ struct bnxt_re_work {#define BNXT_RE_MIN_MSIX 2#define BNXT_RE_MAX_MSIX 16 +#define BNXT_RE_AEQ_IDX 0struct bnxt_re_dev {struct ib_device ibdev;struct list_head list;
@@ -43,6 +49,15 @@ struct bnxt_re_dev {int id; +/* RCFW Channel */ +struct bnxt_qplib_rcfw rcfw; + +/* Device Resources */ +struct bnxt_qplib_dev_attr dev_attr; +struct bnxt_qplib_ctx qplib_ctx; +struct bnxt_qplib_res qplib_res; +struct bnxt_qplib_dpi dpi_privileged; +atomic_t qp_count;struct mutex qp_lock;/* protect qp list */ struct list_head qp_list;
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +422 -8
497 lines not on this page · raw message
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1480919912-1079-12-git-send-email-selvin.xavier-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [PATCH 11/28] bnxt_re: Enabling RoCE control path
Quoted 101 lines · Selvin Xavier
This patch implements the basic initialization for RocE HW interface. Some of the slow path FW commands required for the HW intialization are implemented. It also handles registration with the IB stack.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c | 599 ++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h | 176 ++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 740 +++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 164 ++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 163 ++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 42 ++ drivers/infiniband/hw/bnxtre/bnxt_re.h | 15 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 430 +++++++++++++- 8 files changed, 2321 insertions(+), 8 deletions(-)drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c +73
-0@@ -10,3 +10,602 @@/* * Description: RDMA Controller HW interface */ +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/pci.h> +#include "bnxt_re_hsi.h" +#include "bnxt_qplib_res.h" +#include "bnxt_qplib_rcfw.h" +static void bnxt_qplib_service_creq (unsigned long data); + +/* Hardware communication channel */ +int bnxt_qplib_rcfw_wait_for_resp (struct bnxt_qplib_rcfw *rcfw,u16 cookie) +{ +u16 cbit; +int rc; + + cookie &=RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (!test_bit (cbit, rcfw->cmdq_bitmap)) +dev_warn (&rcfw->pdev->dev, +"QPLIB: CMD bit %d for cookie 0x%x is not set?" , + cbit, cookie); + + rc =wait_event_timeout (rcfw->waitq, + !test_bit (cbit, rcfw->cmdq_bitmap), +msecs_to_jiffies (RCFW_CMD_WAIT_TIME_MS )); +if (!rc) { +dev_warn (&rcfw->pdev->dev, +"QPLIB: Bono Error: timeout %d msec, msg {0x%x}\n" , +RCFW_CMD_WAIT_TIME_MS , cookie); + } + +return rc; +}; + +int bnxt_qplib_rcfw_block_for_resp (struct bnxt_qplib_rcfw *rcfw,u16 cookie) +{ +u32 count =-1 ; +u16 cbit; + + cookie &=RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (!test_bit (cbit, rcfw->cmdq_bitmap)) + goto done; +do { +bnxt_qplib_service_creq ((unsigned long )rcfw); + }while (test_bit (cbit, rcfw->cmdq_bitmap) && --count); +done: +return count; +}; + +void *bnxt_qplib_rcfw_send_message (struct bnxt_qplib_rcfw *rcfw, +struct cmdq_base *req,void **crsbe, +u8 is_block) +{ +struct bnxt_qplib_crsq *crsq = &rcfw->crsq; +struct bnxt_qplib_cmdqe *cmdqe, **cmdq_ptr; +struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq; +struct bnxt_qplib_hwq *crsb = &rcfw->crsb; +struct bnxt_qplib_crsqe *crsqe =NULL ; +struct bnxt_qplib_crsbe **crsb_ptr; +u32 sw_prod, cmdq_prod; +dma_addr_t dma_addr; +unsigned long flags; +u32 size, opcode; +u16 cookie, cbit; +int pg, idx; +u8 *preq; + +retry: + opcode = req->opcode; +if (!test_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags) && + (opcode !=CMDQ_BASE_OPCODE_QUERY_FUNC && + opcode !=CMDQ_BASE_OPCODE_INITIALIZE_FW )) { + dev_err(&rcfw->pdev->dev,
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c line 95
Quoted 10 lines
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c +10
-0+"QPLIB: RCFW not initialized, reject opcode 0x%x" , + opcode); +return NULL ; + } + +if (test_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags) && + opcode ==CMDQ_BASE_OPCODE_INITIALIZE_FW ) { +dev_err (&rcfw->pdev->dev,"QPLIB: RCFW already initialized!" ); +return NULL ; + }
This retry logic looks like a complicated infinite loop, I am not seeing where there is a counter or some other mechanism to break out of this retry cycle if for some reason the HW stops or some other issue occurs. Can you help me understand this section?
Quoted 2,387 lines
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c +516
-0+ +/* Cmdq are in 16-byte units, each request can consume 1 or more +* cmdqe +*/ +spin_lock_irqsave (&cmdq->lock, flags); +if (req->cmd_size > cmdq->max_elements - + ((HWQ_CMP (cmdq->prod, cmdq) -HWQ_CMP (cmdq->cons, cmdq)) & + (cmdq->max_elements -1 ))) { +dev_err (&rcfw->pdev->dev,"QPLIB: RCFW: CMDQ is full!" ); +spin_unlock_irqrestore (&cmdq->lock, flags); + goto retry; + } + + cookie =atomic_inc_return (&rcfw->seq_num) &RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (is_block) + cookie |=RCFW_CMD_IS_BLOCKING ; + req->cookie =cpu_to_le16 (cookie); +if (test_and_set_bit (cbit, rcfw->cmdq_bitmap)) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW MAX outstanding cmd reached!" ); +atomic_dec (&rcfw->seq_num); +spin_unlock_irqrestore (&cmdq->lock, flags); + goto retry; + } +/* Reserve a resp buffer slot if requested */ +if (req->resp_size && crsbe) { +spin_lock_irqsave (&crsb->lock, flags); + sw_prod =HWQ_CMP (crsb->prod, crsb); + crsb_ptr = (struct bnxt_qplib_crsbe **)crsb->pbl_ptr; + *crsbe = (void *)&crsb_ptr[CRSB_PG (sw_prod)][CRSB_IDX (sw_prod)]; +BNXT_QPLIB_CRSB_DMA_NEXT (crsb->pbl_dma_ptr, sw_prod, dma_addr); + req->resp_addr =cpu_to_le64 (dma_addr); + crsb->prod++; +spin_unlock_irqrestore (&crsb->lock, flags); + + req->resp_size = (sizeof (struct bnxt_qplib_crsbe ) + +BNXT_QPLIB_CMDQE_UNITS -1 ) / +BNXT_QPLIB_CMDQE_UNITS ; + } + cmdq_ptr = (struct bnxt_qplib_cmdqe **)cmdq->pbl_ptr; + preq = (u8 *)req; + size = req->cmd_size *BNXT_QPLIB_CMDQE_UNITS ; +do { + pg =0 ; + idx =0 ; + +/* Locate the next cmdq slot */ + sw_prod =HWQ_CMP (cmdq->prod, cmdq); + cmdqe = &cmdq_ptr[CMDQ_PG (sw_prod)][CMDQ_IDX (sw_prod)]; +if (!cmdqe) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW request failed with no cmdqe!" ); + goto done; + } +/* Copy a segment of the req cmd to the cmdq */ +memset (cmdqe,0 ,sizeof (*cmdqe)); +memcpy (cmdqe, preq,min_t (u32, size,sizeof (*cmdqe))); + preq +=min_t (u32, size,sizeof (*cmdqe)); + size -=min_t (u32, size,sizeof (*cmdqe)); + cmdq->prod++; + }while (size >0 ); + + cmdq_prod = cmdq->prod; +if (rcfw->flags &FIRMWARE_FIRST_FLAG ) { +/* The very first doorbell write is required to set this flag +* which prompts the FW to reset its internal pointers +*/ + cmdq_prod |=FIRMWARE_FIRST_FLAG ; + rcfw->flags &= ~FIRMWARE_FIRST_FLAG ; + } + sw_prod =HWQ_CMP (crsq->prod, crsq); + crsqe = &crsq->crsq[sw_prod]; +memset (crsqe,0 ,sizeof (*crsqe)); + crsq->prod++; + crsqe->req_size = req->cmd_size; + +/* ring CMDQ DB */ +writel (cmdq_prod, rcfw->cmdq_bar_reg_iomem + + rcfw->cmdq_bar_reg_prod_off); +writel (RCFW_CMDQ_TRIG_VAL , rcfw->cmdq_bar_reg_iomem + + rcfw->cmdq_bar_reg_trig_off); +done: +spin_unlock_irqrestore (&cmdq->lock, flags); +/* Return the CREQ response pointer */ +return crsqe ? &crsqe->qp_event :NULL ; +} + +/* Completions */ +static int bnxt_qplib_process_func_event (struct bnxt_qplib_rcfw *rcfw, +struct creq_func_event *func_event) +{ +switch (func_event->event) { +case CREQ_FUNC_EVENT_EVENT_TX_WQE_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TX_DATA_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_RX_WQE_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_RX_DATA_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CQ_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TQM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCQ_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCS_ERROR : +/* SRQ ctx error, call srq_handler?? +* But there's no SRQ handle! +*/ +break ; +case CREQ_FUNC_EVENT_EVENT_CFCC_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TIM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_VF_COMM_REQUEST : +break ; +case CREQ_FUNC_EVENT_EVENT_RESOURCE_EXHAUSTED : +break ; +default : +return -EINVAL ; + } +return 0 ; +} + +/* SP - CREQ Completion handlers */ +static void bnxt_qplib_service_creq (unsigned long data) +{ +struct bnxt_qplib_rcfw *rcfw = (struct bnxt_qplib_rcfw *)data; +struct bnxt_qplib_hwq *creq = &rcfw->creq; +struct creq_base *creqe, **creq_ptr; +u32 sw_cons, raw_cons; +unsigned long flags; +u32 type; + +/* Service the CREQ until empty */ +spin_lock_irqsave (&creq->lock, flags); + raw_cons = creq->cons; +while (1 ) { + sw_cons =HWQ_CMP (raw_cons, creq); + creq_ptr = (struct creq_base **)creq->pbl_ptr; + creqe = &creq_ptr[CREQ_PG (sw_cons)][CREQ_IDX (sw_cons)]; +if (!CREQ_CMP_VALID (creqe, raw_cons, creq->max_elements)) +break ; + + type = creqe->type &CREQ_BASE_TYPE_MASK ; +switch (type) { +case CREQ_BASE_TYPE_QP_EVENT : +break ; +case CREQ_BASE_TYPE_FUNC_EVENT : +if (!bnxt_qplib_process_func_event + (rcfw, (struct creq_func_event *)creqe)) + rcfw->creq_func_event_processed++; +else { +dev_warn (&rcfw->pdev->dev,"QPLIB: aeqe with" ); +dev_warn (&rcfw->pdev->dev, +"QPLIB: type = 0x%x not handled" , + type); + } +break ; +default : +dev_warn (&rcfw->pdev->dev,"QPLIB: creqe with " ); +dev_warn (&rcfw->pdev->dev, +"QPLIB: op_event = 0x%x not handled" , type); +break ; + } + raw_cons++; + } +if (creq->cons != raw_cons) { + creq->cons = raw_cons; +CREQ_DB_REARM (rcfw->creq_bar_reg_iomem, raw_cons, + creq->max_elements); + } +spin_unlock_irqrestore (&creq->lock, flags); +} + +static irqreturn_t bnxt_qplib_creq_irq (int irq,void *dev_instance) +{ +struct bnxt_qplib_rcfw *rcfw = dev_instance; +struct bnxt_qplib_hwq *creq = &rcfw->creq; +struct creq_base **creq_ptr; +u32 sw_cons; + +/* Prefetch the CREQ element */ + sw_cons =HWQ_CMP (creq->cons, creq); + creq_ptr = (struct creq_base **)rcfw->creq.pbl_ptr; +prefetch (&creq_ptr[CREQ_PG (sw_cons)][CREQ_IDX (sw_cons)]); + +tasklet_schedule (&rcfw->worker); + +return IRQ_HANDLED ; +} + +/* RCFW */ +int bnxt_qplib_deinit_rcfw (struct bnxt_qplib_rcfw *rcfw) +{ +struct creq_deinitialize_fw_resp *resp; +struct cmdq_deinitialize_fw req; +u16 cmd_flags =0 ; + +RCFW_CMD_PREP (req,DEINITIALIZE_FW , cmd_flags); + resp = (struct creq_deinitialize_fw_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) +return -EINVAL ; + +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) +return -ETIMEDOUT ; + +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) +return -EFAULT ; + +clear_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags); +return 0 ; +} + +static int __get_pbl_pg_idx (struct bnxt_qplib_pbl *pbl) +{ +return (pbl->pg_size ==ROCE_PG_SIZE_4K ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K : + pbl->pg_size ==ROCE_PG_SIZE_8K ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8K : + pbl->pg_size ==ROCE_PG_SIZE_64K ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_64K : + pbl->pg_size ==ROCE_PG_SIZE_2M ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_2M : + pbl->pg_size ==ROCE_PG_SIZE_8M ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_8M : + pbl->pg_size ==ROCE_PG_SIZE_1G ? +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_1G : +CMDQ_INITIALIZE_FW_QPC_PG_SIZE_PG_4K ); +} + +int bnxt_qplib_init_rcfw (struct bnxt_qplib_rcfw *rcfw, +struct bnxt_qplib_ctx *ctx,int is_virtfn) +{ +struct creq_initialize_fw_resp *resp; +struct cmdq_initialize_fw req; +u16 cmd_flags =0 , level; + +RCFW_CMD_PREP (req,INITIALIZE_FW , cmd_flags); + +/* +* VFs need not setup the HW context area, PF +* shall setup this area for VF. Skipping the +* HW programming +*/ +if (is_virtfn) + goto skip_ctx_setup; + + level = ctx->qpc_tbl.level; + req.qpc_pg_size_qpc_lvl = (level <<CMDQ_INITIALIZE_FW_QPC_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->qpc_tbl.pbl[level]); + level = ctx->mrw_tbl.level; + req.mrw_pg_size_mrw_lvl = (level <<CMDQ_INITIALIZE_FW_MRW_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->mrw_tbl.pbl[level]); + level = ctx->srqc_tbl.level; + req.srq_pg_size_srq_lvl = (level <<CMDQ_INITIALIZE_FW_SRQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->srqc_tbl.pbl[level]); + level = ctx->cq_tbl.level; + req.cq_pg_size_cq_lvl = (level <<CMDQ_INITIALIZE_FW_CQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->cq_tbl.pbl[level]); + level = ctx->srqc_tbl.level; + req.srq_pg_size_srq_lvl = (level <<CMDQ_INITIALIZE_FW_SRQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->srqc_tbl.pbl[level]); + level = ctx->cq_tbl.level; + req.cq_pg_size_cq_lvl = (level <<CMDQ_INITIALIZE_FW_CQ_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->cq_tbl.pbl[level]); + level = ctx->tim_tbl.level; + req.tim_pg_size_tim_lvl = (level <<CMDQ_INITIALIZE_FW_TIM_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->tim_tbl.pbl[level]); + level = ctx->tqm_pde_level; + req.tqm_pg_size_tqm_lvl = (level <<CMDQ_INITIALIZE_FW_TQM_LVL_SFT ) | +__get_pbl_pg_idx (&ctx->tqm_pde.pbl[level]); + + req.qpc_page_dir = +cpu_to_le64 (ctx->qpc_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.mrw_page_dir = +cpu_to_le64 (ctx->mrw_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.srq_page_dir = +cpu_to_le64 (ctx->srqc_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.cq_page_dir = +cpu_to_le64 (ctx->cq_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.tim_page_dir = +cpu_to_le64 (ctx->tim_tbl.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + req.tqm_page_dir = +cpu_to_le64 (ctx->tqm_pde.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + + req.number_of_qp =cpu_to_le32 (ctx->qpc_tbl.max_elements); + req.number_of_mrw =cpu_to_le32 (ctx->mrw_tbl.max_elements); + req.number_of_srq =cpu_to_le32 (ctx->srqc_tbl.max_elements); + req.number_of_cq =cpu_to_le32 (ctx->cq_tbl.max_elements); + + req.max_qp_per_vf =cpu_to_le32 (ctx->vf_res.max_qp_per_vf); + req.max_mrw_per_vf =cpu_to_le32 (ctx->vf_res.max_mrw_per_vf); + req.max_srq_per_vf =cpu_to_le32 (ctx->vf_res.max_srq_per_vf); + req.max_cq_per_vf =cpu_to_le32 (ctx->vf_res.max_cq_per_vf); + req.max_gid_per_vf =cpu_to_le32 (ctx->vf_res.max_gid_per_vf); + +skip_ctx_setup: + req.stat_ctx_id =cpu_to_le32 (ctx->stats.fw_id); + resp = (struct creq_initialize_fw_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW: INITIALIZE_FW send failed" ); +return -EINVAL ; + } +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW: INITIALIZE_FW timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW: INITIALIZE_FW failed" ); +return -EINVAL ; + } +set_bit (FIRMWARE_INITIALIZED_FLAG , &rcfw->flags); +return 0 ; +} + +void bnxt_qplib_free_rcfw_channel (struct bnxt_qplib_rcfw *rcfw) +{ +bnxt_qplib_free_hwq (rcfw->pdev, &rcfw->crsb); +kfree (rcfw->crsq.crsq); +bnxt_qplib_free_hwq (rcfw->pdev, &rcfw->cmdq); +bnxt_qplib_free_hwq (rcfw->pdev, &rcfw->creq); + + rcfw->pdev =NULL ; +} + +int bnxt_qplib_alloc_rcfw_channel (struct pci_dev *pdev, +struct bnxt_qplib_rcfw *rcfw) +{ + rcfw->pdev = pdev; + rcfw->creq.max_elements =BNXT_QPLIB_CREQE_MAX_CNT ; +if (bnxt_qplib_alloc_init_hwq (rcfw->pdev, &rcfw->creq,NULL ,0 , + &rcfw->creq.max_elements, +BNXT_QPLIB_CREQE_UNITS ,0 ,PAGE_SIZE , +HWQ_TYPE_L2_CMPL )) { +dev_err (&rcfw->pdev->dev, +"QPLIB: HW channel CREQ allocation failed" ); + goto fail; + } + rcfw->cmdq.max_elements =BNXT_QPLIB_CMDQE_MAX_CNT ; +if (bnxt_qplib_alloc_init_hwq (rcfw->pdev, &rcfw->cmdq,NULL ,0 , + &rcfw->cmdq.max_elements, +BNXT_QPLIB_CMDQE_UNITS ,0 ,PAGE_SIZE , +HWQ_TYPE_CTX )) { +dev_err (&rcfw->pdev->dev, +"QPLIB: HW channel CMDQ allocation failed" ); + goto fail; + } + + rcfw->crsq.max_elements = rcfw->cmdq.max_elements; + rcfw->crsq.crsq =kcalloc (rcfw->crsq.max_elements, +sizeof (*rcfw->crsq.crsq),GFP_KERNEL ); +if (!rcfw->crsq.crsq) + goto fail; + + rcfw->crsb.max_elements =BNXT_QPLIB_CRSBE_MAX_CNT ; +if (bnxt_qplib_alloc_init_hwq (rcfw->pdev, &rcfw->crsb,NULL ,0 , + &rcfw->crsb.max_elements, +BNXT_QPLIB_CRSBE_UNITS ,0 ,PAGE_SIZE , +HWQ_TYPE_CTX )) { +dev_err (&rcfw->pdev->dev, +"QPLIB: HW channel CRSB allocation failed" ); + goto fail; + } +return 0 ; + +fail: +bnxt_qplib_free_rcfw_channel (rcfw); +return -ENOMEM ; +} + +void bnxt_qplib_disable_rcfw_channel (struct bnxt_qplib_rcfw *rcfw) +{ +unsigned long indx; + +/* Make sure the HW channel is stopped! */ +synchronize_irq (rcfw->vector); +tasklet_disable (&rcfw->worker); +tasklet_kill (&rcfw->worker); + +if (rcfw->requested) { +free_irq (rcfw->vector, rcfw); + rcfw->requested = false; + } +if (rcfw->cmdq_bar_reg_iomem) +iounmap (rcfw->cmdq_bar_reg_iomem); + rcfw->cmdq_bar_reg_iomem =NULL ; + +if (rcfw->creq_bar_reg_iomem) +iounmap (rcfw->creq_bar_reg_iomem); + rcfw->creq_bar_reg_iomem =NULL ; + + indx =find_first_bit (rcfw->cmdq_bitmap, rcfw->bmap_size); +if (indx != rcfw->bmap_size) +dev_err (&rcfw->pdev->dev, +"QPLIB: disabling RCFW with pending cmd-bit %lx" , indx); +kfree (rcfw->cmdq_bitmap); + rcfw->bmap_size =0 ; + + rcfw->aeq_handler =NULL ; + rcfw->vector =0 ; +} + +int bnxt_qplib_enable_rcfw_channel (struct pci_dev *pdev, +struct bnxt_qplib_rcfw *rcfw, +int msix_vector, +int cp_bar_reg_off,int virt_fn, +int (*aeq_handler)(struct bnxt_qplib_rcfw *, +struct creq_func_event *)) +{ +resource_size_t res_base; +struct cmdq_init init; +u16 bmap_size; +int rc; + +/* General */ +atomic_set (&rcfw->seq_num,0 ); + rcfw->flags =FIRMWARE_FIRST_FLAG ; + bmap_size =BITS_TO_LONGS (RCFW_MAX_OUTSTANDING_CMD * +sizeof (unsigned long )); + rcfw->cmdq_bitmap =kzalloc (bmap_size,GFP_KERNEL ); +if (!rcfw->cmdq_bitmap) +return -ENOMEM ; + rcfw->bmap_size = bmap_size; + +/* CMDQ */ + rcfw->cmdq_bar_reg =RCFW_COMM_PCI_BAR_REGION ; + res_base =pci_resource_start (pdev, rcfw->cmdq_bar_reg); +if (!res_base) +return -ENOMEM ; + + rcfw->cmdq_bar_reg_iomem =ioremap_nocache (res_base + +RCFW_COMM_BASE_OFFSET , +RCFW_COMM_SIZE ); +if (!rcfw->cmdq_bar_reg_iomem) { +dev_err (&rcfw->pdev->dev, +"QPLIB: CMDQ BAR region %d mapping failed" , + rcfw->cmdq_bar_reg); +return -ENOMEM ; + } + + rcfw->cmdq_bar_reg_prod_off = virt_fn ?RCFW_VF_COMM_PROD_OFFSET : +RCFW_PF_COMM_PROD_OFFSET ; + + rcfw->cmdq_bar_reg_trig_off =RCFW_COMM_TRIG_OFFSET ; + +/* CRSQ */ + rcfw->crsq.prod =0 ; + rcfw->crsq.cons =0 ; + +/* CREQ */ + rcfw->creq_bar_reg =RCFW_COMM_CONS_PCI_BAR_REGION ; + res_base =pci_resource_start (pdev, rcfw->creq_bar_reg); +if (!res_base) +dev_err (&rcfw->pdev->dev, +"QPLIB: CREQ BAR region %d resc start is 0!" , + rcfw->creq_bar_reg); + rcfw->creq_bar_reg_iomem =ioremap_nocache (res_base + cp_bar_reg_off, +4 ); +if (!rcfw->creq_bar_reg_iomem) { +dev_err (&rcfw->pdev->dev, +"QPLIB: CREQ BAR region %d mapping failed" , + rcfw->creq_bar_reg); +return -ENOMEM ; + } + rcfw->creq_qp_event_processed =0 ; + rcfw->creq_func_event_processed =0 ; + + rcfw->vector = msix_vector; +if (aeq_handler) + rcfw->aeq_handler = aeq_handler; + +tasklet_init (&rcfw->worker, bnxt_qplib_service_creq, + (unsigned long )rcfw); + + rcfw->requested = false; + rc =request_irq (rcfw->vector, bnxt_qplib_creq_irq,0 , +"bnxt_qplib_creq" , rcfw); +if (rc) { +dev_err (&rcfw->pdev->dev, +"QPLIB: Failed to request IRQ for CREQ rc = 0x%x" , rc); +bnxt_qplib_disable_rcfw_channel (rcfw); +return rc; + } + rcfw->requested = true; + +init_waitqueue_head (&rcfw->waitq); + +CREQ_DB_REARM (rcfw->creq_bar_reg_iomem,0 , rcfw->creq.max_elements); + + init.cmdq_pbl =cpu_to_le64 (rcfw->cmdq.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + init.cmdq_size_cmdq_lvl =cpu_to_le16 ( + ((BNXT_QPLIB_CMDQE_MAX_CNT <<CMDQ_INIT_CMDQ_SIZE_SFT ) & +CMDQ_INIT_CMDQ_SIZE_MASK ) | + ((rcfw->cmdq.level <<CMDQ_INIT_CMDQ_LVL_SFT ) & +CMDQ_INIT_CMDQ_LVL_MASK )); + init.creq_ring_id =cpu_to_le16 (rcfw->creq_ring_id); + +/* Write to the Bono mailbox register */ +__iowrite32_copy (rcfw->cmdq_bar_reg_iomem, &init,sizeof (init) /4 ); +return 0 ; +}drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h +176
-0@@ -14,4 +14,180 @@#ifndef __BNXT_QPLIB_RCFW_H__#define __BNXT_QPLIB_RCFW_H__ +#define RCFW_CMDQ_TRIG_VAL 1 +#define RCFW_COMM_PCI_BAR_REGION 0 +#define RCFW_COMM_CONS_PCI_BAR_REGION 2 +#define RCFW_COMM_BASE_OFFSET 0x600 +#define RCFW_PF_COMM_PROD_OFFSET 0x7c +#define RCFW_VF_COMM_PROD_OFFSET 0xc +#define RCFW_COMM_TRIG_OFFSET 0x100 +#define RCFW_COMM_SIZE 0x104 + +#define RCFW_DBR_PCI_BAR_REGION 2 + +#define RCFW_CMD_PREP (req,CMD , cmd_flags) \ + do { \ + memset(&(req), 0, sizeof((req))); \ + (req).opcode = CMDQ_BASE_OPCODE_##CMD; \ + (req).cmd_size = (sizeof((req)) + \ + BNXT_QPLIB_CMDQE_UNITS - 1) / \ + BNXT_QPLIB_CMDQE_UNITS; \ + (req).flags = cpu_to_le16(cmd_flags); \ + } while (0) + +#define RCFW_RESP_STATUS (resp) ((resp)->status) + +#define RCFW_CMDQ_COOKIE (req) le16_to_cpu(req.cookie) + +#define RCFW_RESP_COOKIE (resp) le16_to_cpu((resp)->cookie) + +#define RCFW_CMD_WAIT_TIME_MS 20000/* 20 Seconds timeout */ + +/* CMDQ elements */ +#define BNXT_QPLIB_CMDQE_MAX_CNT 256 +#define BNXT_QPLIB_CMDQE_UNITS sizeof(struct bnxt_qplib_cmdqe) +#define BNXT_QPLIB_CMDQE_CNT_PER_PG (PAGE_SIZE / BNXT_QPLIB_CMDQE_UNITS) + +#define MAX_CMDQ_IDX (BNXT_QPLIB_CMDQE_MAX_CNT - 1) +#define MAX_CMDQ_IDX_PER_PG (BNXT_QPLIB_CMDQE_CNT_PER_PG - 1) + +#define CMDQ_PG (x) \ + (((x) & ~MAX_CMDQ_IDX_PER_PG) / BNXT_QPLIB_CMDQE_CNT_PER_PG) +#define CMDQ_IDX (x) ((x) & MAX_CMDQ_IDX_PER_PG) + +#define RCFW_MAX_OUTSTANDING_CMD BNXT_QPLIB_CMDQE_MAX_CNT +#define RCFW_MAX_COOKIE_VALUE 0x7FFF +#define RCFW_CMD_IS_BLOCKING 0x8000 + +/* Cmdq contains a fix number of a 16-Byte slots */ +struct bnxt_qplib_cmdqe { +u8 data[16 ]; +}; + +/* CRSQ SB */ +#define BNXT_QPLIB_CRSBE_MAX_CNT 4 +#define BNXT_QPLIB_CRSBE_UNITS sizeof(struct bnxt_qplib_crsbe) +#define BNXT_QPLIB_CRSBE_CNT_PER_PG (PAGE_SIZE / BNXT_QPLIB_CRSBE_UNITS) + +#define MAX_CRSB_IDX (BNXT_QPLIB_CRSBE_MAX_CNT - 1) +#define MAX_CRSB_IDX_PER_PG (BNXT_QPLIB_CRSBE_CNT_PER_PG - 1) + +#define CRSB_PG (x) \ + (((x) & ~MAX_CRSB_IDX_PER_PG) / BNXT_QPLIB_CRSBE_CNT_PER_PG) +#define CRSB_IDX (x) ((x) & MAX_CRSB_IDX_PER_PG) + +/* Crsq buf is 1024-Byte */ +struct bnxt_qplib_crsbe { +u8 data[1024 ]; +}; + +#define BNXT_QPLIB_CRSB_DMA_NEXT (pg_map_arr, prod, dma_addr) \ + do { \ + dma_addr = pg_map_arr[(prod) / BNXT_QPLIB_CRSBE_CNT_PER_PG];\ + dma_addr += ((prod) % BNXT_QPLIB_CRSBE_CNT_PER_PG) * \ + BNXT_QPLIB_CRSBE_UNITS; \ + } while (0) + +/* CREQ */ +/* Allocate 1 per QP for async error notification for now */ +#define BNXT_QPLIB_CREQE_MAX_CNT (64 * 1024) +#define BNXT_QPLIB_CREQE_UNITS 16/* 16-Bytes per prod unit */ +#define BNXT_QPLIB_CREQE_CNT_PER_PG (PAGE_SIZE / BNXT_QPLIB_CREQE_UNITS) + +#define MAX_CREQ_IDX (BNXT_QPLIB_CREQE_MAX_CNT - 1) +#define MAX_CREQ_IDX_PER_PG (BNXT_QPLIB_CREQE_CNT_PER_PG - 1) + +#define CREQ_PG (x) \ + (((x) & ~MAX_CREQ_IDX_PER_PG) / BNXT_QPLIB_CREQE_CNT_PER_PG) +#define CREQ_IDX (x) ((x) & MAX_CREQ_IDX_PER_PG) + +#define BNXT_QPLIB_CREQE_PER_PG (PAGE_SIZE / sizeof(struct creq_base)) + +#define CREQ_CMP_VALID (hdr, raw_cons, cp_bit) \ + (!!((hdr)->v & CREQ_BASE_V) == \ + !((raw_cons) & (cp_bit))) + +#define CREQ_DB_KEY_CP (0x2 << CMPL_DOORBELL_KEY_SFT) +#define CREQ_DB_IDX_VALID CMPL_DOORBELL_IDX_VALID +#define CREQ_DB_IRQ_DIS CMPL_DOORBELL_MASK +#define CREQ_DB_CP_FLAGS_REARM (CREQ_DB_KEY_CP | \ + CREQ_DB_IDX_VALID) +#define CREQ_DB_CP_FLAGS (CREQ_DB_KEY_CP | \ + CREQ_DB_IDX_VALID | \ + CREQ_DB_IRQ_DIS) +#define CREQ_DB_REARM (db, raw_cons, cp_bit) \ + writel(CREQ_DB_CP_FLAGS_REARM | ((raw_cons) & ((cp_bit) - 1)), db) +#define CREQ_DB (db, raw_cons, cp_bit) \ + writel(CREQ_DB_CP_FLAGS | ((raw_cons) & ((cp_bit) - 1)), db) + +/* HWQ */ +struct bnxt_qplib_crsqe { +struct creq_qp_event qp_event; +u32 req_size; +}; + +struct bnxt_qplib_crsq { +struct bnxt_qplib_crsqe *crsq; +u32 prod; +u32 cons; +u32 max_elements; +}; + +/* RCFW Communication Channels */ +struct bnxt_qplib_rcfw { +struct pci_dev *pdev; +int vector; +struct tasklet_struct worker; +bool requested; +unsigned long *cmdq_bitmap; +u32 bmap_size; +unsigned long flags; +#define FIRMWARE_INITIALIZED_FLAG BIT(0) +#define FIRMWARE_FIRST_FLAG BIT(31) +wait_queue_head_t waitq; +int (*aeq_handler)(struct bnxt_qplib_rcfw *, +struct creq_func_event *); +atomic_t seq_num; + +/* Bar region info */ +void __iomem *cmdq_bar_reg_iomem; +u16 cmdq_bar_reg; +u16 cmdq_bar_reg_prod_off; +u16 cmdq_bar_reg_trig_off; +u16 creq_ring_id; +u16 creq_bar_reg; +void __iomem *creq_bar_reg_iomem; + +/* Cmd-Resp and Async Event notification queue */ +struct bnxt_qplib_hwq creq; +u64 creq_qp_event_processed; +u64 creq_func_event_processed; + +/* Actual Cmd and Resp Queues */ +struct bnxt_qplib_hwq cmdq; +struct bnxt_qplib_crsq crsq; +struct bnxt_qplib_hwq crsb; +}; + +void bnxt_qplib_free_rcfw_channel (struct bnxt_qplib_rcfw *rcfw); +int bnxt_qplib_alloc_rcfw_channel (struct pci_dev *pdev, +struct bnxt_qplib_rcfw *rcfw); +void bnxt_qplib_disable_rcfw_channel (struct bnxt_qplib_rcfw *rcfw); +int bnxt_qplib_enable_rcfw_channel (struct pci_dev *pdev, +struct bnxt_qplib_rcfw *rcfw, +int msix_vector, +int cp_bar_reg_off,int virt_fn, +int (*aeq_handler) + (struct bnxt_qplib_rcfw *, +struct creq_func_event *)); + +int bnxt_qplib_rcfw_block_for_resp (struct bnxt_qplib_rcfw *rcfw,u16 cookie); +int bnxt_qplib_rcfw_wait_for_resp (struct bnxt_qplib_rcfw *rcfw,u16 cookie); +void *bnxt_qplib_rcfw_send_message (struct bnxt_qplib_rcfw *rcfw, +struct cmdq_base *req,void **crsbe, +u8 is_block); + +int bnxt_qplib_deinit_rcfw (struct bnxt_qplib_rcfw *rcfw); +int bnxt_qplib_init_rcfw (struct bnxt_qplib_rcfw *rcfw, +struct bnxt_qplib_ctx *ctx,int is_virtfn);#endif /* __BNXT_QPLIB_RCFW_H__ */ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c +740
-0@@ -10,3 +10,743 @@/* * Description: QPLib resource manager */ + +#include <linux/spinlock.h> +#include <linux/pci.h> +#include <linux/interrupt.h> +#include <linux/inetdevice.h> +#include <linux/dma-mapping.h> +#include <linux/if_vlan.h> +#include "bnxt_re_hsi.h" +#include "bnxt_qplib_res.h" +#include "bnxt_qplib_sp.h" +#include "bnxt_qplib_rcfw.h" + +static void bnxt_qplib_free_stats_ctx (struct pci_dev *pdev, +struct bnxt_qplib_stats *stats); +static int bnxt_qplib_alloc_stats_ctx (struct pci_dev *pdev, +struct bnxt_qplib_stats *stats); + +/* PBL */ +static void __free_pbl (struct pci_dev *pdev,struct bnxt_qplib_pbl *pbl, +bool is_umem) +{ +int i; + +if (!is_umem) { +for (i =0 ; i < pbl->pg_count; i++) { +if (pbl->pg_arr[i]) +dma_free_coherent (&pdev->dev, pbl->pg_size, + (void *)((u64 )pbl->pg_arr[i] & +PAGE_MASK ), + pbl->pg_map_arr[i]); +else +dev_warn (&pdev->dev, +"QPLIB: PBL free pg_arr[%d] empty?!" , + i); + pbl->pg_arr[i] =NULL ; + } + } +kfree (pbl->pg_arr); + pbl->pg_arr =NULL ; +kfree (pbl->pg_map_arr); + pbl->pg_map_arr =NULL ; + pbl->pg_count =0 ; + pbl->pg_size =0 ; +} + +static int __alloc_pbl (struct pci_dev *pdev,struct bnxt_qplib_pbl *pbl, +struct scatterlist *sghead,u32 pages,u32 pg_size) +{ +struct scatterlist *sg; +bool is_umem = false; +int i; + +/* page ptr arrays */ + pbl->pg_arr =kcalloc (pages,sizeof (void *),GFP_KERNEL ); +if (!pbl->pg_arr) +return -ENOMEM ; + + pbl->pg_map_arr =kcalloc (pages,sizeof (dma_addr_t),GFP_KERNEL ); +if (!pbl->pg_map_arr) { +kfree (pbl->pg_arr); + pbl->pg_arr =NULL ; +return -ENOMEM ; + } + pbl->pg_count =0 ; + pbl->pg_size = pg_size; + +if (!sghead) { +for (i =0 ; i < pages; i++) { + pbl->pg_arr[i] =dma_alloc_coherent (&pdev->dev, + pbl->pg_size, + &pbl->pg_map_arr[i], +GFP_KERNEL ); +if (!pbl->pg_arr[i]) + goto fail; +memset (pbl->pg_arr[i],0 , pbl->pg_size); + pbl->pg_count++; + } + }else { + i =0 ; + is_umem = true; +for_each_sg (sghead, sg, pages, i) { + pbl->pg_map_arr[i] =sg_dma_address (sg); + pbl->pg_arr[i] =sg_virt (sg); +if (!pbl->pg_arr[i]) + goto fail; + + pbl->pg_count++; + } + } + +return 0 ; + +fail: +__free_pbl (pdev, pbl, is_umem); +return -ENOMEM ; +} + +/* HWQ */ +void bnxt_qplib_free_hwq (struct pci_dev *pdev,struct bnxt_qplib_hwq *hwq) +{ +int i; + +if (!hwq->max_elements) +return ; +if (hwq->level >=PBL_LVL_MAX ) +return ; + +for (i =0 ; i < hwq->level +1 ; i++) { +if (i == hwq->level) +__free_pbl (pdev, &hwq->pbl[i], hwq->is_user); +else +__free_pbl (pdev, &hwq->pbl[i], false); + } + + hwq->level =PBL_LVL_MAX ; + hwq->max_elements =0 ; + hwq->element_size =0 ; + hwq->prod =0 ; + hwq->cons =0 ; + hwq->cp_bit =0 ; +} + +/* All HWQs are power of 2 in size */ +int bnxt_qplib_alloc_init_hwq (struct pci_dev *pdev,struct bnxt_qplib_hwq *hwq, +struct scatterlist *sghead,int nmap, +u32 *elements,u32 element_size,u32 aux, +u32 pg_size,enum bnxt_qplib_hwq_type hwq_type) +{ +u32 pages, slots, size, aux_pages =0 , aux_size =0 ; +dma_addr_t *src_phys_ptr, **dst_virt_ptr; +int i, rc; + + hwq->level =PBL_LVL_MAX ; + +if (*elements <0 ) +return -EINVAL ; + + slots =roundup_pow_of_two (*elements); +if (aux) { + aux_size =roundup_pow_of_two (aux); + aux_pages = (slots * aux_size) / pg_size; +if ((slots * aux_size) % pg_size) + aux_pages++; + } + size =roundup_pow_of_two (element_size); + +if (!sghead) { + hwq->is_user = false; + pages = (slots * size) / pg_size + aux_pages; +if ((slots * size) % pg_size) + pages++; +if (!pages) +return -EINVAL ; + }else { + hwq->is_user = true; + pages = nmap; + } + +/* Alloc the 1st memory block; can be a PDL/PTL/PBL */ +if (sghead && (pages ==MAX_PBL_LVL_0_PGS )) + rc =__alloc_pbl (pdev, &hwq->pbl[PBL_LVL_0 ], sghead, + pages, pg_size); +else + rc =__alloc_pbl (pdev, &hwq->pbl[PBL_LVL_0 ],NULL ,1 , pg_size); +if (rc) + goto fail; + + hwq->level =PBL_LVL_0 ; + +if (pages >MAX_PBL_LVL_0_PGS ) { +if (pages >MAX_PBL_LVL_1_PGS ) { +/* 2 levels of indirection */ + rc =__alloc_pbl (pdev, &hwq->pbl[PBL_LVL_1 ],NULL , +MAX_PBL_LVL_1_PGS_FOR_LVL_2 , pg_size); +if (rc) + goto fail; +/* Fill in lvl0 PBL */ + dst_virt_ptr = + (dma_addr_t **)hwq->pbl[PBL_LVL_0 ].pg_arr; + src_phys_ptr = hwq->pbl[PBL_LVL_1 ].pg_map_arr; +for (i =0 ; i < hwq->pbl[PBL_LVL_1 ].pg_count; i++) + dst_virt_ptr[PTR_PG (i)][PTR_IDX (i)] = + src_phys_ptr[i] |PTU_PDE_VALID ; + hwq->level =PBL_LVL_1 ; + + rc =__alloc_pbl (pdev, &hwq->pbl[PBL_LVL_2 ], sghead, + pages, pg_size); +if (rc) + goto fail; + +/* Fill in lvl1 PBL */ + dst_virt_ptr = + (dma_addr_t **)hwq->pbl[PBL_LVL_1 ].pg_arr; + src_phys_ptr = hwq->pbl[PBL_LVL_2 ].pg_map_arr; +for (i =0 ; i < hwq->pbl[PBL_LVL_2 ].pg_count; i++) { + dst_virt_ptr[PTR_PG (i)][PTR_IDX (i)] = + src_phys_ptr[i] |PTU_PTE_VALID ; + } +if (hwq_type ==HWQ_TYPE_QUEUE ) { +/* Find the last pg of the size */ + i = hwq->pbl[PBL_LVL_2 ].pg_count; + dst_virt_ptr[PTR_PG (i -1 )][PTR_IDX (i -1 )] |= +PTU_PTE_LAST ; +if (i >1 ) + dst_virt_ptr[PTR_PG (i -2 )] + [PTR_IDX (i -2 )] |= +PTU_PTE_NEXT_TO_LAST ; + } + hwq->level =PBL_LVL_2 ; + }else { +u32 flag = hwq_type ==HWQ_TYPE_L2_CMPL ?0 : +PTU_PTE_VALID ; + +/* 1 level of indirection */ + rc =__alloc_pbl (pdev, &hwq->pbl[PBL_LVL_1 ], sghead, + pages, pg_size); +if (rc) + goto fail; +/* Fill in lvl0 PBL */ + dst_virt_ptr = + (dma_addr_t **)hwq->pbl[PBL_LVL_0 ].pg_arr; + src_phys_ptr = hwq->pbl[PBL_LVL_1 ].pg_map_arr; +for (i =0 ; i < hwq->pbl[PBL_LVL_1 ].pg_count; i++) { + dst_virt_ptr[PTR_PG (i)][PTR_IDX (i)] = + src_phys_ptr[i] | flag; + } +if (hwq_type ==HWQ_TYPE_QUEUE ) { +/* Find the last pg of the size */ + i = hwq->pbl[PBL_LVL_1 ].pg_count; + dst_virt_ptr[PTR_PG (i -1 )][PTR_IDX (i -1 )] |= +PTU_PTE_LAST ; +if (i >1 ) + dst_virt_ptr[PTR_PG (i -2 )] + [PTR_IDX (i -2 )] |= +PTU_PTE_NEXT_TO_LAST ; + } + hwq->level =PBL_LVL_1 ; + } + } + hwq->pdev = pdev; +spin_lock_init (&hwq->lock); + hwq->prod =0 ; + hwq->cons =0 ; + *elements = hwq->max_elements = slots; + hwq->element_size = size; + +/* For direct access to the elements */ + hwq->pbl_ptr = hwq->pbl[hwq->level].pg_arr; + hwq->pbl_dma_ptr = hwq->pbl[hwq->level].pg_map_arr; + +return 0 ; + +fail: +bnxt_qplib_free_hwq (pdev, hwq); +return -ENOMEM ; +} + +/* Context Tables */ +void bnxt_qplib_free_ctx (struct pci_dev *pdev, +struct bnxt_qplib_ctx *ctx) +{ +int i; + +bnxt_qplib_free_hwq (pdev, &ctx->qpc_tbl); +bnxt_qplib_free_hwq (pdev, &ctx->mrw_tbl); +bnxt_qplib_free_hwq (pdev, &ctx->srqc_tbl); +bnxt_qplib_free_hwq (pdev, &ctx->cq_tbl); +bnxt_qplib_free_hwq (pdev, &ctx->tim_tbl); +for (i =0 ; i <MAX_TQM_ALLOC_REQ ; i++) +bnxt_qplib_free_hwq (pdev, &ctx->tqm_tbl[i]); +bnxt_qplib_free_hwq (pdev, &ctx->tqm_pde); +bnxt_qplib_free_stats_ctx (pdev, &ctx->stats); +} + +/* +* Routine: bnxt_qplib_alloc_ctx +* Description: +* Context tables are memories which are used by the chip fw. +* The 6 tables defined are: +* QPC ctx - holds QP states +* MRW ctx - holds memory region and window +* SRQ ctx - holds shared RQ states +* CQ ctx - holds completion queue states +* TQM ctx - holds Tx Queue Manager context +* TIM ctx - holds timer context +* Depending on the size of the tbl requested, either a 1 Page Buffer List +* or a 1-to-2-stage indirection Page Directory List + 1 PBL is used +* instead. +* Table might be employed as follows: +* For 0 < ctx size <= 1 PAGE, 0 level of ind is used +* For 1 PAGE < ctx size <= 512 entries size, 1 level of ind is used +* For 512 < ctx size <= MAX, 2 levels of ind is used +* Returns: +* 0 if success, else -ERRORS +*/ +int bnxt_qplib_alloc_ctx (struct pci_dev *pdev, +struct bnxt_qplib_ctx *ctx, +bool virt_fn) +{ +int i, j, k, rc =0 ; +int fnz_idx =-1 ; +u64 **pbl_ptr; + +if (virt_fn) + goto stats_alloc; + +/* QPC Tables */ + ctx->qpc_tbl.max_elements = ctx->qpc_count; + rc =bnxt_qplib_alloc_init_hwq (pdev, &ctx->qpc_tbl,NULL ,0 , + &ctx->qpc_tbl.max_elements, +BNXT_QPLIB_MAX_QP_CTX_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_CTX ); +if (rc) + goto fail; + +/* MRW Tables */ + ctx->mrw_tbl.max_elements = ctx->mrw_count; + rc =bnxt_qplib_alloc_init_hwq (pdev, &ctx->mrw_tbl,NULL ,0 , + &ctx->mrw_tbl.max_elements, +BNXT_QPLIB_MAX_MRW_CTX_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_CTX ); +if (rc) + goto fail; + +/* SRQ Tables */ + ctx->srqc_tbl.max_elements = ctx->srqc_count; + rc =bnxt_qplib_alloc_init_hwq (pdev, &ctx->srqc_tbl,NULL ,0 , + &ctx->srqc_tbl.max_elements, +BNXT_QPLIB_MAX_SRQ_CTX_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_CTX ); +if (rc) + goto fail; + +/* CQ Tables */ + ctx->cq_tbl.max_elements = ctx->cq_count; + rc =bnxt_qplib_alloc_init_hwq (pdev, &ctx->cq_tbl,NULL ,0 , + &ctx->cq_tbl.max_elements, +BNXT_QPLIB_MAX_CQ_CTX_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_CTX ); +if (rc) + goto fail; + +/* TQM Buffer */ + ctx->tqm_pde.max_elements =512 ; + rc =bnxt_qplib_alloc_init_hwq (pdev, &ctx->tqm_pde,NULL ,0 , + &ctx->tqm_pde.max_elements,sizeof (u64), +0 ,PAGE_SIZE ,HWQ_TYPE_CTX ); +if (rc) + goto fail; + +for (i =0 ; i <MAX_TQM_ALLOC_REQ ; i++) { +if (!ctx->tqm_count[i]) +continue ; + ctx->tqm_tbl[i].max_elements = ctx->qpc_count * + ctx->tqm_count[i]; + rc =bnxt_qplib_alloc_init_hwq (pdev, &ctx->tqm_tbl[i],NULL ,0 , + &ctx->tqm_tbl[i].max_elements,1 , +0 ,PAGE_SIZE ,HWQ_TYPE_CTX ); +if (rc) + goto fail; + } + pbl_ptr = (u64 **)ctx->tqm_pde.pbl_ptr; +for (i =0 , j =0 ; i <MAX_TQM_ALLOC_REQ ; + i++, j +=MAX_TQM_ALLOC_BLK_SIZE ) { +if (!ctx->tqm_tbl[i].max_elements) +continue ; +if (fnz_idx ==-1 ) + fnz_idx = i; +switch (ctx->tqm_tbl[i].level) { +case PBL_LVL_2 : +for (k =0 ; k < ctx->tqm_tbl[i].pbl[PBL_LVL_1 ].pg_count; + k++) + pbl_ptr[PTR_PG (j + k)][PTR_IDX (j + k)] = +cpu_to_le64 ( + ctx->tqm_tbl[i].pbl[PBL_LVL_1 ].pg_map_arr[k] + |PTU_PTE_VALID ); +break ; +case PBL_LVL_1 : +case PBL_LVL_0 : +default : + pbl_ptr[PTR_PG (j)][PTR_IDX (j)] =cpu_to_le64 ( + ctx->tqm_tbl[i].pbl[PBL_LVL_0 ].pg_map_arr[0 ] | +PTU_PTE_VALID ); +break ; + } + } +if (fnz_idx ==-1 ) + fnz_idx =0 ; + ctx->tqm_pde_level = ctx->tqm_tbl[fnz_idx].level ==PBL_LVL_2 ? +PBL_LVL_2 : ctx->tqm_tbl[fnz_idx].level +1 ; + +/* TIM Buffer */ + ctx->tim_tbl.max_elements = ctx->qpc_count *16 ; + rc =bnxt_qplib_alloc_init_hwq (pdev, &ctx->tim_tbl,NULL ,0 , + &ctx->tim_tbl.max_elements,1 , +0 ,PAGE_SIZE ,HWQ_TYPE_CTX ); +if (rc) + goto fail; + +stats_alloc: +/* Stats */ + rc =bnxt_qplib_alloc_stats_ctx (pdev, &ctx->stats); +if (rc) + goto fail; + +return 0 ; + +fail: +bnxt_qplib_free_ctx (pdev, ctx); +return rc; +} + +static void bnxt_qplib_free_sgid_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_sgid_tbl *sgid_tbl) +{ +kfree (sgid_tbl->tbl); +kfree (sgid_tbl->hw_id); +kfree (sgid_tbl->ctx); + sgid_tbl->tbl =NULL ; + sgid_tbl->hw_id =NULL ; + sgid_tbl->ctx =NULL ; + sgid_tbl->max =0 ; + sgid_tbl->active =0 ; +} + +static int bnxt_qplib_alloc_sgid_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_sgid_tbl *sgid_tbl, +u16 max) +{ + sgid_tbl->tbl =kcalloc (max,sizeof (struct bnxt_qplib_gid ),GFP_KERNEL ); +if (!sgid_tbl->tbl) +return -ENOMEM ; + + sgid_tbl->hw_id =kcalloc (max,sizeof (u32),GFP_KERNEL ); +if (!sgid_tbl->hw_id) + goto out_free1; + + sgid_tbl->ctx =kcalloc (max,sizeof (void *),GFP_KERNEL ); +if (!sgid_tbl->ctx) + goto out_free2; + + sgid_tbl->max = max; +return 0 ; +out_free2: +kfree (sgid_tbl->hw_id); + sgid_tbl->hw_id =NULL ; +out_free1: +kfree (sgid_tbl->tbl); + sgid_tbl->tbl =NULL ; +return -ENOMEM ; +}; + +static void bnxt_qplib_cleanup_sgid_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_sgid_tbl *sgid_tbl) +{ +int i; + +memset (sgid_tbl->tbl,0 ,sizeof (struct bnxt_qplib_gid ) * sgid_tbl->max); +memset (sgid_tbl->hw_id,-1 ,sizeof (u16) * sgid_tbl->max); + sgid_tbl->active =0 ; +} + +static void bnxt_qplib_init_sgid_tbl (struct bnxt_qplib_sgid_tbl *sgid_tbl, +struct net_device *netdev) +{ +memset (sgid_tbl->tbl,0 ,sizeof (struct bnxt_qplib_gid ) * sgid_tbl->max); +memset (sgid_tbl->hw_id,-1 ,sizeof (u16) * sgid_tbl->max); +} + +static void bnxt_qplib_free_pkey_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl) +{ +if (!pkey_tbl->tbl) +dev_dbg (&res->pdev->dev,"QPLIB: PKEY tbl not present" ); +else +kfree (pkey_tbl->tbl); + + pkey_tbl->tbl =NULL ; + pkey_tbl->max =0 ; + pkey_tbl->active =0 ; +} + +static int bnxt_qplib_alloc_pkey_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl, +u16 max) +{ + pkey_tbl->tbl =kcalloc (max,sizeof (u16),GFP_KERNEL ); +if (!pkey_tbl->tbl) +return -ENOMEM ; + + pkey_tbl->max = max; +return 0 ; +}; + +static void bnxt_qplib_free_pd_tbl (struct bnxt_qplib_pd_tbl *pdt) +{ +kfree (pdt->tbl); + pdt->tbl =NULL ; + pdt->max =0 ; +} + +static int bnxt_qplib_alloc_pd_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_pd_tbl *pdt, +u32 max) +{ +u32 bytes; + + bytes = max >>3 ; +if (!bytes) + bytes =1 ; + pdt->tbl =kmalloc (bytes,GFP_KERNEL ); +if (!pdt->tbl) +return -ENOMEM ; + + pdt->max = max; +memset ((u8 *)pdt->tbl,0xFF , bytes); + +return 0 ; +} + +/* DPIs */ +int bnxt_qplib_alloc_dpi (struct bnxt_qplib_dpi_tbl *dpit, +struct bnxt_qplib_dpi *dpi, +void *app) +{ +u32 bit_num; + + bit_num =find_first_bit (dpit->tbl, dpit->max); +if (bit_num == dpit->max) +return -ENOMEM ; + +/* Found unused DPI */ +clear_bit (bit_num, dpit->tbl); + dpit->app_tbl[bit_num] = app; + + dpi->dpi = bit_num; + dpi->dbr = dpit->dbr_bar_reg_iomem + (bit_num *PAGE_SIZE ); + dpi->umdbr = dpit->unmapped_dbr + (bit_num *PAGE_SIZE ); + +return 0 ; +} + +int bnxt_qplib_dealloc_dpi (struct bnxt_qplib_res *res, +struct bnxt_qplib_dpi_tbl *dpit, +struct bnxt_qplib_dpi *dpi) +{ +if (dpi->dpi >= dpit->max) { +dev_warn (&res->pdev->dev,"Invalid DPI? dpi = %d" , dpi->dpi); +return -EINVAL ; + } +if (test_and_set_bit (dpi->dpi, dpit->tbl)) { +dev_warn (&res->pdev->dev,"Freeing an unused DPI? dpi = %d" , + dpi->dpi); +return -EINVAL ; + } +if (dpit->app_tbl) + dpit->app_tbl[dpi->dpi] =NULL ; +memset (dpi,0 ,sizeof (*dpi)); + +return 0 ; +} + +static void bnxt_qplib_free_dpi_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_dpi_tbl *dpit) +{ +kfree (dpit->tbl); +kfree (dpit->app_tbl); +if (dpit->dbr_bar_reg_iomem) +pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem); +memset (dpit,0 ,sizeof (*dpit)); +} + +static int bnxt_qplib_alloc_dpi_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_dpi_tbl *dpit, +u32 dbr_offset) +{ +u32 dbr_bar_reg =RCFW_DBR_PCI_BAR_REGION ; +resource_size_t bar_reg_base; +u32 dbr_len, bytes; + +if (dpit->dbr_bar_reg_iomem) { +dev_err (&res->pdev->dev, +"QPLIB: DBR BAR region %d already mapped" , dbr_bar_reg); +return -EALREADY ; + } + + bar_reg_base =pci_resource_start (res->pdev, dbr_bar_reg); +if (!bar_reg_base) { +dev_err (&res->pdev->dev, +"QPLIB: BAR region %d resc start failed" , dbr_bar_reg); +return -ENOMEM ; + } + + dbr_len =pci_resource_len (res->pdev, dbr_bar_reg) - dbr_offset; +if (!dbr_len || ((dbr_len & (PAGE_SIZE -1 )) !=0 )) { +dev_err (&res->pdev->dev,"QPLIB: Invalid DBR length %d" , + dbr_len); +return -ENOMEM ; + } + + dpit->dbr_bar_reg_iomem =ioremap_nocache (bar_reg_base + dbr_offset, + dbr_len); +if (!dpit->dbr_bar_reg_iomem) { +dev_err (&res->pdev->dev, +"QPLIB: FP: DBR BAR region %d mapping failed" , + dbr_bar_reg); +return -ENOMEM ; + } + + dpit->unmapped_dbr = bar_reg_base + dbr_offset; + dpit->max = dbr_len /PAGE_SIZE ; + + dpit->app_tbl =kcalloc (dpit->max,sizeof (void *),GFP_KERNEL ); +if (!dpit->app_tbl) { +pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem); +dev_err (&res->pdev->dev, +"QPLIB: DPI app tbl allocation failed" ); +return -ENOMEM ; + } + + bytes = dpit->max >>3 ; +if (!bytes) + bytes =1 ; + + dpit->tbl =kmalloc (bytes,GFP_KERNEL ); +if (!dpit->tbl) { +pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem); +kfree (dpit->app_tbl); + dpit->app_tbl =NULL ; +dev_err (&res->pdev->dev, +"QPLIB: DPI tbl allocation failed for size = %d" , + bytes); +return -ENOMEM ; + } + +memset ((u8 *)dpit->tbl,0xFF , bytes); + +return 0 ; +} + +/* PKEYs */ +void bnxt_qplib_cleanup_pkey_tbl (struct bnxt_qplib_pkey_tbl *pkey_tbl) +{ +memset (pkey_tbl->tbl,0 ,sizeof (u16) * pkey_tbl->max); + pkey_tbl->active =0 ; +} + +static void bnxt_qplib_init_pkey_tbl (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl) +{ +u16 pkey =0xFFFF ; + +memset (pkey_tbl->tbl,0 ,sizeof (u16) * pkey_tbl->max); + +/* pkey default = 0xFFFF */ +bnxt_qplib_add_pkey (res, pkey_tbl, &pkey, false); +} + +/* Stats */ +static void bnxt_qplib_free_stats_ctx (struct pci_dev *pdev, +struct bnxt_qplib_stats *stats) +{ +if (stats->dma) { +dma_free_coherent (&pdev->dev, stats->size, + stats->dma, stats->dma_map); + } +memset (stats,0 ,sizeof (*stats)); + stats->fw_id =-1 ; +} + +static int bnxt_qplib_alloc_stats_ctx (struct pci_dev *pdev, +struct bnxt_qplib_stats *stats) +{ +memset (stats,0 ,sizeof (*stats)); + stats->fw_id =-1 ; + stats->size =sizeof (ctx_hw_stats_t); + stats->dma =dma_alloc_coherent (&pdev->dev, stats->size, + &stats->dma_map,GFP_KERNEL ); +if (!stats->dma) { +dev_err (&pdev->dev,"QPLIB: Stats DMA allocation failed" ); +return -ENOMEM ; + } +return 0 ; +} + +void bnxt_qplib_cleanup_res (struct bnxt_qplib_res *res) +{ +bnxt_qplib_cleanup_pkey_tbl (&res->pkey_tbl); +bnxt_qplib_cleanup_sgid_tbl (res, &res->sgid_tbl); +} + +int bnxt_qplib_init_res (struct bnxt_qplib_res *res) +{ +bnxt_qplib_init_sgid_tbl (&res->sgid_tbl, res->netdev); +bnxt_qplib_init_pkey_tbl (res, &res->pkey_tbl); + +return 0 ; +} + +void bnxt_qplib_free_res (struct bnxt_qplib_res *res) +{ +bnxt_qplib_free_pkey_tbl (res, &res->pkey_tbl); +bnxt_qplib_free_sgid_tbl (res, &res->sgid_tbl); +bnxt_qplib_free_pd_tbl (&res->pd_tbl); +bnxt_qplib_free_dpi_tbl (res, &res->dpi_tbl); + + res->netdev =NULL ; + res->pdev =NULL ; +} + +int bnxt_qplib_alloc_res (struct bnxt_qplib_res *res,struct pci_dev *pdev, +struct net_device *netdev, +struct bnxt_qplib_dev_attr *dev_attr) +{ +int rc =0 ; + + res->pdev = pdev; + res->netdev = netdev; + + rc =bnxt_qplib_alloc_sgid_tbl (res, &res->sgid_tbl, dev_attr->max_sgid); +if (rc) + goto fail; + + rc =bnxt_qplib_alloc_pkey_tbl (res, &res->pkey_tbl, dev_attr->max_pkey); +if (rc) + goto fail; + + rc =bnxt_qplib_alloc_pd_tbl (res, &res->pd_tbl, dev_attr->max_pd); +if (rc) + goto fail; + + rc =bnxt_qplib_alloc_dpi_tbl (res, &res->dpi_tbl, dev_attr->l2_db_size); +if (rc) + goto fail; + +return 0 ; +fail: +bnxt_qplib_free_res (res); +return rc; +}drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h +164
-0@@ -13,5 +13,169 @@#ifndef __BNXT_QPLIB_RES_H__#define __BNXT_QPLIB_RES_H_ +extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero; +#define PTR_CNT_PER_PG (PAGE_SIZE / sizeof(void *)) +#define PTR_MAX_IDX_PER_PG (PTR_CNT_PER_PG - 1) +#define PTR_PG (x) (((x) & ~PTR_MAX_IDX_PER_PG) / PTR_CNT_PER_PG) +#define PTR_IDX (x) ((x) & PTR_MAX_IDX_PER_PG) + +#define HWQ_CMP (idx, hwq) ((idx) & ((hwq)->max_elements - 1)) + +enum bnxt_qplib_hwq_type { +HWQ_TYPE_CTX , +HWQ_TYPE_QUEUE , +HWQ_TYPE_L2_CMPL +}; + +#define MAX_PBL_LVL_0_PGS 1 +#define MAX_PBL_LVL_1_PGS 512 +#define MAX_PBL_LVL_1_PGS_SHIFT 9 +#define MAX_PBL_LVL_1_PGS_FOR_LVL_2 256 +#define MAX_PBL_LVL_2_PGS (256 * 512) + +enum bnxt_qplib_pbl_lvl { +PBL_LVL_0 , +PBL_LVL_1 , +PBL_LVL_2 , +PBL_LVL_MAX +}; + +#define ROCE_PG_SIZE_4K (4 * 1024) +#define ROCE_PG_SIZE_8K (8 * 1024) +#define ROCE_PG_SIZE_64K (64 * 1024) +#define ROCE_PG_SIZE_2M (2 * 1024 * 1024) +#define ROCE_PG_SIZE_8M (8 * 1024 * 1024) +#define ROCE_PG_SIZE_1G (1024 * 1024 * 1024) + +struct bnxt_qplib_pbl { +u32 pg_count; +u32 pg_size; +void **pg_arr; +dma_addr_t *pg_map_arr; +}; + +struct bnxt_qplib_hwq { +struct pci_dev *pdev; +/* lock to protect qplib_hwq */ +spinlock_t lock; +struct bnxt_qplib_pbl pbl[PBL_LVL_MAX ]; +enum bnxt_qplib_pbl_lvl level;/* 0, 1, or 2 */ +/* ptr for easy access to the PBL entries */ +void **pbl_ptr; +/* ptr for easy access to the dma_addr */ +dma_addr_t *pbl_dma_ptr; +u32 max_elements; +u16 element_size;/* Size of each entry */ + +u32 prod;/* raw */ +u32 cons;/* raw */ +u8 cp_bit; +u8 is_user; +}; + +/* Tables */ +struct bnxt_qplib_pd_tbl { +unsigned long *tbl; +u32 max; +}; + +struct bnxt_qplib_sgid_tbl { +struct bnxt_qplib_gid *tbl; +u16 *hw_id; +u16 max; +u16 active; +void *ctx; +}; + +struct bnxt_qplib_pkey_tbl { +u16 *tbl; +u16 max; +u16 active; +}; + +struct bnxt_qplib_dpi { +u32 dpi; +void __iomem *dbr; +u64 umdbr; +}; + +struct bnxt_qplib_dpi_tbl { +void **app_tbl; +unsigned long *tbl; +u16 max; +void __iomem *dbr_bar_reg_iomem; +u64 unmapped_dbr; +}; + +struct bnxt_qplib_stats { +dma_addr_t dma_map; +void *dma; +u32 size; +u32 fw_id; +}; + +struct bnxt_qplib_vf_res { +u32 max_qp_per_vf; +u32 max_mrw_per_vf; +u32 max_srq_per_vf; +u32 max_cq_per_vf; +u32 max_gid_per_vf; +}; + +#define BNXT_QPLIB_MAX_QP_CTX_ENTRY_SIZE 448 +#define BNXT_QPLIB_MAX_SRQ_CTX_ENTRY_SIZE 64 +#define BNXT_QPLIB_MAX_CQ_CTX_ENTRY_SIZE 64 +#define BNXT_QPLIB_MAX_MRW_CTX_ENTRY_SIZE 128 + +struct bnxt_qplib_ctx { +u32 qpc_count; +struct bnxt_qplib_hwq qpc_tbl; +u32 mrw_count; +struct bnxt_qplib_hwq mrw_tbl; +u32 srqc_count; +struct bnxt_qplib_hwq srqc_tbl; +u32 cq_count; +struct bnxt_qplib_hwq cq_tbl; +struct bnxt_qplib_hwq tim_tbl; +#define MAX_TQM_ALLOC_REQ 32 +#define MAX_TQM_ALLOC_BLK_SIZE 8 +u8 tqm_count[MAX_TQM_ALLOC_REQ ]; +struct bnxt_qplib_hwq tqm_pde; +u32 tqm_pde_level; +struct bnxt_qplib_hwq tqm_tbl[MAX_TQM_ALLOC_REQ ]; +struct bnxt_qplib_stats stats; +struct bnxt_qplib_vf_res vf_res; +}; + +struct bnxt_qplib_res { +struct pci_dev *pdev; +struct net_device *netdev; + +struct bnxt_qplib_rcfw *rcfw; + +struct bnxt_qplib_pd_tbl pd_tbl; +struct bnxt_qplib_sgid_tbl sgid_tbl; +struct bnxt_qplib_pkey_tbl pkey_tbl; +struct bnxt_qplib_dpi_tbl dpi_tbl; +}; + +struct bnxt_qplib_dev_attr ; + +void bnxt_qplib_free_hwq (struct pci_dev *pdev,struct bnxt_qplib_hwq *hwq); +int bnxt_qplib_alloc_init_hwq (struct pci_dev *pdev,struct bnxt_qplib_hwq *hwq, +struct scatterlist *sl,int nmap,u32 *elements, +u32 elements_per_page,u32 aux,u32 pg_size, +enum bnxt_qplib_hwq_type hwq_type); +void bnxt_qplib_cleanup_res (struct bnxt_qplib_res *res); +int bnxt_qplib_init_res (struct bnxt_qplib_res *res); +void bnxt_qplib_free_res (struct bnxt_qplib_res *res); +int bnxt_qplib_alloc_res (struct bnxt_qplib_res *res,struct pci_dev *pdev, +struct net_device *netdev, +struct bnxt_qplib_dev_attr *dev_attr); +void bnxt_qplib_free_ctx (struct pci_dev *pdev, +struct bnxt_qplib_ctx *ctx); +int bnxt_qplib_alloc_ctx (struct pci_dev *pdev, +struct bnxt_qplib_ctx *ctx, +bool virt_fn);#endif /* __BNXT_QPLIB_RES_H__ */ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c +163
-0@@ -10,3 +10,166 @@/* * Description: Slow Path Operators */ + +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/sched.h> +#include <linux/pci.h> + +#include "bnxt_re_hsi.h" + +#include "bnxt_qplib_res.h" +#include "bnxt_qplib_rcfw.h" +#include "bnxt_qplib_sp.h" +/* Device */ +int bnxt_qplib_get_dev_attr (struct bnxt_qplib_rcfw *rcfw, +struct bnxt_qplib_dev_attr *attr) +{ +struct cmdq_query_func req; +struct creq_query_func_resp *resp; +struct creq_query_func_resp_sb *sb; +u16 cmd_flags =0 ; +u32 temp; +u8 *tqm_alloc; +int i; + +RCFW_CMD_PREP (req,QUERY_FUNC , cmd_flags); + + req.resp_size =sizeof (*sb) /BNXT_QPLIB_CMDQE_UNITS ; + resp = (struct creq_query_func_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, (void **)&sb, +0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: QUERY_FUNC send failed" ); +return -EINVAL ; + } +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: SP: QUERY_FUNC timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: QUERY_FUNC failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } +/* Extract the context from the side buffer */ + attr->max_qp =le32_to_cpu (sb->max_qp); + attr->max_qp_rd_atom = + sb->max_qp_rd_atom >BNXT_QPLIB_MAX_OUT_RD_ATOM ? +BNXT_QPLIB_MAX_OUT_RD_ATOM : sb->max_qp_rd_atom; + attr->max_qp_init_rd_atom = + sb->max_qp_init_rd_atom >BNXT_QPLIB_MAX_OUT_RD_ATOM ? +BNXT_QPLIB_MAX_OUT_RD_ATOM : sb->max_qp_init_rd_atom; + attr->max_qp_wqes =le16_to_cpu (sb->max_qp_wr); + attr->max_qp_sges = sb->max_sge; + attr->max_cq =le32_to_cpu (sb->max_cq); + attr->max_cq_wqes =le32_to_cpu (sb->max_cqe); + attr->max_cq_sges = attr->max_qp_sges; + attr->max_mr =le32_to_cpu (sb->max_mr); + attr->max_mw =le32_to_cpu (sb->max_mw); + + attr->max_mr_size =le64_to_cpu (sb->max_mr_size); + attr->max_pd =64 *1024 ; + attr->max_raw_ethy_qp =le32_to_cpu (sb->max_raw_eth_qp); + attr->max_ah =le32_to_cpu (sb->max_ah); + + attr->max_fmr =le32_to_cpu (sb->max_fmr); + attr->max_map_per_fmr =le32_to_cpu (sb->max_map_per_fmr); + + attr->max_srq =le16_to_cpu (sb->max_srq); + attr->max_srq_wqes =le32_to_cpu (sb->max_srq_wr -1 ); + attr->max_srq_sges = sb->max_srq_sge; +/* Bono only reports 1 PKEY for now, but it can support > 1 */ + attr->max_pkey =le32_to_cpu (sb->max_pkeys); + + attr->max_inline_data =le32_to_cpu (sb->max_inline_data); + attr->l2_db_size = (sb->l2_db_space_size +1 ) *PAGE_SIZE ; + attr->max_sgid =le32_to_cpu (sb->max_gid); + +strlcpy (attr->fw_ver,"20.6.28.0" ,sizeof (attr->fw_ver)); + +for (i =0 ; i <MAX_TQM_ALLOC_REQ /4 ; i++) { + temp =le32_to_cpu (sb->tqm_alloc_reqs[i]); + tqm_alloc = (u8 *)&temp; + attr->tqm_alloc_reqs[i *4 ] = *tqm_alloc; + attr->tqm_alloc_reqs[i *4 +1 ] = *(++tqm_alloc); + attr->tqm_alloc_reqs[i *4 +2 ] = *(++tqm_alloc); + attr->tqm_alloc_reqs[i *4 +3 ] = *(++tqm_alloc); + } +return 0 ; +} + +int bnxt_qplib_del_pkey (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, +bool update) +{ +int i, rc =0 ; + +if (!pkey_tbl) { +dev_err (&res->pdev->dev,"QPLIB: PKEY table not allocated" ); +return -EINVAL ; + } + +/* Do we need a pkey_lock here? */ +if (!pkey_tbl->active) { +dev_err (&res->pdev->dev, +"QPLIB: PKEY table has no active entries" ); +return -ENOMEM ; + } +for (i =0 ; i < pkey_tbl->max; i++) { +if (!memcmp (&pkey_tbl->tbl[i], pkey,sizeof (*pkey))) +break ; + } +if (i == pkey_tbl->max) { +dev_err (&res->pdev->dev, +"QPLIB: PKEY 0x%04x not found in the pkey table" , + *pkey); +return -ENOMEM ; + } +memset (&pkey_tbl->tbl[i],0 ,sizeof (*pkey)); + pkey_tbl->active--; + +/* unlock */ +return rc; +} + +int bnxt_qplib_add_pkey (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, +bool update) +{ +int i, free_idx, rc =0 ; + +if (!pkey_tbl) { +dev_err (&res->pdev->dev,"QPLIB: PKEY table not allocated" ); +return -EINVAL ; + } + +/* Do we need a pkey_lock here? */ +if (pkey_tbl->active == pkey_tbl->max) { +dev_err (&res->pdev->dev,"QPLIB: PKEY table is full" ); +return -ENOMEM ; + } + free_idx = pkey_tbl->max; +for (i =0 ; i < pkey_tbl->max; i++) { +if (!memcmp (&pkey_tbl->tbl[i], pkey,sizeof (*pkey))) +return -EALREADY ; +else if (!pkey_tbl->tbl[i] && free_idx == pkey_tbl->max) + free_idx = i; + } +if (free_idx == pkey_tbl->max) { +dev_err (&res->pdev->dev, +"QPLIB: PKEY table is FULL but count is not MAX??" ); +return -ENOMEM ; + } +/* Add PKEY to the pkey_tbl */ +memcpy (&pkey_tbl->tbl[free_idx], pkey,sizeof (*pkey)); + pkey_tbl->active++; + +/* unlock */ +return rc; +}drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h +42
-0@@ -14,4 +14,46 @@#ifndef __BNXT_QPLIB_SP_H__#define __BNXT_QPLIB_SP_H__ +struct bnxt_qplib_dev_attr { +char fw_ver[32 ]; +u16 max_sgid; +u16 max_mrw; +u32 max_qp; +#define BNXT_QPLIB_MAX_OUT_RD_ATOM 126 +u32 max_qp_rd_atom; +u32 max_qp_init_rd_atom; +u32 max_qp_wqes; +u32 max_qp_sges; +u32 max_cq; +u32 max_cq_wqes; +u32 max_cq_sges; +u32 max_mr; +u64 max_mr_size; +u32 max_pd; +u32 max_mw; +u32 max_raw_ethy_qp; +u32 max_ah; +u32 max_fmr; +u32 max_map_per_fmr; +u32 max_srq; +u32 max_srq_wqes; +u32 max_srq_sges; +u32 max_pkey; +u32 max_inline_data; +u32 l2_db_size; +u8 tqm_alloc_reqs[MAX_TQM_ALLOC_REQ ]; +}; + +struct bnxt_qplib_gid { +u8 data[16 ]; +}; + +int bnxt_qplib_del_pkey (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, +bool update); +int bnxt_qplib_add_pkey (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey, +bool update); +int bnxt_qplib_get_dev_attr (struct bnxt_qplib_rcfw *rcfw, +struct bnxt_qplib_dev_attr *attr);#endif /* __BNXT_QPLIB_SP_H__*/ drivers/infiniband/hw/bnxtre/bnxt_re.h +15
-0@@ -16,6 +16,11 @@#define BNXT_RE_REF_WAIT_COUNT 10#define BNXT_RE_DESC "Broadcom NetXtreme-C/E RoCE Driver" +#define BNXT_RE_MAX_QPC_COUNT (64 * 1024) +#define BNXT_RE_MAX_MRW_COUNT (64 * 1024) +#define BNXT_RE_MAX_SRQC_COUNT (64 * 1024) +#define BNXT_RE_MAX_CQ_COUNT (64 * 1024) +struct bnxt_re_work {struct work_struct work;unsigned long event;@@ -25,6 +30,7 @@ struct bnxt_re_work {#define BNXT_RE_MIN_MSIX 2#define BNXT_RE_MAX_MSIX 16 +#define BNXT_RE_AEQ_IDX 0struct bnxt_re_dev {struct ib_device ibdev;struct list_head list;@@ -43,6 +49,15 @@ struct bnxt_re_dev {int id; +/* RCFW Channel */ +struct bnxt_qplib_rcfw rcfw; + +/* Device Resources */ +struct bnxt_qplib_dev_attr dev_attr; +struct bnxt_qplib_ctx qplib_ctx; +struct bnxt_qplib_res qplib_res; +struct bnxt_qplib_dpi dpi_privileged; +atomic_t qp_count;struct mutex qp_lock;/* protect qp list */ struct list_head qp_list;drivers/infiniband/hw/bnxtre/bnxt_re_main.c +422
-5@@ -29,6 +29,10 @@#include "bnxt_ulp.h" #include "bnxt_re_hsi.h" +#include "bnxt_qplib_res.h" +#include "bnxt_qplib_sp.h" +#include "bnxt_qplib_fp.h" +#include "bnxt_qplib_rcfw.h" #include "bnxt_re.h" #include "bnxt.h" static char version[] =@@ -84,7 +88,6 @@ static inline const char *bnxt_re_netevent(unsigned long event) event =NETDEV_UNKNOWN ;return bnxt_re_event2str[(event)]; } -/* The rdev ref_count is to protect immature removal of the device */ static inline void bnxt_re_hold (struct bnxt_re_dev *rdev) {@@ -95,7 +98,6 @@ static inline void bnxt_re_put(struct bnxt_re_dev *rdev) {atomic_dec (&rdev->ref_count); } -/* RoCE -> Net driver */ /* Driver registration routines used to let the networking driver (bnxt_en) @@ -184,6 +186,156 @@ static int bnxt_re_request_msix(struct bnxt_re_dev *rdev)return rc; } +static void bnxt_re_init_hwrm_hdr (struct bnxt_re_dev *rdev,struct input *hdr, +u16 opcd,u16 crid,u16 trid) +{ + hdr->req_type =cpu_to_le16 (opcd); + hdr->cmpl_ring =cpu_to_le16 (crid); + hdr->target_id =cpu_to_le16 (trid); +} + +static void bnxt_re_fill_fw_msg (struct bnxt_fw_msg *fw_msg,void *msg, +int msg_len,void *resp,int resp_max_len, +int timeout) +{ + fw_msg->msg = msg; + fw_msg->msg_len = msg_len; + fw_msg->resp = resp; + fw_msg->resp_max_len = resp_max_len; + fw_msg->timeout = timeout; +} + +static int bnxt_re_net_ring_free (struct bnxt_re_dev *rdev,u16 fw_ring_id, +bool lock_wait) +{ +struct bnxt_en_dev *en_dev = rdev->en_dev; +struct hwrm_ring_free_input req = {0 }; +struct hwrm_ring_free_output resp; +struct bnxt_fw_msg fw_msg = {0 }; +bool do_unlock = false; +int rc = -EINVAL ; + +if (!en_dev) +return rc; + +if (!rtnl_is_locked () || lock_wait) { +rtnl_lock (); + do_unlock = true; + } + +bnxt_re_init_hwrm_hdr (rdev, (void *)&req,HWRM_RING_FREE ,-1 ,-1 ); + req.ring_type =RING_ALLOC_REQ_RING_TYPE_CMPL ; + req.ring_id =cpu_to_le16 (fw_ring_id); +bnxt_re_fill_fw_msg (&fw_msg, (void *)&req,sizeof (req), (void *)&resp, +sizeof (resp),DFLT_HWRM_CMD_TIMEOUT ); + rc = en_dev->en_ops->bnxt_send_fw_msg (en_dev,BNXT_ROCE_ULP , &fw_msg); +if (rc) +dev_err (rdev_to_dev (rdev), +"Failed to free HW ring:%d :%#x" , req.ring_id, rc); +if (do_unlock) +rtnl_unlock (); +return rc; +} + +static int bnxt_re_net_ring_alloc (struct bnxt_re_dev *rdev,dma_addr_t *dma_arr, +int pages,int type,u32 ring_mask, +u32 map_index,u16 *fw_ring_id) +{ +struct bnxt_en_dev *en_dev = rdev->en_dev; +struct hwrm_ring_alloc_input req = {0 }; +struct hwrm_ring_alloc_output resp; +struct bnxt_fw_msg fw_msg = {0 }; +int rc = -EINVAL ; + +if (!en_dev) +return rc; + +rtnl_lock (); +bnxt_re_init_hwrm_hdr (rdev, (void *)&req,HWRM_RING_ALLOC ,-1 ,-1 ); + req.enables =0 ; + req.page_tbl_addr =cpu_to_le64 (dma_arr[0 ]); +if (pages >1 ) { +/* Page size is in log2 units */ + req.page_size =BNXT_PAGE_SHIFT ; + req.page_tbl_depth =1 ; + } + req.fbo =0 ; +/* Association of ring index with doorbell index and MSIX number */ + req.logical_id =cpu_to_le16 (map_index); + req.length =cpu_to_le32 (ring_mask +1 ); + req.ring_type =RING_ALLOC_REQ_RING_TYPE_CMPL ; + req.int_mode =RING_ALLOC_REQ_INT_MODE_MSIX ; +bnxt_re_fill_fw_msg (&fw_msg, (void *)&req,sizeof (req), (void *)&resp, +sizeof (resp),DFLT_HWRM_CMD_TIMEOUT ); + rc = en_dev->en_ops->bnxt_send_fw_msg (en_dev,BNXT_ROCE_ULP , &fw_msg); +if (!rc) + *fw_ring_id =le16_to_cpu (resp.ring_id); + +rtnl_unlock (); +return rc; +} + +static int bnxt_re_net_stats_ctx_free (struct bnxt_re_dev *rdev, +u32 fw_stats_ctx_id,bool lock_wait) +{ +struct bnxt_en_dev *en_dev = rdev->en_dev; +struct hwrm_stat_ctx_free_input req = {0 }; +struct bnxt_fw_msg fw_msg = {0 }; +bool do_unlock = false; +int rc = -EINVAL ; + +if (!en_dev) +return rc; + +if (!rtnl_is_locked () || lock_wait) { +rtnl_lock (); + do_unlock = true; + } + +bnxt_re_init_hwrm_hdr (rdev, (void *)&req,HWRM_STAT_CTX_FREE ,-1 ,-1 ); + req.stat_ctx_id =cpu_to_le32 (fw_stats_ctx_id); +bnxt_re_fill_fw_msg (&fw_msg, (void *)&req,sizeof (req), (void *)&req, +sizeof (req),DFLT_HWRM_CMD_TIMEOUT ); + rc = en_dev->en_ops->bnxt_send_fw_msg (en_dev,BNXT_ROCE_ULP , &fw_msg); +if (rc) +dev_err (rdev_to_dev (rdev), +"Failed to free HW stats context %#x" , rc); + +if (do_unlock) +rtnl_unlock (); +return rc; +} + +static int bnxt_re_net_stats_ctx_alloc (struct bnxt_re_dev *rdev, +dma_addr_t dma_map, +u32 *fw_stats_ctx_id) +{ +struct hwrm_stat_ctx_alloc_output resp = {0 }; +struct hwrm_stat_ctx_alloc_input req = {0 }; +struct bnxt_en_dev *en_dev = rdev->en_dev; +struct bnxt_fw_msg fw_msg = {0 }; +int rc = -EINVAL ; + + *fw_stats_ctx_id =INVALID_STATS_CTX_ID ; + +if (!en_dev) +return rc; + +rtnl_lock (); + +bnxt_re_init_hwrm_hdr (rdev, (void *)&req,HWRM_STAT_CTX_ALLOC ,-1 ,-1 ); + req.update_period_ms =cpu_to_le32 (1000 ); + req.stats_dma_addr =cpu_to_le64 (dma_map); +bnxt_re_fill_fw_msg (&fw_msg, (void *)&req,sizeof (req), (void *)&resp, +sizeof (resp),DFLT_HWRM_CMD_TIMEOUT ); + rc = en_dev->en_ops->bnxt_send_fw_msg (en_dev,BNXT_ROCE_ULP , &fw_msg); +if (!rc) + *fw_stats_ctx_id =le32_to_cpu (resp.stat_ctx_id); + +rtnl_unlock (); +return rc; +} +/* Device */ static bool is_bnxt_re_dev (struct net_device *netdev)@@ -247,6 +399,64 @@ struct bnxt_en_dev *bnxt_re_dev_probe(struct net_device *netdev)return en_dev; } +static void bnxt_re_unregister_ib (struct bnxt_re_dev *rdev) +{ +ib_unregister_device (&rdev->ibdev); +} + +static int bnxt_re_register_ib (struct bnxt_re_dev *rdev) +{ +struct ib_device *ibdev = &rdev->ibdev; + +/* ib device init */ + ibdev->owner =THIS_MODULE ; + ibdev->node_type =RDMA_NODE_IB_CA ; +strlcpy (ibdev->name,"bnxt_re%d" ,IB_DEVICE_NAME_MAX ); +strlcpy (ibdev->node_desc,BNXT_RE_DESC " HCA" , +strlen (BNXT_RE_DESC ) +5 ); + ibdev->phys_port_cnt =1 ; + + ibdev->num_comp_vectors =1 ; + ibdev->dma_device = &rdev->en_dev->pdev->dev; +return ib_register_device (ibdev,NULL ); +} + +static ssize_t show_rev (struct device *device,struct device_attribute *attr, +char *buf) +{ +struct bnxt_re_dev *rdev =to_bnxt_re_dev (device, ibdev.dev); + +return scnprintf (buf,PAGE_SIZE ,"0x%x\n" , rdev->en_dev->pdev->vendor); +strcpy (buf,"bnxt_re" ); +return 0 ; +} + +static ssize_t show_fw_ver (struct device *device,struct device_attribute *attr, +char *buf) +{ +struct bnxt_re_dev *rdev =to_bnxt_re_dev (device, ibdev.dev); + +return scnprintf (buf,PAGE_SIZE ,"%s\n" , rdev->dev_attr.fw_ver); +} + +static ssize_t show_hca (struct device *device,struct device_attribute *attr, +char *buf) +{ +struct bnxt_re_dev *rdev =to_bnxt_re_dev (device, ibdev.dev); + +return scnprintf (buf,PAGE_SIZE ,"%s\n" , rdev->ibdev.node_desc); +} + +static DEVICE_ATTR(hw_rev, 0444, show_rev, NULL); +static DEVICE_ATTR(fw_rev, 0444, show_fw_ver, NULL); +static DEVICE_ATTR(hca_type, 0444, show_hca, NULL); + +static struct device_attribute *bnxt_re_attributes[] = { + &dev_attr_hw_rev, + &dev_attr_fw_rev, + &dev_attr_hca_type +}; +static void bnxt_re_dev_remove (struct bnxt_re_dev *rdev) {int i =BNXT_RE_REF_WAIT_COUNT ;@@ -309,10 +519,109 @@ static struct bnxt_re_dev *bnxt_re_dev_add(struct net_device *netdev,return rdev; } +static int bnxt_re_aeq_handler (struct bnxt_qplib_rcfw *rcfw, +struct creq_func_event *aeqe) +{ +switch (aeqe->event) { +case CREQ_FUNC_EVENT_EVENT_TX_WQE_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TX_DATA_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_RX_WQE_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_RX_DATA_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CQ_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TQM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCQ_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCS_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCC_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_CFCM_ERROR : +break ; +case CREQ_FUNC_EVENT_EVENT_TIM_ERROR : +break ; +default : +return -EINVAL ; + } +return 0 ; +} + +static void bnxt_re_cleanup_res (struct bnxt_re_dev *rdev) +{ +if (rdev->qplib_res.rcfw) +bnxt_qplib_cleanup_res (&rdev->qplib_res); +} + +static int bnxt_re_init_res (struct bnxt_re_dev *rdev) +{ +int rc =0 ; + +bnxt_qplib_init_res (&rdev->qplib_res); + +return rc; +} + +static void bnxt_re_free_res (struct bnxt_re_dev *rdev,bool lock_wait) +{ +if (rdev->qplib_res.rcfw) { +bnxt_qplib_free_res (&rdev->qplib_res); + rdev->qplib_res.rcfw =NULL ; + } +} + +static int bnxt_re_alloc_res (struct bnxt_re_dev *rdev) +{ +int rc =0 ; + +/* Configure and allocate resources for qplib */ + rdev->qplib_res.rcfw = &rdev->rcfw; + rc =bnxt_qplib_get_dev_attr (&rdev->rcfw, &rdev->dev_attr); +if (rc) + goto fail; + + rc =bnxt_qplib_alloc_res (&rdev->qplib_res, rdev->en_dev->pdev, + rdev->netdev, &rdev->dev_attr); +if (rc) + goto fail; + +return 0 ; + +fail: + rdev->qplib_res.rcfw =NULL ; +return rc; +} +static void bnxt_re_ib_unreg (struct bnxt_re_dev *rdev,bool lock_wait) { -int rc; +int i, rc; + +if (test_and_clear_bit (BNXT_RE_FLAG_IBDEV_REGISTERED , &rdev->flags)) { +for (i =0 ; i <ARRAY_SIZE (bnxt_re_attributes); i++) +device_remove_file (&rdev->ibdev.dev, + bnxt_re_attributes[i]); +/* Cleanup ib dev */ +bnxt_re_unregister_ib (rdev); + } +bnxt_re_cleanup_res (rdev); +bnxt_re_free_res (rdev, lock_wait); +if (test_and_clear_bit (BNXT_RE_FLAG_RCFW_CHANNEL_EN , &rdev->flags)) { + rc =bnxt_qplib_deinit_rcfw (&rdev->rcfw); +if (rc) +dev_warn (rdev_to_dev (rdev), +"Failed to deinitialize RCFW: %#x" , rc); +bnxt_re_net_stats_ctx_free (rdev, rdev->qplib_ctx.stats.fw_id, + lock_wait); +bnxt_qplib_free_ctx (rdev->en_dev->pdev, &rdev->qplib_ctx); +bnxt_qplib_disable_rcfw_channel (&rdev->rcfw); +bnxt_re_net_ring_free (rdev, rdev->rcfw.creq_ring_id, lock_wait); +bnxt_qplib_free_rcfw_channel (&rdev->rcfw); + }if (test_and_clear_bit (BNXT_RE_FLAG_GOT_MSIX , &rdev->flags)) { rc =bnxt_re_free_msix (rdev, lock_wait);if (rc)@@ -327,6 +636,19 @@ static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev, bool lock_wait) } } +static void bnxt_re_set_resource_limits (struct bnxt_re_dev *rdev) +{ +u32 i; + + rdev->qplib_ctx.qpc_count =BNXT_RE_MAX_QPC_COUNT ; + rdev->qplib_ctx.mrw_count =BNXT_RE_MAX_MRW_COUNT ; + rdev->qplib_ctx.srqc_count =BNXT_RE_MAX_SRQC_COUNT ; + rdev->qplib_ctx.cq_count =BNXT_RE_MAX_CQ_COUNT ; +for (i =0 ; i <MAX_TQM_ALLOC_REQ ; i++) + rdev->qplib_ctx.tqm_count[i] = + rdev->dev_attr.tqm_alloc_reqs[i]; +} +static int bnxt_re_ib_reg (struct bnxt_re_dev *rdev) {int i, j, rc;@@ -347,6 +669,103 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev) }set_bit (BNXT_RE_FLAG_GOT_MSIX , &rdev->flags); +/* Establish RCFW Communication Channel to initialize the context +* memory for the function and all child VFs +*/ + rc =bnxt_qplib_alloc_rcfw_channel (rdev->en_dev->pdev, &rdev->rcfw); +if (rc) + goto fail; + + rc =bnxt_re_net_ring_alloc + (rdev, rdev->rcfw.creq.pbl[PBL_LVL_0 ].pg_map_arr, + rdev->rcfw.creq.pbl[rdev->rcfw.creq.level].pg_count, +HWRM_RING_ALLOC_CMPL ,BNXT_QPLIB_CREQE_MAX_CNT -1 , + rdev->msix_entries[BNXT_RE_AEQ_IDX ].ring_idx, + &rdev->rcfw.creq_ring_id); +if (rc) { +pr_err ("Failed to allocate CREQ: %#x\n" , rc); + goto free_rcfw; + } + rc =bnxt_qplib_enable_rcfw_channel + (rdev->en_dev->pdev, &rdev->rcfw, + rdev->msix_entries[BNXT_RE_AEQ_IDX ].vector, + rdev->msix_entries[BNXT_RE_AEQ_IDX ].db_offset, +0 , &bnxt_re_aeq_handler); +if (rc) { +pr_err ("Failed to enable RCFW channel: %#x\n" , rc); + goto free_ring; + } + + rc =bnxt_qplib_get_dev_attr (&rdev->rcfw, &rdev->dev_attr); +if (rc) + goto disable_rcfw; +bnxt_re_set_resource_limits (rdev); + + rc =bnxt_qplib_alloc_ctx (rdev->en_dev->pdev, &rdev->qplib_ctx,0 ); +if (rc) { +pr_err ("Failed to allocate QPLIB context: %#x\n" , rc); + goto disable_rcfw; + } + rc =bnxt_re_net_stats_ctx_alloc (rdev, + rdev->qplib_ctx.stats.dma_map, + &rdev->qplib_ctx.stats.fw_id); +if (rc) { +pr_err ("Failed to allocate stats context: %#x\n" , rc); + goto free_ctx; + } + + rc =bnxt_qplib_init_rcfw (&rdev->rcfw, &rdev->qplib_ctx,0 ); +if (rc) { +pr_err ("Failed to initialize RCFW: %#x\n" , rc); + goto free_sctx; + } +set_bit (BNXT_RE_FLAG_RCFW_CHANNEL_EN , &rdev->flags); + +/* Resources based on the 'new' device caps */ + rc =bnxt_re_alloc_res (rdev); +if (rc) { +pr_err ("Failed to allocate resources: %#x\n" , rc); + goto fail; + } + rc =bnxt_re_init_res (rdev); +if (rc) { +pr_err ("Failed to initialize resources: %#x\n" , rc); + goto fail; + } + +/* Register ib dev */ + rc =bnxt_re_register_ib (rdev); +if (rc) { +pr_err ("Failed to register with IB: %#x\n" , rc); + goto fail; + } +for (i =0 ; i <ARRAY_SIZE (bnxt_re_attributes); i++) { + rc =device_create_file (&rdev->ibdev.dev, + bnxt_re_attributes[i]); +if (rc) { +dev_err (rdev_to_dev (rdev), +"Failed to create IB sysfs: %#x" , rc); +/* Must clean up all created device files */ +for (j =0 ; j < i; j++) +device_remove_file (&rdev->ibdev.dev, + bnxt_re_attributes[j]); +bnxt_re_unregister_ib (rdev); + goto fail; + } + } +set_bit (BNXT_RE_FLAG_IBDEV_REGISTERED , &rdev->flags); + +return 0 ; +free_sctx: +bnxt_re_net_stats_ctx_free (rdev, rdev->qplib_ctx.stats.fw_id, true); +free_ctx: +bnxt_qplib_free_ctx (rdev->en_dev->pdev, &rdev->qplib_ctx); +disable_rcfw: +bnxt_qplib_disable_rcfw_channel (&rdev->rcfw); +free_ring: +bnxt_re_net_ring_free (rdev, rdev->rcfw.creq_ring_id, true); +free_rcfw: +bnxt_qplib_free_rcfw_channel (&rdev->rcfw); fail:bnxt_re_ib_unreg (rdev, true);return rc;@@ -391,7 +810,6 @@ static void bnxt_re_remove_one(struct bnxt_re_dev *rdev) {pci_dev_put (rdev->en_dev->pdev); } -/* Handle all deferred netevents tasks */ static void bnxt_re_task (struct work_struct *work) {@@ -414,14 +832,10 @@ static void bnxt_re_task(struct work_struct *work) "Failed to register with IB: %#x", rc);break ;case NETDEV_UP : -
drivers/infiniband/hw/bnxtre/bnxt_re_main.c static void bnxt_re_task(struct work_struct *work) · line 841
Quoted 10 lines
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +0
-3break ;case NETDEV_DOWN : -break ; -case NETDEV_CHANGE : -break ;default :break ;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 973d0642-1d06-72d4-bbbd-d360663d287b-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 11/28] bnxt_re: Enabling RoCE control path
Hi Jonathan,
Thanks for your review.
Quoted 5 lines · Jonathan Toppins
This retry logic looks like a complicated infinite loop, I am not seeing where there is a counter or some other mechanism to break out of this retry cycle if for some reason the HW stops or some other issue occurs. Can you help me understand this section?
You are right. This is a bug which could cause a system hang. cmdq_bitmap is set while sending the commands to FW and this will be cleared when completion interrupts are received (handled by function bnxt_qplib_process_qp_event which is a part
"bnxt_re: Add QP event handling" patch in this series).
I missed your mail before sending out v2 patch set. I will include this change as a bug fix patch
or will fix it while incorporating other review comments in v3 patch set.
Thanks
Quoted 17 lines
Quoted 17 lines
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c +17
-0+ +/* Cmdq are in 16-byte units, each request can consume 1 or more +* cmdqe +*/ +spin_lock_irqsave (&cmdq->lock, flags); +if (req->cmd_size > cmdq->max_elements - + ((HWQ_CMP (cmdq->prod, cmdq) -HWQ_CMP (cmdq->cons, cmdq)) & + (cmdq->max_elements -1 ))) { +dev_err (&rcfw->pdev->dev,"QPLIB: RCFW: CMDQ is full!" ); +spin_unlock_irqrestore (&cmdq->lock, flags); + goto retry; + } + + cookie =atomic_inc_return (&rcfw->seq_num) &RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (is_block) + cookie |=RCFW_CMD_IS_BLOCKING ;
Quoted 8 lines
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c line 120
Quoted 8 lines
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c +8
-0+ req->cookie =cpu_to_le16 (cookie); +if (test_and_set_bit (cbit, rcfw->cmdq_bitmap)) { +dev_err (&rcfw->pdev->dev, +"QPLIB: RCFW MAX outstanding cmd reached!" ); +atomic_dec (&rcfw->seq_num); +spin_unlock_irqrestore (&cmdq->lock, flags); + goto retry; + }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 12/28 bnxt_re: Adding Notification Queue support
In reply to a message not in the archiveCompletion Notifcations are handled by Notification Queue (NQ). This patch configures the NQs. Also, configures the Door bell page mapping
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 160 ++++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 60 ++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 6 + drivers/infiniband/hw/bnxtre/bnxt_re.h | 8 ++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 52 ++++++++- 5 files changed, 285 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c +160 -0
@@ -10,3 +10,163 @@/* * Description: Fast Path Operators */ + +#include <linux/interrupt.h> +#include <linux/spinlock.h> +#include <linux/sched.h> +#include <linux/slab.h> +#include <linux/pci.h> + +#include "bnxt_re_hsi.h" + +#include "bnxt_qplib_res.h" +#include "bnxt_qplib_rcfw.h" +#include "bnxt_qplib_sp.h" +#include "bnxt_qplib_fp.h" + +static void bnxt_qplib_service_nq (unsigned long data) +{ +struct bnxt_qplib_nq *nq = (struct bnxt_qplib_nq *)data; +struct bnxt_qplib_hwq *hwq = &nq->hwq; +struct nq_base *nqe, **nq_ptr; +u32 sw_cons, raw_cons; +u32 type; +int budget = nq->budget; + +/* Service the NQ until empty */ + raw_cons = hwq->cons; +while (budget--) { + sw_cons =HWQ_CMP (raw_cons, hwq); + nq_ptr = (struct nq_base **)hwq->pbl_ptr; + nqe = &nq_ptr[NQE_PG (sw_cons)][NQE_IDX (sw_cons)]; +if (!NQE_CMP_VALID (nqe, raw_cons, hwq->max_elements)) +break ; + + type =le16_to_cpu (nqe->info10_type &NQ_BASE_TYPE_MASK ); +switch (type) { +case NQ_BASE_TYPE_CQ_NOTIFICATION : +break ; +case NQ_BASE_TYPE_DBQ_EVENT : +break ; +default : +dev_warn (&nq->pdev->dev, +"QPLIB: nqe with type = 0x%x not handled" , + type); +break ; + } + raw_cons++; + } +if (hwq->cons != raw_cons) { + hwq->cons = raw_cons; +NQ_DB_REARM (nq->bar_reg_iomem, hwq->cons, hwq->max_elements); + } +} + +static irqreturn_t bnxt_qplib_nq_irq (int irq,void *dev_instance) +{ +struct bnxt_qplib_nq *nq = dev_instance; +struct bnxt_qplib_hwq *hwq = &nq->hwq; +struct nq_base **nq_ptr; +u32 sw_cons; + +/* Prefetch the NQ element */ + sw_cons =HWQ_CMP (hwq->cons, hwq); + nq_ptr = (struct nq_base **)nq->hwq.pbl_ptr; +prefetch (&nq_ptr[NQE_PG (sw_cons)][NQE_IDX (sw_cons)]); + +/* Fan out to CPU affinitized kthreads? */ +tasklet_schedule (&nq->worker); + +return IRQ_HANDLED ; +} + +void bnxt_qplib_disable_nq (struct bnxt_qplib_nq *nq) +{ +/* Make sure the HW is stopped! */ +synchronize_irq (nq->vector); +tasklet_disable (&nq->worker); +tasklet_kill (&nq->worker); + +if (nq->requested) { +free_irq (nq->vector, nq); + nq->requested = false; + } +if (nq->bar_reg_iomem) +iounmap (nq->bar_reg_iomem); + nq->bar_reg_iomem =NULL ; + + nq->cqn_handler =NULL ; + nq->srqn_handler =NULL ; + nq->vector =0 ; +} + +int bnxt_qplib_enable_nq (struct pci_dev *pdev,struct bnxt_qplib_nq *nq, +int msix_vector,int bar_reg_offset, +int (*cqn_handler)(struct bnxt_qplib_nq *nq, +void *), +int (*srqn_handler)(struct bnxt_qplib_nq *nq, +void *,u8 event)) +{ +resource_size_t nq_base; +int rc; + + nq->pdev = pdev; + nq->vector = msix_vector; + + nq->cqn_handler = cqn_handler; + + nq->srqn_handler = srqn_handler; + +tasklet_init (&nq->worker, bnxt_qplib_service_nq, (unsigned long )nq); + + nq->requested = false; + rc =request_irq (nq->vector, bnxt_qplib_nq_irq,0 ,"bnxt_qplib_nq" , nq); +if (rc) { +dev_err (&nq->pdev->dev, +"Failed to request IRQ for NQ: %#x" , rc); +bnxt_qplib_disable_nq (nq); + goto fail; + } + nq->requested = true; + nq->bar_reg =NQ_CONS_PCI_BAR_REGION ; + nq->bar_reg_off = bar_reg_offset; + nq_base =pci_resource_start (pdev, nq->bar_reg); +if (!nq_base) { + rc = -ENOMEM ; + goto fail; + } + nq->bar_reg_iomem =ioremap_nocache (nq_base + nq->bar_reg_off,4 ); +if (!nq->bar_reg_iomem) { + rc = -ENOMEM ; + goto fail; + } +NQ_DB_REARM (nq->bar_reg_iomem, nq->hwq.cons, nq->hwq.max_elements); + +return 0 ; +fail: +bnxt_qplib_disable_nq (nq); +return rc; +} + +void bnxt_qplib_free_nq (struct bnxt_qplib_nq *nq) +{ +if (nq->hwq.max_elements) +bnxt_qplib_free_hwq (nq->pdev, &nq->hwq); +} + +int bnxt_qplib_alloc_nq (struct pci_dev *pdev,struct bnxt_qplib_nq *nq) +{ + nq->pdev = pdev; +if (!nq->hwq.max_elements || + nq->hwq.max_elements >BNXT_QPLIB_NQE_MAX_CNT ) + nq->hwq.max_elements =BNXT_QPLIB_NQE_MAX_CNT ; + +if (bnxt_qplib_alloc_init_hwq (nq->pdev, &nq->hwq,NULL ,0 , + &nq->hwq.max_elements, +BNXT_QPLIB_MAX_NQE_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_L2_CMPL )) +return -ENOMEM ; + + nq->budget =8 ; +return 0 ; +}
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h +60 -0
64 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h +6 -0
@@ -167,6 +167,12 @@ int bnxt_qplib_alloc_init_hwq(struct pci_dev *pdev, struct bnxt_qplib_hwq *hwq, struct scatterlist *sl, int nmap, u32 *elements, u32 elements_per_page, u32 aux, u32 pg_size, enum bnxt_qplib_hwq_type hwq_type); +int bnxt_qplib_alloc_dpi (struct bnxt_qplib_dpi_tbl *dpit, +struct bnxt_qplib_dpi *dpi, +void *app); +int bnxt_qplib_dealloc_dpi (struct bnxt_qplib_res *res, +struct bnxt_qplib_dpi_tbl *dpi_tbl, +struct bnxt_qplib_dpi *dpi);void bnxt_qplib_cleanup_res (struct bnxt_qplib_res *res);int bnxt_qplib_init_res (struct bnxt_qplib_res *res);void bnxt_qplib_free_res (struct bnxt_qplib_res *res);
drivers/infiniband/hw/bnxtre/bnxt_re.h +8 -0
@@ -31,6 +31,8 @@ struct bnxt_re_work {#define BNXT_RE_MIN_MSIX 2#define BNXT_RE_MAX_MSIX 16#define BNXT_RE_AEQ_IDX 0 +#define BNXT_RE_NQ_IDX 1 +struct bnxt_re_dev {struct ib_device ibdev;struct list_head list;
@@ -49,9 +51,15 @@ struct bnxt_re_dev {int id; +/* FP Notification Queue (CQ & SRQ) */ +struct tasklet_struct nq_task; +/* RCFW Channel */ struct bnxt_qplib_rcfw rcfw; +/* NQ */ +struct bnxt_qplib_nq nq; +/* Device Resources */ struct bnxt_qplib_dev_attr dev_attr;struct bnxt_qplib_ctx qplib_ctx;
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +51 -1
76 lines not on this page · raw message
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 13/28 bnxt_re: Support for PD, ucontext and mmap verbs
In reply to a message not in the archiveThis patch includes the uverbs_abi.h file to enable user verbs. Also adds support for the Protection Domain, User Context and mmap verbs.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 28 +++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 8 +- drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 4 + drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 219 +++++++++++++++++++++- drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 23 +++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 7 + drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 32 ++++ 7 files changed, 319 insertions(+), 2 deletions(-) create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c +28 -0
@@ -504,6 +504,34 @@ static int bnxt_qplib_alloc_pkey_tbl(struct bnxt_qplib_res *res,return 0 ; }; +/* PDs */ +int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pdt,struct bnxt_qplib_pd *pd) +{ +u32 bit_num; + + bit_num =find_first_bit (pdt->tbl, pdt->max); +if (bit_num == pdt->max) +return -ENOMEM ; + +/* Found unused PD */ +clear_bit (bit_num, pdt->tbl); + pd->id = bit_num; +return 0 ; +} + +int bnxt_qplib_dealloc_pd (struct bnxt_qplib_res *res, +struct bnxt_qplib_pd_tbl *pdt, +struct bnxt_qplib_pd *pd) +{ +if (test_and_set_bit (pd->id, pdt->tbl)) { +dev_warn (&res->pdev->dev,"Freeing an unused PD? pdn = %d" , + pd->id); +return -EINVAL ; + } + pd->id =0 ; +return 0 ; +} +static void bnxt_qplib_free_pd_tbl (struct bnxt_qplib_pd_tbl *pdt) {kfree (pdt->tbl);
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h +7 -1
@@ -12,7 +12,7 @@*/ #ifndef __BNXT_QPLIB_RES_H__ -#define __BNXT_QPLIB_RES_H_ +#define __BNXT_QPLIB_RES_H__extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero;#define PTR_CNT_PER_PG (PAGE_SIZE / sizeof(void *))
@@ -160,6 +160,7 @@ struct bnxt_qplib_res {struct bnxt_qplib_dpi_tbl dpi_tbl; }; +struct bnxt_qplib_pd ;struct bnxt_qplib_dev_attr ;void bnxt_qplib_free_hwq (struct pci_dev *pdev,struct bnxt_qplib_hwq *hwq);
@@ -167,6 +168,11 @@ int bnxt_qplib_alloc_init_hwq(struct pci_dev *pdev, struct bnxt_qplib_hwq *hwq, struct scatterlist *sl, int nmap, u32 *elements, u32 elements_per_page, u32 aux, u32 pg_size, enum bnxt_qplib_hwq_type hwq_type); +int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pd_tbl, +struct bnxt_qplib_pd *pd); +int bnxt_qplib_dealloc_pd (struct bnxt_qplib_res *res, +struct bnxt_qplib_pd_tbl *pd_tbl, +struct bnxt_qplib_pd *pd);int bnxt_qplib_alloc_dpi (struct bnxt_qplib_dpi_tbl *dpit,struct bnxt_qplib_dpi *dpi,void *app);
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h +4 -0
@@ -44,6 +44,10 @@ struct bnxt_qplib_dev_attr {u8 tqm_alloc_reqs[MAX_TQM_ALLOC_REQ ]; }; +struct bnxt_qplib_pd { +u32 id; +}; +struct bnxt_qplib_gid {u8 data[16 ]; };
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +218 -1
224 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +23 -0
@@ -14,4 +14,27 @@#ifndef __BNXT_RE_IB_VERBS_H__#define __BNXT_RE_IB_VERBS_H__ +struct bnxt_re_pd { +struct bnxt_re_dev *rdev; +struct ib_pd ib_pd; +struct bnxt_qplib_pd qplib_pd; +struct bnxt_qplib_dpi dpi; +}; + +struct bnxt_re_ucontext { +struct bnxt_re_dev *rdev; +struct ib_ucontext ib_uctx; +struct bnxt_qplib_dpi *dpi; +void *shpg; +spinlock_t sh_lock;/* protect shpg */ +}; + +struct ib_pd *bnxt_re_alloc_pd (struct ib_device *ibdev, +struct ib_ucontext *context, +struct ib_udata *udata); +int bnxt_re_dealloc_pd (struct ib_pd *pd); +struct ib_ucontext *bnxt_re_alloc_ucontext (struct ib_device *ibdev, +struct ib_udata *udata); +int bnxt_re_dealloc_ucontext (struct ib_ucontext *context); +int bnxt_re_mmap (struct ib_ucontext *context,struct vm_area_struct *vma);#endif /* __BNXT_RE_IB_VERBS_H__ */
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +7 -0
@@ -34,6 +34,7 @@#include "bnxt_qplib_fp.h" #include "bnxt_qplib_rcfw.h" #include "bnxt_re.h" +#include "bnxt_re_ib_verbs.h" #include "bnxt.h" static char version[] =BNXT_RE_DESC " v" ROCE_DRV_MODULE_VERSION "\n" ;
@@ -418,6 +419,12 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->num_comp_vectors =1 ; ibdev->dma_device = &rdev->en_dev->pdev->dev; + ibdev->alloc_pd = bnxt_re_alloc_pd; + ibdev->dealloc_pd = bnxt_re_dealloc_pd; + ibdev->alloc_ucontext = bnxt_re_alloc_ucontext; + ibdev->dealloc_ucontext = bnxt_re_dealloc_ucontext; + ibdev->mmap = bnxt_re_mmap; +return ib_register_device (ibdev,NULL ); }
drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h new file +32 -0
@@ -0,0 +1,32 @@ +/* Broadcom NetXtreme-C/E RoCE driver. +* +* Copyright (c) 2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +*/ +/* +* Description: Uverbs ABI header file +*/ + +#ifndef __BNXT_RE_UVERBS_ABI_H__ +#define __BNXT_RE_UVERBS_ABI_H__ + +#define BNXT_RE_ABI_VERSION 1 + +struct bnxt_re_uctx_resp { +__u32 dev_id; +__u32 max_qp; +__u32 pg_size; +__u32 cqe_sz; +__u32 max_cqd; +} __packed; + +struct bnxt_re_pd_resp { +__u32 pdid; +__u32 dpi; +__u64 dbr; +} __packed; + +#endif /* __BNXT_RE_UVERBS_ABI_H__*/
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 14/28 bnxt_re: Support for query and modify device verbs
In reply to a message not in the archiveAdding implementation for the query device and modify device verbs
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 17 +++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 1 + drivers/infiniband/hw/bnxtre/bnxt_re.h | 7 ++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 90 +++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 6 ++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 2 + 6 files changed, 123 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c +17 -0
@@ -422,6 +422,23 @@ int bnxt_qplib_alloc_ctx(struct pci_dev *pdev,return rc; } +/* GUID */ +void bnxt_qplib_get_guid (u8 *dev_addr,u8 *guid) +{ +u8 mac[ETH_ALEN ]; + +/* MAC-48 to EUI-64 mapping */ +memcpy (mac, dev_addr,ETH_ALEN ); + guid[0 ] = mac[0 ] ^2 ; + guid[1 ] = mac[1 ]; + guid[2 ] = mac[2 ]; + guid[3 ] =0xff ; + guid[4 ] =0xfe ; + guid[5 ] = mac[3 ]; + guid[6 ] = mac[4 ]; + guid[7 ] = mac[5 ]; +} +static void bnxt_qplib_free_sgid_tbl (struct bnxt_qplib_res *res,struct bnxt_qplib_sgid_tbl *sgid_tbl) {
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h +1 -0
@@ -168,6 +168,7 @@ int bnxt_qplib_alloc_init_hwq(struct pci_dev *pdev, struct bnxt_qplib_hwq *hwq, struct scatterlist *sl, int nmap, u32 *elements, u32 elements_per_page, u32 aux, u32 pg_size, enum bnxt_qplib_hwq_type hwq_type); +void bnxt_qplib_get_guid (u8 *dev_addr,u8 *guid);int bnxt_qplib_alloc_pd (struct bnxt_qplib_pd_tbl *pd_tbl,struct bnxt_qplib_pd *pd); int bnxt_qplib_dealloc_pd(struct bnxt_qplib_res *res,
drivers/infiniband/hw/bnxtre/bnxt_re.h +7 -0
@@ -16,6 +16,13 @@#define BNXT_RE_REF_WAIT_COUNT 10#define BNXT_RE_DESC "Broadcom NetXtreme-C/E RoCE Driver" +#define BNXT_RE_PAGE_SIZE_4K BIT(12) +#define BNXT_RE_PAGE_SIZE_8K BIT(13) +#define BNXT_RE_PAGE_SIZE_64K BIT(16) +#define BNXT_RE_PAGE_SIZE_2M BIT(21) +#define BNXT_RE_PAGE_SIZE_8M BIT(23) +#define BNXT_RE_PAGE_SIZE_1G BIT(30) +#define BNXT_RE_MAX_QPC_COUNT (64 * 1024)#define BNXT_RE_MAX_MRW_COUNT (64 * 1024)#define BNXT_RE_MAX_SRQC_COUNT (64 * 1024)
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +90 -0
96 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +6 -0
@@ -29,6 +29,12 @@ struct bnxt_re_ucontext {spinlock_t sh_lock;/* protect shpg */ }; +int bnxt_re_query_device (struct ib_device *ibdev, +struct ib_device_attr *ib_attr, +struct ib_udata *udata); +int bnxt_re_modify_device (struct ib_device *ibdev, +int device_modify_mask, +struct ib_device_modify *device_modify);struct ib_pd *bnxt_re_alloc_pd (struct ib_device *ibdev,struct ib_ucontext *context,struct ib_udata *udata);
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +2 -0
@@ -419,6 +419,8 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->num_comp_vectors =1 ; ibdev->dma_device = &rdev->en_dev->pdev->dev; + ibdev->query_device = bnxt_re_query_device; + ibdev->modify_device = bnxt_re_modify_device; ibdev->alloc_pd = bnxt_re_alloc_pd; ibdev->dealloc_pd = bnxt_re_dealloc_pd; ibdev->alloc_ucontext = bnxt_re_alloc_ucontext;
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 15/28 bnxt_re: Adding support for port related verbs
In reply to a message not in the archiveImplentation of query_port, modify_port, port_immutable verbs
--- drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 122 ++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 7 ++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 4 + 3 files changed, 133 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +122 -0
@@ -125,6 +125,128 @@ int bnxt_re_modify_device(struct ib_device *ibdev,return 0 ; } +static void __to_ib_speed_width (struct net_device *netdev,u8 *speed,u8 *width) +{ +struct ethtool_link_ksettings lksettings; +u32 espeed; + +if (netdev->ethtool_ops && netdev->ethtool_ops->get_link_ksettings) { +memset (&lksettings,0 ,sizeof (lksettings)); +rtnl_lock (); + netdev->ethtool_ops->get_link_ksettings (netdev, &lksettings); +rtnl_unlock (); + espeed = lksettings.base.speed; + }else { + espeed =SPEED_UNKNOWN ; + } +switch (espeed) { +case SPEED_1000 : + *speed =IB_SPEED_SDR ; + *width =IB_WIDTH_1X ; +break ; +case SPEED_10000 : + *speed =IB_SPEED_QDR ; + *width =IB_WIDTH_1X ; +break ; +case SPEED_20000 : + *speed =IB_SPEED_DDR ; + *width =IB_WIDTH_4X ; +break ; +case SPEED_25000 : + *speed =IB_SPEED_EDR ; + *width =IB_WIDTH_1X ; +break ; +case SPEED_40000 : + *speed =IB_SPEED_QDR ; + *width =IB_WIDTH_4X ; +break ; +case SPEED_50000 : +break ; +default : + *speed =IB_SPEED_SDR ; + *width =IB_WIDTH_1X ; +break ; + } +} + +/* Port */ +int bnxt_re_query_port (struct ib_device *ibdev,u8 port_num, +struct ib_port_attr *port_attr) +{ +struct bnxt_re_dev *rdev =to_bnxt_re_dev (ibdev, ibdev); +struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr; + +memset (port_attr,0 ,sizeof (*port_attr)); + +if (netif_running (rdev->netdev) &&netif_carrier_ok (rdev->netdev)) { + port_attr->state =IB_PORT_ACTIVE ; + port_attr->phys_state =5 ; + }else { + port_attr->state =IB_PORT_DOWN ; + port_attr->phys_state =3 ; + } + port_attr->max_mtu =IB_MTU_4096 ; + port_attr->active_mtu =iboe_get_mtu (rdev->netdev->mtu); + port_attr->gid_tbl_len = dev_attr->max_sgid; + port_attr->port_cap_flags =IB_PORT_CM_SUP |IB_PORT_REINIT_SUP | +IB_PORT_DEVICE_MGMT_SUP | +IB_PORT_VENDOR_CLASS_SUP | +IB_PORT_IP_BASED_GIDS ; + +/* Max MSG size set to 2G for now */ + port_attr->max_msg_sz =0x80000000 ; + port_attr->bad_pkey_cntr =0 ; + port_attr->qkey_viol_cntr =0 ; + port_attr->pkey_tbl_len = dev_attr->max_pkey; + port_attr->lid =0 ; + port_attr->sm_lid =0 ; + port_attr->lmc =0 ; + port_attr->max_vl_num =4 ; + port_attr->sm_sl =0 ; + port_attr->subnet_timeout =0 ; + port_attr->init_type_reply =0 ; +/* call the underlying netdev's ethtool hooks to query speed settings +* for which we acquire rtnl_lock _only_ if it's registered with +* IB stack to avoid race in the NETDEV_UNREG path +*/ +if (test_bit (BNXT_RE_FLAG_IBDEV_REGISTERED , &rdev->flags)) +__to_ib_speed_width (rdev->netdev, &port_attr->active_speed, + &port_attr->active_width); +return 0 ; +} + +int bnxt_re_modify_port (struct ib_device *ibdev,u8 port_num, +int port_modify_mask, +struct ib_port_modify *port_modify) +{ +switch (port_modify_mask) { +case IB_PORT_SHUTDOWN : +break ; +case IB_PORT_INIT_TYPE : +break ; +case IB_PORT_RESET_QKEY_CNTR : +break ; +default : +break ; + } +return 0 ; +} + +int bnxt_re_get_port_immutable (struct ib_device *ibdev,u8 port_num, +struct ib_port_immutable *immutable) +{ +struct ib_port_attr port_attr; + +if (bnxt_re_query_port (ibdev, port_num, &port_attr)) +return -EINVAL ; + + immutable->pkey_tbl_len = port_attr.pkey_tbl_len; + immutable->gid_tbl_len = port_attr.gid_tbl_len; + immutable->core_cap_flags =RDMA_CORE_PORT_IBA_ROCE ; + immutable->core_cap_flags |=RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP ; + immutable->max_mad_size =IB_MGMT_MAD_SIZE ; +return 0 ; +}/* Protection Domains */ int bnxt_re_dealloc_pd (struct ib_pd *ib_pd) {
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +7 -0
@@ -35,6 +35,13 @@ int bnxt_re_query_device(struct ib_device *ibdev,int bnxt_re_modify_device (struct ib_device *ibdev,int device_modify_mask,struct ib_device_modify *device_modify); +int bnxt_re_query_port (struct ib_device *ibdev,u8 port_num, +struct ib_port_attr *port_attr); +int bnxt_re_modify_port (struct ib_device *ibdev,u8 port_num, +int port_modify_mask, +struct ib_port_modify *port_modify); +int bnxt_re_get_port_immutable (struct ib_device *ibdev,u8 port_num, +struct ib_port_immutable *immutable);struct ib_pd *bnxt_re_alloc_pd (struct ib_device *ibdev,struct ib_ucontext *context,struct ib_udata *udata);
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +4 -0
@@ -421,6 +421,10 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->dma_device = &rdev->en_dev->pdev->dev; ibdev->query_device = bnxt_re_query_device; ibdev->modify_device = bnxt_re_modify_device; + + ibdev->query_port = bnxt_re_query_port; + ibdev->modify_port = bnxt_re_modify_port; + ibdev->get_port_immutable = bnxt_re_get_port_immutable; ibdev->alloc_pd = bnxt_re_alloc_pd; ibdev->dealloc_pd = bnxt_re_dealloc_pd; ibdev->alloc_ucontext = bnxt_re_alloc_ucontext;
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 16/28 bnxt_re: Support for GID related verbs
In reply to a message not in the archiveThis patch implements add/del GID, get_netdev and pkey related verbs.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 5 + drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 3 + drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 218 ++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 11 ++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 123 +++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 18 ++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 7 + 7 files changed, 385 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c +5 -0
@@ -484,6 +484,11 @@ static void bnxt_qplib_cleanup_sgid_tbl(struct bnxt_qplib_res *res, {int i; +for (i =0 ; i < sgid_tbl->max; i++) { +if (memcmp (&sgid_tbl->tbl[i], &bnxt_qplib_gid_zero, +sizeof (bnxt_qplib_gid_zero))) +bnxt_qplib_del_sgid (sgid_tbl, &sgid_tbl->tbl[i], true); + }memset (sgid_tbl->tbl,0 ,sizeof (struct bnxt_qplib_gid ) * sgid_tbl->max);memset (sgid_tbl->hw_id,-1 ,sizeof (u16) * sgid_tbl->max); sgid_tbl->active =0 ;
drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h +3 -0
@@ -160,6 +160,9 @@ struct bnxt_qplib_res {struct bnxt_qplib_dpi_tbl dpi_tbl; }; +#define to_bnxt_qplib (ptr, type, member) \ + container_of(ptr, type, member) +struct bnxt_qplib_pd ;struct bnxt_qplib_dev_attr ;
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c +218 -0
230 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h +11 -0
@@ -52,6 +52,17 @@ struct bnxt_qplib_gid {u8 data[16 ]; }; +int bnxt_qplib_get_sgid (struct bnxt_qplib_res *res, +struct bnxt_qplib_sgid_tbl *sgid_tbl,int index, +struct bnxt_qplib_gid *gid); +int bnxt_qplib_del_sgid (struct bnxt_qplib_sgid_tbl *sgid_tbl, +struct bnxt_qplib_gid *gid,bool update); +int bnxt_qplib_add_sgid (struct bnxt_qplib_sgid_tbl *sgid_tbl, +struct bnxt_qplib_gid *gid,u8 *mac,u16 vlan_id, +bool update,u32 *index); +int bnxt_qplib_get_pkey (struct bnxt_qplib_res *res, +struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 index, +u16 *pkey);int bnxt_qplib_del_pkey (struct bnxt_qplib_res *res,struct bnxt_qplib_pkey_tbl *pkey_tbl,u16 *pkey,bool update);
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +123 -0
135 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +18 -0
@@ -14,6 +14,11 @@ #ifndef __BNXT_RE_IB_VERBS_H__ #define __BNXT_RE_IB_VERBS_H__ +struct bnxt_re_gid_ctx { + u32 idx; + u32 refcnt; +}; + struct bnxt_re_pd { struct bnxt_re_dev *rdev; struct ib_pd ib_pd;
@@ -29,6 +34,8 @@ struct bnxt_re_ucontext {spinlock_t sh_lock;/* protect shpg */ }; +struct net_device *bnxt_re_get_netdev (struct ib_device *ibdev,u8 port_num); +int bnxt_re_query_device (struct ib_device *ibdev,struct ib_device_attr *ib_attr,struct ib_udata *udata);
@@ -42,6 +49,17 @@ int bnxt_re_modify_port(struct ib_device *ibdev, u8 port_num, struct ib_port_modify *port_modify);int bnxt_re_get_port_immutable (struct ib_device *ibdev,u8 port_num,struct ib_port_immutable *immutable); +int bnxt_re_query_pkey (struct ib_device *ibdev,u8 port_num, +u16 index,u16 *pkey); +int bnxt_re_del_gid (struct ib_device *ibdev,u8 port_num, +unsigned int index,void **context); +int bnxt_re_add_gid (struct ib_device *ibdev,u8 port_num, +unsigned int index,const union ib_gid *gid, +const struct ib_gid_attr *attr,void **context); +int bnxt_re_query_gid (struct ib_device *ibdev,u8 port_num, +int index,union ib_gid *gid); +enum rdma_link_layer bnxt_re_get_link_layer (struct ib_device *ibdev, +u8 port_num);struct ib_pd *bnxt_re_alloc_pd (struct ib_device *ibdev,struct ib_ucontext *context,struct ib_udata *udata);
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +7 -0
@@ -425,6 +425,13 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->query_port = bnxt_re_query_port; ibdev->modify_port = bnxt_re_modify_port; ibdev->get_port_immutable = bnxt_re_get_port_immutable; + ibdev->query_pkey = bnxt_re_query_pkey; + ibdev->query_gid = bnxt_re_query_gid; + ibdev->get_netdev = bnxt_re_get_netdev; + ibdev->add_gid = bnxt_re_add_gid; + ibdev->del_gid = bnxt_re_del_gid; + ibdev->get_link_layer = bnxt_re_get_link_layer; + ibdev->alloc_pd = bnxt_re_alloc_pd; ibdev->dealloc_pd = bnxt_re_dealloc_pd; ibdev->alloc_ucontext = bnxt_re_alloc_ucontext;
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 17/28 bnxt_re: Support for CQ verbs
In reply to a message not in the archiveThis patch implements support for create_cq, destroy_cq and req_notify_cq verbs.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 183 ++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 47 ++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 154 ++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 19 +++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 4 + drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 11 ++ 6 files changed, 418 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c +183 -0
@@ -24,14 +24,17 @@#include "bnxt_qplib_sp.h" #include "bnxt_qplib_fp.h" +static void bnxt_qplib_arm_cq_enable (struct bnxt_qplib_cq *cq);static void bnxt_qplib_service_nq (unsigned long data) {struct bnxt_qplib_nq *nq = (struct bnxt_qplib_nq *)data;struct bnxt_qplib_hwq *hwq = &nq->hwq;struct nq_base *nqe, **nq_ptr; +int num_cqne_processed =0 ;u32 sw_cons, raw_cons;u32 type;int budget = nq->budget; +u64 q_handle;/* Service the NQ until empty */ raw_cons = hwq->cons;
@@ -45,7 +48,23 @@ static void bnxt_qplib_service_nq(unsigned long data) type =le16_to_cpu (nqe->info10_type &NQ_BASE_TYPE_MASK );switch (type) {case NQ_BASE_TYPE_CQ_NOTIFICATION : + { +struct nq_cn *nqcne = (struct nq_cn *)nqe; + + q_handle =le32_to_cpu (nqcne->cq_handle_low); + q_handle |= (u64 )le32_to_cpu (nqcne->cq_handle_high) + <<32 ; +bnxt_qplib_arm_cq_enable ((struct bnxt_qplib_cq *) + q_handle); +if (!nq->cqn_handler (nq, (struct bnxt_qplib_cq *) + q_handle)) + num_cqne_processed++; +else +dev_warn (&nq->pdev->dev, +"QPLIB: cqn - type 0x%x not handled" , + type);break ; + }case NQ_BASE_TYPE_DBQ_EVENT :break ;default :
@@ -170,3 +189,167 @@ int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq) nq->budget =8 ;return 0 ; } + +/* CQ */ + +/* Spinlock must be held */ +static void bnxt_qplib_arm_cq_enable (struct bnxt_qplib_cq *cq) +{ +struct dbr_dbr db_msg = {0 }; + + db_msg.type_xid = +cpu_to_le32 (((cq->id <<DBR_DBR_XID_SFT ) &DBR_DBR_XID_MASK ) | +DBR_DBR_TYPE_CQ_ARMENA ); +/* Flush memory writes before enabling the CQ */ +wmb (); +__iowrite64_copy (cq->dbr_base, &db_msg,sizeof (db_msg) /sizeof (u64)); +} + +static void bnxt_qplib_arm_cq (struct bnxt_qplib_cq *cq,u32 arm_type) +{ +struct bnxt_qplib_hwq *cq_hwq = &cq->hwq; +struct dbr_dbr db_msg = {0 }; +u32 sw_cons; + +/* Ring DB */ + sw_cons =HWQ_CMP (cq_hwq->cons, cq_hwq); + db_msg.index =cpu_to_le32 ((sw_cons <<DBR_DBR_INDEX_SFT ) & +DBR_DBR_INDEX_MASK ); + db_msg.type_xid = +cpu_to_le32 (((cq->id <<DBR_DBR_XID_SFT ) &DBR_DBR_XID_MASK ) | + arm_type); +/* flush memory writes before arming the CQ */ +wmb (); +__iowrite64_copy (cq->dpi->dbr, &db_msg,sizeof (db_msg) /sizeof (u64)); +} + +int bnxt_qplib_create_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_create_cq req; +struct creq_create_cq_resp *resp; +struct bnxt_qplib_pbl *pbl; +u16 cmd_flags =0 ; +int rc; + + cq->hwq.max_elements = cq->max_wqe; + rc =bnxt_qplib_alloc_init_hwq (res->pdev, &cq->hwq, cq->sghead, + cq->nmap, &cq->hwq.max_elements, +BNXT_QPLIB_MAX_CQE_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_QUEUE ); +if (rc) + goto exit; + +RCFW_CMD_PREP (req,CREATE_CQ , cmd_flags); + +if (!cq->dpi) { +dev_err (&rcfw->pdev->dev, +"QPLIB: FP: CREATE_CQ failed due to NULL DPI" ); +return -EINVAL ; + } + req.dpi =cpu_to_le32 (cq->dpi->dpi); + req.cq_handle =cpu_to_le64 (cq->cq_handle); + + req.cq_size =cpu_to_le32 (cq->hwq.max_elements); + pbl = &cq->hwq.pbl[PBL_LVL_0 ]; + req.pg_size_lvl =cpu_to_le32 ( + ((cq->hwq.level &CMDQ_CREATE_CQ_LVL_MASK ) << +CMDQ_CREATE_CQ_LVL_SFT ) | + (pbl->pg_size ==ROCE_PG_SIZE_4K ?CMDQ_CREATE_CQ_PG_SIZE_PG_4K : + pbl->pg_size ==ROCE_PG_SIZE_8K ?CMDQ_CREATE_CQ_PG_SIZE_PG_8K : + pbl->pg_size ==ROCE_PG_SIZE_64K ?CMDQ_CREATE_CQ_PG_SIZE_PG_64K : + pbl->pg_size ==ROCE_PG_SIZE_2M ?CMDQ_CREATE_CQ_PG_SIZE_PG_2M : + pbl->pg_size ==ROCE_PG_SIZE_8M ?CMDQ_CREATE_CQ_PG_SIZE_PG_8M : + pbl->pg_size ==ROCE_PG_SIZE_1G ?CMDQ_CREATE_CQ_PG_SIZE_PG_1G : +CMDQ_CREATE_CQ_PG_SIZE_PG_4K )); + + req.pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); + + req.cq_fco_cnq_id =cpu_to_le16 ( + ((cq->cnq_hw_ring_id &CMDQ_CREATE_CQ_CNQ_ID_MASK ) << +CMDQ_CREATE_CQ_CNQ_ID_SFT ) |0 ); + + resp = (struct creq_create_cq_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_CQ send failed" ); +return -EINVAL ; + } +/**/ +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_CQ timed out" ); + rc = -ETIMEDOUT ; + goto fail; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_CQ failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); + rc = -EINVAL ; + goto fail; + } + cq->id =le32_to_cpu (resp->xid); + cq->dbr_base = res->dpi_tbl.dbr_bar_reg_iomem; + cq->period =BNXT_QPLIB_QUEUE_START_PERIOD ; +init_waitqueue_head (&cq->waitq); + +bnxt_qplib_arm_cq_enable (cq); +return 0 ; + +fail: +bnxt_qplib_free_hwq (res->pdev, &cq->hwq); +exit: +return rc; +} + +int bnxt_qplib_destroy_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_destroy_cq req; +struct creq_destroy_cq_resp *resp; +u16 cmd_flags =0 ; + +RCFW_CMD_PREP (req,DESTROY_CQ , cmd_flags); + + req.cq_cid =cpu_to_le32 (cq->id); + resp = (struct creq_destroy_cq_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: DESTROY_CQ send failed" ); +return -EINVAL ; + } +/**/ +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: FP: DESTROY_CQ timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: DESTROY_CQ failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } +bnxt_qplib_free_hwq (res->pdev, &cq->hwq); +return 0 ; +} + +void bnxt_qplib_req_notify_cq (struct bnxt_qplib_cq *cq,u32 arm_type) +{ +unsigned long flags; + +spin_lock_irqsave (&cq->hwq.lock, flags); +if (arm_type) +bnxt_qplib_arm_cq (cq, arm_type); + +spin_unlock_irqrestore (&cq->hwq.lock, flags); +}
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h +47 -0
59 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +154 -0
166 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +19 -0
@@ -26,6 +26,19 @@ struct bnxt_re_pd {struct bnxt_qplib_dpi dpi; }; +struct bnxt_re_cq { +struct bnxt_re_dev *rdev; +spinlock_t cq_lock;/* protect cq */ +u16 cq_count; +u16 cq_period; +struct ib_cq ib_cq; +struct bnxt_qplib_cq qplib_cq; +struct bnxt_qplib_cqe *cql; +#define MAX_CQL_PER_POLL 1024 +u32 max_cql; +struct ib_umem *umem; +}; +struct bnxt_re_ucontext {struct bnxt_re_dev *rdev;struct ib_ucontext ib_uctx;
@@ -64,6 +77,12 @@ struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev,struct ib_ucontext *context, struct ib_udata *udata);int bnxt_re_dealloc_pd (struct ib_pd *pd); +struct ib_cq *bnxt_re_create_cq (struct ib_device *ibdev, +const struct ib_cq_init_attr *attr, +struct ib_ucontext *context, +struct ib_udata *udata); +int bnxt_re_destroy_cq (struct ib_cq *cq); +int bnxt_re_req_notify_cq (struct ib_cq *cq,enum ib_cq_notify_flags flags);struct ib_ucontext *bnxt_re_alloc_ucontext (struct ib_device *ibdev,struct ib_udata *udata);int bnxt_re_dealloc_ucontext (struct ib_ucontext *context);
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +4 -0
@@ -434,6 +434,10 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->alloc_pd = bnxt_re_alloc_pd; ibdev->dealloc_pd = bnxt_re_dealloc_pd; + + ibdev->create_cq = bnxt_re_create_cq; + ibdev->destroy_cq = bnxt_re_destroy_cq; + ibdev->req_notify_cq = bnxt_re_req_notify_cq; ibdev->alloc_ucontext = bnxt_re_alloc_ucontext; ibdev->dealloc_ucontext = bnxt_re_dealloc_ucontext; ibdev->mmap = bnxt_re_mmap;
drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h +11 -0
@@ -29,4 +29,15 @@ struct bnxt_re_pd_resp { __u64 dbr; } __packed; +struct bnxt_re_cq_req { +__u64 cq_va; +__u64 cq_handle; +} __packed; + +struct bnxt_re_cq_resp { +__u32 cqid; +__u32 tail; +__u32 phase; +} __packed; +#endif /* __BNXT_RE_UVERBS_ABI_H__*/
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 18/28 bnxt_re: Support for AH verbs
In reply to a message not in the archiveThis patch implements support for create_ah, destroy_ah, query_ah and modify_ah verbs.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 94 ++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 18 +++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 147 ++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 11 ++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 4 + drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 7 ++ 6 files changed, 281 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c +94 -0
@@ -391,3 +391,97 @@ int bnxt_qplib_add_pkey(struct bnxt_qplib_res *res,/* unlock */ return rc; } + +/* AH */ +int bnxt_qplib_create_ah (struct bnxt_qplib_res *res,struct bnxt_qplib_ah *ah) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_create_ah req; +struct creq_create_ah_resp *resp; +u16 cmd_flags =0 ; +u32 temp32[4 ]; +u16 temp16[3 ]; + +RCFW_CMD_PREP (req,CREATE_AH , cmd_flags); + +memcpy (temp32, ah->dgid.data,sizeof (struct bnxt_qplib_gid )); + req.dgid[0 ] =cpu_to_le32 (temp32[0 ]); + req.dgid[1 ] =cpu_to_le32 (temp32[1 ]); + req.dgid[2 ] =cpu_to_le32 (temp32[2 ]); + req.dgid[3 ] =cpu_to_le32 (temp32[3 ]); + + req.type = ah->nw_type; + req.hop_limit = ah->hop_limit; + req.sgid_index =cpu_to_le16 (res->sgid_tbl.hw_id[ah->sgid_index]); + req.dest_vlan_id_flow_label =cpu_to_le32 ((ah->flow_label & +CMDQ_CREATE_AH_FLOW_LABEL_MASK ) | +CMDQ_CREATE_AH_DEST_VLAN_ID_MASK ); + req.pd_id =cpu_to_le32 (ah->pd->id); + req.traffic_class = ah->traffic_class; + +/* MAC in network format */ +memcpy (temp16, ah->dmac,6 ); + req.dest_mac[0 ] =cpu_to_le16 (temp16[0 ]); + req.dest_mac[1 ] =cpu_to_le16 (temp16[1 ]); + req.dest_mac[2 ] =cpu_to_le16 (temp16[2 ]); + + resp = (struct creq_create_ah_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,1 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: CREATE_AH send failed" ); +return -EINVAL ; + } +if (!bnxt_qplib_rcfw_block_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: SP: CREATE_AH timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: CREATE_AH failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } + ah->id =le32_to_cpu (resp->xid); +return 0 ; +} + +int bnxt_qplib_destroy_ah (struct bnxt_qplib_res *res,struct bnxt_qplib_ah *ah) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_destroy_ah req; +struct creq_destroy_ah_resp *resp; +u16 cmd_flags =0 ; + +/* Clean up the AH table in the device */ +RCFW_CMD_PREP (req,DESTROY_AH , cmd_flags); + + req.ah_cid =cpu_to_le32 (ah->id); + + resp = (struct creq_destroy_ah_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,1 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: DESTROY_AH send failed" ); +return -EINVAL ; + } +if (!bnxt_qplib_rcfw_block_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: SP: DESTROY_AH timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: DESTROY_AH failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } +return 0 ; +}
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h +18 -0
@@ -52,6 +52,22 @@ struct bnxt_qplib_gid {u8 data[16 ]; }; +struct bnxt_qplib_ah { +struct bnxt_qplib_gid dgid; +struct bnxt_qplib_pd *pd; +u32 id; +u8 sgid_index; +/* For Query AH if the hw table and SW table are differnt */ +u8 host_sgid_index; +u8 traffic_class; +u32 flow_label; +u8 hop_limit; +u8 sl; +u8 dmac[6 ]; +u16 vlan_id; +u8 nw_type; +}; +int bnxt_qplib_get_sgid (struct bnxt_qplib_res *res,struct bnxt_qplib_sgid_tbl *sgid_tbl,int index,struct bnxt_qplib_gid *gid);
@@ -71,4 +87,6 @@ int bnxt_qplib_add_pkey(struct bnxt_qplib_res *res, bool update);int bnxt_qplib_get_dev_attr (struct bnxt_qplib_rcfw *rcfw,struct bnxt_qplib_dev_attr *attr); +int bnxt_qplib_create_ah (struct bnxt_qplib_res *res,struct bnxt_qplib_ah *ah); +int bnxt_qplib_destroy_ah (struct bnxt_qplib_res *res,struct bnxt_qplib_ah *ah);#endif /* __BNXT_QPLIB_SP_H__*/
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +147 -0
153 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +11 -0
@@ -26,6 +26,12 @@ struct bnxt_re_pd {struct bnxt_qplib_dpi dpi; }; +struct bnxt_re_ah { +struct bnxt_re_dev *rdev; +struct ib_ah ib_ah; +struct bnxt_qplib_ah qplib_ah; +}; +struct bnxt_re_cq {struct bnxt_re_dev *rdev;spinlock_t cq_lock;/* protect cq */
@@ -77,6 +83,11 @@ struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev,struct ib_ucontext *context, struct ib_udata *udata);int bnxt_re_dealloc_pd (struct ib_pd *pd); +struct ib_ah *bnxt_re_create_ah (struct ib_pd *pd, +struct ib_ah_attr *ah_attr); +int bnxt_re_modify_ah (struct ib_ah *ah,struct ib_ah_attr *ah_attr); +int bnxt_re_query_ah (struct ib_ah *ah,struct ib_ah_attr *ah_attr); +int bnxt_re_destroy_ah (struct ib_ah *ah); struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev, const struct ib_cq_init_attr *attr, struct ib_ucontext *context,
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +4 -0
@@ -435,6 +435,10 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->alloc_pd = bnxt_re_alloc_pd; ibdev->dealloc_pd = bnxt_re_dealloc_pd; + ibdev->create_ah = bnxt_re_create_ah; + ibdev->modify_ah = bnxt_re_modify_ah; + ibdev->query_ah = bnxt_re_query_ah; + ibdev->destroy_ah = bnxt_re_destroy_ah; ibdev->create_cq = bnxt_re_create_cq; ibdev->destroy_cq = bnxt_re_destroy_cq; ibdev->req_notify_cq = bnxt_re_req_notify_cq;
drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h +7 -0
@@ -40,4 +40,11 @@ struct bnxt_re_cq_resp { __u32 phase; } __packed; +enum bnxt_re_shpg_offt { +BNXT_RE_BEG_RESV_OFFT =0x00 , +BNXT_RE_AVID_OFFT =0x10 , +BNXT_RE_AVID_SIZE =0x04 , +BNXT_RE_END_RESV_OFFT =0xFF0 +}; +#endif /* __BNXT_RE_UVERBS_ABI_H__*/
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 19/28 bnxt_re: Support memory registration verbs
In reply to a message not in the archiveThis patch implements the kernel and user memory region registration supported by the bnxt_re driver.
This includes the user MR, FRMR, FMR and DMA MR support.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 324 ++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 41 +++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 375 ++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 44 +++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 11 + 5 files changed, 795 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c +324 -0
@@ -485,3 +485,327 @@ int bnxt_qplib_destroy_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah) }return 0 ; } + +/* MRW */ +int bnxt_qplib_free_mrw (struct bnxt_qplib_res *res,struct bnxt_qplib_mrw *mrw) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_deallocate_key req; +struct creq_deallocate_key_resp *resp; +u16 cmd_flags =0 ; + +if (mrw->lkey ==0xFFFFFFFF ) { +dev_info (&res->pdev->dev, +"QPLIB: SP: Free a reserved lkey MRW" ); +return 0 ; + } + +RCFW_CMD_PREP (req,DEALLOCATE_KEY , cmd_flags); + + req.mrw_flags = mrw->type; + +if ((mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE1 ) || + (mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A ) || + (mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B )) + req.key =cpu_to_le32 (mrw->rkey); +else + req.key =cpu_to_le32 (mrw->lkey); + + resp = (struct creq_deallocate_key_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&res->pdev->dev,"QPLIB: SP: FREE_MR send failed" ); +return -EINVAL ; + } +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&res->pdev->dev,"QPLIB: SP: FREE_MR timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&res->pdev->dev,"QPLIB: SP: FREE_MR failed " ); +dev_err (&res->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } +/* Free the qplib's MRW memory */ +if (mrw->hwq.max_elements) +bnxt_qplib_free_hwq (res->pdev, &mrw->hwq); + +return 0 ; +} + +int bnxt_qplib_alloc_mrw (struct bnxt_qplib_res *res,struct bnxt_qplib_mrw *mrw) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_allocate_mrw req; +struct creq_allocate_mrw_resp *resp; +u16 cmd_flags =0 ; + +RCFW_CMD_PREP (req,ALLOCATE_MRW , cmd_flags); + + req.pd_id =cpu_to_le32 (mrw->pd->id); + req.mrw_flags = mrw->type; +if ((mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_PMR && + mrw->flags &BNXT_QPLIB_FR_PMR ) || + mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A || + mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B ) + req.access =CMDQ_ALLOCATE_MRW_ACCESS_CONSUMER_OWNED_KEY ; + req.mrw_handle =cpu_to_le64 (mrw); + + resp = (struct creq_allocate_mrw_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: ALLOC_MRW send failed" ); +return -EINVAL ; + } +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: SP: ALLOC_MRW timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: ALLOC_MRW failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } +if ((mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE1 ) || + (mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2A ) || + (mrw->type ==CMDQ_ALLOCATE_MRW_MRW_FLAGS_MW_TYPE2B )) + mrw->rkey =le32_to_cpu (resp->xid); +else + mrw->lkey =le32_to_cpu (resp->xid); +return 0 ; +} + +int bnxt_qplib_dereg_mrw (struct bnxt_qplib_res *res,struct bnxt_qplib_mrw *mrw, +bool block) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_deregister_mr req; +struct creq_deregister_mr_resp *resp; +u16 cmd_flags =0 ; +int rc; + +RCFW_CMD_PREP (req,DEREGISTER_MR , cmd_flags); + + req.lkey =cpu_to_le32 (mrw->lkey); + resp = (struct creq_deregister_mr_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL , block); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: DEREG_MR send failed" ); +return -EINVAL ; + } +if (block) + rc =bnxt_qplib_rcfw_block_for_resp (rcfw, +le16_to_cpu (req.cookie)); +else + rc =bnxt_qplib_rcfw_wait_for_resp (rcfw, +le16_to_cpu (req.cookie)); +if (!rc) { +/* Cmd timed out */ +dev_err (&res->pdev->dev,"QPLIB: SP: DEREG_MR timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: SP: DEREG_MR failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } + +/* Free the qplib's MR memory */ +if (mrw->hwq.max_elements) { + mrw->va =0 ; + mrw->total_size =0 ; +bnxt_qplib_free_hwq (res->pdev, &mrw->hwq); + } + +return 0 ; +} + +int bnxt_qplib_reg_mr (struct bnxt_qplib_res *res,struct bnxt_qplib_mrw *mr, +u64 *pbl_tbl,int num_pbls,bool block) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_register_mr req; +struct creq_register_mr_resp *resp; +u16 cmd_flags =0 , level; +int pg_ptrs, pages, i, rc; +dma_addr_t **pbl_ptr; +u32 pg_size; + +if (num_pbls) { + pg_ptrs =roundup_pow_of_two (num_pbls); + pages = pg_ptrs >>MAX_PBL_LVL_1_PGS_SHIFT ; +if (!pages) + pages++; + +if (pages >MAX_PBL_LVL_1_PGS ) { +dev_err (&res->pdev->dev,"QPLIB: SP: Reg MR pages " ); +dev_err (&res->pdev->dev, +"requested (0x%x) exceeded max (0x%x)" , + pages,MAX_PBL_LVL_1_PGS ); +return -ENOMEM ; + } +/* Free the hwq if it already exist, must be a rereg */ +if (mr->hwq.max_elements) +bnxt_qplib_free_hwq (res->pdev, &mr->hwq); + + mr->hwq.max_elements = pages; + rc =bnxt_qplib_alloc_init_hwq (res->pdev, &mr->hwq,NULL ,0 , + &mr->hwq.max_elements, +PAGE_SIZE ,0 ,PAGE_SIZE , +HWQ_TYPE_CTX ); +if (rc) { +dev_err (&res->pdev->dev, +"SP: Reg MR memory allocation failed" ); +return -ENOMEM ; + } +/* Write to the hwq */ + pbl_ptr = (u64 **)mr->hwq.pbl_ptr; +for (i =0 ; i < num_pbls; i++) + pbl_ptr[PTR_PG (i)][PTR_IDX (i)] = + (pbl_tbl[i] &PAGE_MASK ) |PTU_PTE_VALID ; + } + +RCFW_CMD_PREP (req,REGISTER_MR , cmd_flags); + +/* Configure the request */ +if (mr->hwq.level ==PBL_LVL_MAX ) { + level =0 ; + req.pbl =0 ; + pg_size =PAGE_SIZE ; + }else { + level = mr->hwq.level +1 ; + req.pbl =cpu_to_le64 (mr->hwq.pbl[PBL_LVL_0 ].pg_map_arr[0 ]); + pg_size = mr->hwq.pbl[PBL_LVL_0 ].pg_size; + } + req.log2_pg_size_lvl = (level <<CMDQ_REGISTER_MR_LVL_SFT ) | + ((ilog2 (pg_size) << +CMDQ_REGISTER_MR_LOG2_PG_SIZE_SFT ) & +CMDQ_REGISTER_MR_LOG2_PG_SIZE_MASK ); + req.access = (mr->flags &0xFFFF ); + req.va =cpu_to_le64 (mr->va); + req.key =cpu_to_le32 (mr->lkey); + req.mr_size =cpu_to_le64 (mr->total_size); + + resp = (struct creq_register_mr_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL , block); +if (!resp) { +dev_err (&res->pdev->dev,"SP: REG_MR send failed" ); + rc = -EINVAL ; + goto fail; + } +if (block) + rc =bnxt_qplib_rcfw_block_for_resp (rcfw, +le16_to_cpu (req.cookie)); +else + rc =bnxt_qplib_rcfw_wait_for_resp (rcfw, +le16_to_cpu (req.cookie)); +if (!rc) { +/* Cmd timed out */ +dev_err (&res->pdev->dev,"SP: REG_MR timed out" ); + rc = -ETIMEDOUT ; + goto fail; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&res->pdev->dev,"QPLIB: SP: REG_MR failed " ); +dev_err (&res->pdev->dev, +"QPLIB: SP: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); + rc = -EINVAL ; + goto fail; + } +return 0 ; + +fail: +if (mr->hwq.max_elements) +bnxt_qplib_free_hwq (res->pdev, &mr->hwq); +return rc; +} + +int bnxt_qplib_alloc_fast_reg_page_list (struct bnxt_qplib_res *res, +struct bnxt_qplib_frpl *frpl, +int max_pg_ptrs) +{ +int pg_ptrs, pages, rc; + +/* Re-calculate the max to fit the HWQ allocation model */ + pg_ptrs =roundup_pow_of_two (max_pg_ptrs); + pages = pg_ptrs >>MAX_PBL_LVL_1_PGS_SHIFT ; +if (!pages) + pages++; + +if (pages >MAX_PBL_LVL_1_PGS ) +return -ENOMEM ; + + frpl->hwq.max_elements = pages; + rc =bnxt_qplib_alloc_init_hwq (res->pdev, &frpl->hwq,NULL ,0 , + &frpl->hwq.max_elements,PAGE_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_CTX ); +if (!rc) + frpl->max_pg_ptrs = pg_ptrs; + +return rc; +} + +int bnxt_qplib_free_fast_reg_page_list (struct bnxt_qplib_res *res, +struct bnxt_qplib_frpl *frpl) +{ +bnxt_qplib_free_hwq (res->pdev, &frpl->hwq); +return 0 ; +} + +int bnxt_qplib_map_tc2cos (struct bnxt_qplib_res *res,u16 *cids) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_map_tc_to_cos req; +struct creq_map_tc_to_cos_resp *resp; +u16 cmd_flags =0 ; +int tleft; + +RCFW_CMD_PREP (req,MAP_TC_TO_COS , cmd_flags); + req.cos0 = cids[0 ]; + req.cos1 = cids[1 ]; + + resp =bnxt_qplib_rcfw_send_message (rcfw, (void *)&req,NULL ,0 ); +if (!resp) { +dev_err (&res->pdev->dev,"QPLIB: SP: MAP_TC2COS send failed" ); +return -EINVAL ; + } + + tleft =bnxt_qplib_rcfw_block_for_resp (rcfw,le16_to_cpu (req.cookie)); +if (!tleft) { +dev_err (&res->pdev->dev,"QPLIB: SP: MAP_TC2COS timed out" ); +return -ETIMEDOUT ; + } + +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&res->pdev->dev,"QPLIB: SP: MAP_TC2COS failed " ); +dev_err (&res->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } + +return 0 ; +}
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h +41 -0
51 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +375 -0
387 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +44 -0
56 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +11 -0
@@ -442,6 +442,17 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->create_cq = bnxt_re_create_cq; ibdev->destroy_cq = bnxt_re_destroy_cq; ibdev->req_notify_cq = bnxt_re_req_notify_cq; + + ibdev->get_dma_mr = bnxt_re_get_dma_mr; + ibdev->dereg_mr = bnxt_re_dereg_mr; + ibdev->alloc_mr = bnxt_re_alloc_mr; + ibdev->map_mr_sg = bnxt_re_map_mr_sg; + ibdev->alloc_fmr = bnxt_re_alloc_fmr; + ibdev->map_phys_fmr = bnxt_re_map_phys_fmr; + ibdev->unmap_fmr = bnxt_re_unmap_fmr; + ibdev->dealloc_fmr = bnxt_re_dealloc_fmr; + + ibdev->reg_user_mr = bnxt_re_reg_user_mr; ibdev->alloc_ucontext = bnxt_re_alloc_ucontext; ibdev->dealloc_ucontext = bnxt_re_dealloc_ucontext; ibdev->mmap = bnxt_re_mmap;
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 20/28 bnxt_re: Support QP verbs
In reply to a message not in the archiveThis patch implements create_qp, destroy_qp, query_qp and modify_qp verbs.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 873 ++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 250 +++++++ drivers/infiniband/hw/bnxtre/bnxt_re.h | 14 + drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 762 +++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 21 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 6 + drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 10 + 7 files changed, 1936 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c +873 -0
@@ -25,6 +25,69 @@#include "bnxt_qplib_fp.h" static void bnxt_qplib_arm_cq_enable (struct bnxt_qplib_cq *cq); + +static void bnxt_qplib_free_qp_hdr_buf (struct bnxt_qplib_res *res, +struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_q *rq = &qp->rq; +struct bnxt_qplib_q *sq = &qp->sq; + +if (qp->rq_hdr_buf) +dma_free_coherent (&res->pdev->dev, + rq->hwq.max_elements * qp->rq_hdr_buf_size, + qp->rq_hdr_buf, qp->rq_hdr_buf_map); +if (qp->sq_hdr_buf) +dma_free_coherent (&res->pdev->dev, + sq->hwq.max_elements * qp->sq_hdr_buf_size, + qp->sq_hdr_buf, qp->sq_hdr_buf_map); + qp->rq_hdr_buf =NULL ; + qp->sq_hdr_buf =NULL ; + qp->rq_hdr_buf_map =0 ; + qp->sq_hdr_buf_map =0 ; + qp->sq_hdr_buf_size =0 ; + qp->rq_hdr_buf_size =0 ; +} + +static int bnxt_qplib_alloc_qp_hdr_buf (struct bnxt_qplib_res *res, +struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_q *rq = &qp->rq; +struct bnxt_qplib_q *sq = &qp->rq; +int rc =0 ; + +if (qp->sq_hdr_buf_size && sq->hwq.max_elements) { + qp->sq_hdr_buf =dma_alloc_coherent (&res->pdev->dev, + sq->hwq.max_elements * + qp->sq_hdr_buf_size, + &qp->sq_hdr_buf_map,GFP_KERNEL ); +if (!qp->sq_hdr_buf) { + rc = -ENOMEM ; +dev_err (&res->pdev->dev, +"QPLIB: Failed to create sq_hdr_buf" ); + goto fail; + } + } + +if (qp->rq_hdr_buf_size && rq->hwq.max_elements) { + qp->rq_hdr_buf =dma_alloc_coherent (&res->pdev->dev, + rq->hwq.max_elements * + qp->rq_hdr_buf_size, + &qp->rq_hdr_buf_map, +GFP_KERNEL ); +if (!qp->rq_hdr_buf) { + rc = -ENOMEM ; +dev_err (&res->pdev->dev, +"QPLIB: Failed to create rq_hdr_buf" ); + goto fail; + } + } +return 0 ; + +fail: +bnxt_qplib_free_qp_hdr_buf (res, qp); +return rc; +} +static void bnxt_qplib_service_nq (unsigned long data) {struct bnxt_qplib_nq *nq = (struct bnxt_qplib_nq *)data;
@@ -190,6 +253,816 @@ int bnxt_qplib_alloc_nq(struct pci_dev *pdev, struct bnxt_qplib_nq *nq)return 0 ; } +/* QP */ +int bnxt_qplib_create_qp1 (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_create_qp1 req; +struct creq_create_qp1_resp *resp; +struct bnxt_qplib_pbl *pbl; +struct bnxt_qplib_q *sq = &qp->sq; +struct bnxt_qplib_q *rq = &qp->rq; +int rc; +u16 cmd_flags =0 ; +u32 qp_flags =0 ; + +RCFW_CMD_PREP (req,CREATE_QP1 , cmd_flags); + +/* General */ + req.type = qp->type; + req.dpi =cpu_to_le32 (qp->dpi->dpi); + req.qp_handle =cpu_to_le64 (qp->qp_handle); + +/* SQ */ + sq->hwq.max_elements = sq->max_wqe; + rc =bnxt_qplib_alloc_init_hwq (res->pdev, &sq->hwq,NULL ,0 , + &sq->hwq.max_elements, +BNXT_QPLIB_MAX_SQE_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_QUEUE ); +if (rc) + goto exit; + + sq->swq =kcalloc (sq->hwq.max_elements,sizeof (*sq->swq),GFP_KERNEL ); +if (!sq->swq) { + rc = -ENOMEM ; + goto fail_sq; + } + pbl = &sq->hwq.pbl[PBL_LVL_0 ]; + req.sq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); + req.sq_pg_size_sq_lvl = + ((sq->hwq.level &CMDQ_CREATE_QP1_SQ_LVL_MASK ) + <<CMDQ_CREATE_QP1_SQ_LVL_SFT ) | + (pbl->pg_size ==ROCE_PG_SIZE_4K ? +CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K : + pbl->pg_size ==ROCE_PG_SIZE_8K ? +CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8K : + pbl->pg_size ==ROCE_PG_SIZE_64K ? +CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_64K : + pbl->pg_size ==ROCE_PG_SIZE_2M ? +CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_2M : + pbl->pg_size ==ROCE_PG_SIZE_8M ? +CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_8M : + pbl->pg_size ==ROCE_PG_SIZE_1G ? +CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_1G : +CMDQ_CREATE_QP1_SQ_PG_SIZE_PG_4K ); + +if (qp->scq) + req.scq_cid =cpu_to_le32 (qp->scq->id); + + qp_flags |=CMDQ_CREATE_QP1_QP_FLAGS_RESERVED_LKEY_ENABLE ; + +/* RQ */ +if (rq->max_wqe) { + rq->hwq.max_elements = qp->rq.max_wqe; + rc =bnxt_qplib_alloc_init_hwq (res->pdev, &rq->hwq,NULL ,0 , + &rq->hwq.max_elements, +BNXT_QPLIB_MAX_RQE_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_QUEUE ); +if (rc) + goto fail_sq; + + rq->swq =kcalloc (rq->hwq.max_elements,sizeof (*rq->swq), +GFP_KERNEL ); +if (!rq->swq) { + rc = -ENOMEM ; + goto fail_rq; + } + pbl = &rq->hwq.pbl[PBL_LVL_0 ]; + req.rq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); + req.rq_pg_size_rq_lvl = + ((rq->hwq.level &CMDQ_CREATE_QP1_RQ_LVL_MASK ) << +CMDQ_CREATE_QP1_RQ_LVL_SFT ) | + (pbl->pg_size ==ROCE_PG_SIZE_4K ? +CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K : + pbl->pg_size ==ROCE_PG_SIZE_8K ? +CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8K : + pbl->pg_size ==ROCE_PG_SIZE_64K ? +CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_64K : + pbl->pg_size ==ROCE_PG_SIZE_2M ? +CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_2M : + pbl->pg_size ==ROCE_PG_SIZE_8M ? +CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_8M : + pbl->pg_size ==ROCE_PG_SIZE_1G ? +CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_1G : +CMDQ_CREATE_QP1_RQ_PG_SIZE_PG_4K ); +if (qp->rcq) + req.rcq_cid =cpu_to_le32 (qp->rcq->id); + } + +/* Header buffer - allow hdr_buf pass in */ + rc =bnxt_qplib_alloc_qp_hdr_buf (res, qp); +if (rc) { + rc = -ENOMEM ; + goto fail; + } + req.qp_flags =cpu_to_le32 (qp_flags); + req.sq_size =cpu_to_le32 (sq->hwq.max_elements); + req.rq_size =cpu_to_le32 (rq->hwq.max_elements); + + req.sq_fwo_sq_sge = +cpu_to_le16 ((sq->max_sge &CMDQ_CREATE_QP1_SQ_SGE_MASK ) << +CMDQ_CREATE_QP1_SQ_SGE_SFT ); + req.rq_fwo_rq_sge = +cpu_to_le16 ((rq->max_sge &CMDQ_CREATE_QP1_RQ_SGE_MASK ) << +CMDQ_CREATE_QP1_RQ_SGE_SFT ); + + req.pd_id =cpu_to_le32 (qp->pd->id); + + resp = (struct creq_create_qp1_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&res->pdev->dev,"QPLIB: FP: CREATE_QP1 send failed" ); + rc = -EINVAL ; + goto fail; + } +/**/ +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_QP1 timed out" ); + rc = -ETIMEDOUT ; + goto fail; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_QP1 failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); + rc = -EINVAL ; + goto fail; + } + qp->id =le32_to_cpu (resp->xid); + qp->cur_qp_state =CMDQ_MODIFY_QP_NEW_STATE_RESET ; + sq->flush_in_progress = false; + rq->flush_in_progress = false; + +return 0 ; + +fail: +bnxt_qplib_free_qp_hdr_buf (res, qp); +fail_rq: +bnxt_qplib_free_hwq (res->pdev, &rq->hwq); +kfree (rq->swq); +fail_sq: +bnxt_qplib_free_hwq (res->pdev, &sq->hwq); +kfree (sq->swq); +exit: +return rc; +} + +int bnxt_qplib_create_qp (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct sq_send *hw_sq_send_hdr, **hw_sq_send_ptr; +struct cmdq_create_qp req; +struct creq_create_qp_resp *resp; +struct bnxt_qplib_pbl *pbl; +struct sq_psn_search **psn_search_ptr; +unsigned long long int psn_search, poff =0 ; +struct bnxt_qplib_q *sq = &qp->sq; +struct bnxt_qplib_q *rq = &qp->rq; +struct bnxt_qplib_hwq *xrrq; +int i, rc, req_size, psn_sz; +u16 cmd_flags =0 , max_ssge; +u32 sw_prod, qp_flags =0 ; + +RCFW_CMD_PREP (req,CREATE_QP , cmd_flags); + +/* General */ + req.type = qp->type; + req.dpi =cpu_to_le32 (qp->dpi->dpi); + req.qp_handle =cpu_to_le64 (qp->qp_handle); + +/* SQ */ + psn_sz = (qp->type ==CMDQ_CREATE_QP_TYPE_RC ) ? +sizeof (struct sq_psn_search ) :0 ; + sq->hwq.max_elements = sq->max_wqe; + rc =bnxt_qplib_alloc_init_hwq (res->pdev, &sq->hwq, sq->sglist, + sq->nmap, &sq->hwq.max_elements, +BNXT_QPLIB_MAX_SQE_ENTRY_SIZE , + psn_sz, +PAGE_SIZE ,HWQ_TYPE_QUEUE ); +if (rc) + goto exit; + + sq->swq =kcalloc (sq->hwq.max_elements,sizeof (*sq->swq),GFP_KERNEL ); +if (!sq->swq) { + rc = -ENOMEM ; + goto fail_sq; + } + hw_sq_send_ptr = (struct sq_send **)sq->hwq.pbl_ptr; +if (psn_sz) { + psn_search_ptr = (struct sq_psn_search **) + &hw_sq_send_ptr[SQE_PG (sq->hwq.max_elements)]; + psn_search = (unsigned long long int ) + &hw_sq_send_ptr[SQE_PG (sq->hwq.max_elements)] + [SQE_IDX (sq->hwq.max_elements)]; +if (psn_search & ~PAGE_MASK ) { +/* If the psn_search does not start on a page boundary, +* then calculate the offset +*/ + poff = (psn_search & ~PAGE_MASK ) / +BNXT_QPLIB_MAX_PSNE_ENTRY_SIZE ; + } +for (i =0 ; i < sq->hwq.max_elements; i++) + sq->swq[i].psn_search = + &psn_search_ptr[PSNE_PG (i + poff)] + [PSNE_IDX (i + poff)]; + } + pbl = &sq->hwq.pbl[PBL_LVL_0 ]; + req.sq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); + req.sq_pg_size_sq_lvl = + ((sq->hwq.level &CMDQ_CREATE_QP_SQ_LVL_MASK ) + <<CMDQ_CREATE_QP_SQ_LVL_SFT ) | + (pbl->pg_size ==ROCE_PG_SIZE_4K ? +CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K : + pbl->pg_size ==ROCE_PG_SIZE_8K ? +CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8K : + pbl->pg_size ==ROCE_PG_SIZE_64K ? +CMDQ_CREATE_QP_SQ_PG_SIZE_PG_64K : + pbl->pg_size ==ROCE_PG_SIZE_2M ? +CMDQ_CREATE_QP_SQ_PG_SIZE_PG_2M : + pbl->pg_size ==ROCE_PG_SIZE_8M ? +CMDQ_CREATE_QP_SQ_PG_SIZE_PG_8M : + pbl->pg_size ==ROCE_PG_SIZE_1G ? +CMDQ_CREATE_QP_SQ_PG_SIZE_PG_1G : +CMDQ_CREATE_QP_SQ_PG_SIZE_PG_4K ); + +/* initialize all SQ WQEs to LOCAL_INVALID (sq prep for hw fetch) */ + hw_sq_send_ptr = (struct sq_send **)sq->hwq.pbl_ptr; +for (sw_prod =0 ; sw_prod < sq->hwq.max_elements; sw_prod++) { + hw_sq_send_hdr = &hw_sq_send_ptr[SQE_PG (sw_prod)] + [SQE_IDX (sw_prod)]; + hw_sq_send_hdr->wqe_type =SQ_BASE_WQE_TYPE_LOCAL_INVALID ; + } + +if (qp->scq) + req.scq_cid =cpu_to_le32 (qp->scq->id); + + qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_RESERVED_LKEY_ENABLE ; + qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_FR_PMR_ENABLED ; +if (qp->sig_type) + qp_flags |=CMDQ_CREATE_QP_QP_FLAGS_FORCE_COMPLETION ; + +/* RQ */ +if (rq->max_wqe) { + rq->hwq.max_elements = rq->max_wqe; + rc =bnxt_qplib_alloc_init_hwq (res->pdev, &rq->hwq, rq->sglist, + rq->nmap, &rq->hwq.max_elements, +BNXT_QPLIB_MAX_RQE_ENTRY_SIZE ,0 , +PAGE_SIZE ,HWQ_TYPE_QUEUE ); +if (rc) + goto fail_sq; + + rq->swq =kcalloc (rq->hwq.max_elements,sizeof (*rq->swq), +GFP_KERNEL ); +if (!rq->swq) { + rc = -ENOMEM ; + goto fail_rq; + } + pbl = &rq->hwq.pbl[PBL_LVL_0 ]; + req.rq_pbl =cpu_to_le64 (pbl->pg_map_arr[0 ]); + req.rq_pg_size_rq_lvl = + ((rq->hwq.level &CMDQ_CREATE_QP_RQ_LVL_MASK ) << +CMDQ_CREATE_QP_RQ_LVL_SFT ) | + (pbl->pg_size ==ROCE_PG_SIZE_4K ? +CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K : + pbl->pg_size ==ROCE_PG_SIZE_8K ? +CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8K : + pbl->pg_size ==ROCE_PG_SIZE_64K ? +CMDQ_CREATE_QP_RQ_PG_SIZE_PG_64K : + pbl->pg_size ==ROCE_PG_SIZE_2M ? +CMDQ_CREATE_QP_RQ_PG_SIZE_PG_2M : + pbl->pg_size ==ROCE_PG_SIZE_8M ? +CMDQ_CREATE_QP_RQ_PG_SIZE_PG_8M : + pbl->pg_size ==ROCE_PG_SIZE_1G ? +CMDQ_CREATE_QP_RQ_PG_SIZE_PG_1G : +CMDQ_CREATE_QP_RQ_PG_SIZE_PG_4K ); + } + +if (qp->rcq) + req.rcq_cid =cpu_to_le32 (qp->rcq->id); + req.qp_flags =cpu_to_le32 (qp_flags); + req.sq_size =cpu_to_le32 (sq->hwq.max_elements); + req.rq_size =cpu_to_le32 (rq->hwq.max_elements); + qp->sq_hdr_buf =NULL ; + qp->rq_hdr_buf =NULL ; + + rc =bnxt_qplib_alloc_qp_hdr_buf (res, qp); +if (rc) + goto fail_rq; + +/* CTRL-22434: Irrespective of the requested SGE count on the SQ +* always create the QP with max send sges possible if the requested +* inline size is greater than 0. +*/ + max_ssge = qp->max_inline_data ?6 : sq->max_sge; + req.sq_fwo_sq_sge =cpu_to_le16 ( + ((max_ssge &CMDQ_CREATE_QP_SQ_SGE_MASK ) + <<CMDQ_CREATE_QP_SQ_SGE_SFT ) |0 ); + req.rq_fwo_rq_sge =cpu_to_le16 ( + ((rq->max_sge &CMDQ_CREATE_QP_RQ_SGE_MASK ) + <<CMDQ_CREATE_QP_RQ_SGE_SFT ) |0 ); +/* ORRQ and IRRQ */ +if (psn_sz) { + xrrq = &qp->orrq; + xrrq->max_elements = +ORD_LIMIT_TO_ORRQ_SLOTS (qp->max_rd_atomic); + req_size = xrrq->max_elements * +BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE +PAGE_SIZE -1 ; + req_size &= ~(PAGE_SIZE -1 ); + rc =bnxt_qplib_alloc_init_hwq (res->pdev, xrrq,NULL ,0 , + &xrrq->max_elements, +BNXT_QPLIB_MAX_ORRQE_ENTRY_SIZE , +0 , req_size,HWQ_TYPE_CTX ); +if (rc) + goto fail_buf_free; + pbl = &xrrq->pbl[PBL_LVL_0 ]; + req.orrq_addr =cpu_to_le64 (pbl->pg_map_arr[0 ]); + + xrrq = &qp->irrq; + xrrq->max_elements =IRD_LIMIT_TO_IRRQ_SLOTS ( + qp->max_dest_rd_atomic); + req_size = xrrq->max_elements * +BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE +PAGE_SIZE -1 ; + req_size &= ~(PAGE_SIZE -1 ); + + rc =bnxt_qplib_alloc_init_hwq (res->pdev, xrrq,NULL ,0 , + &xrrq->max_elements, +BNXT_QPLIB_MAX_IRRQE_ENTRY_SIZE , +0 , req_size,HWQ_TYPE_CTX ); +if (rc) + goto fail_orrq; + + pbl = &xrrq->pbl[PBL_LVL_0 ]; + req.irrq_addr =cpu_to_le64 (pbl->pg_map_arr[0 ]); + } + req.pd_id =cpu_to_le32 (qp->pd->id); + + resp = (struct creq_create_qp_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_QP send failed" ); + rc = -EINVAL ; + goto fail; + } +/**/ +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_QP timed out" ); + rc = -ETIMEDOUT ; + goto fail; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: CREATE_QP failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); + rc = -EINVAL ; + goto fail; + } + qp->id =le32_to_cpu (resp->xid); + qp->cur_qp_state =CMDQ_MODIFY_QP_NEW_STATE_RESET ; + sq->flush_in_progress = false; + rq->flush_in_progress = false; + +return 0 ; + +fail: +if (qp->irrq.max_elements) +bnxt_qplib_free_hwq (res->pdev, &qp->irrq); +fail_orrq: +if (qp->orrq.max_elements) +bnxt_qplib_free_hwq (res->pdev, &qp->orrq); +fail_buf_free: +bnxt_qplib_free_qp_hdr_buf (res, qp); +fail_rq: +bnxt_qplib_free_hwq (res->pdev, &rq->hwq); +kfree (rq->swq); +fail_sq: +bnxt_qplib_free_hwq (res->pdev, &sq->hwq); +kfree (sq->swq); +exit: +return rc; +} + +static void __filter_modify_flags (struct bnxt_qplib_qp *qp) +{ +switch (qp->cur_qp_state) { +case CMDQ_MODIFY_QP_NEW_STATE_RESET : +switch (qp->state) { +case CMDQ_MODIFY_QP_NEW_STATE_INIT : +break ; +default : +break ; + } +break ; +case CMDQ_MODIFY_QP_NEW_STATE_INIT : +switch (qp->state) { +case CMDQ_MODIFY_QP_NEW_STATE_RTR : +/* INIT->RTR, configure the path_mtu to the default +* 2048 if not being requested +*/ +if (!(qp->modify_flags & +CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU )) { + qp->modify_flags |= +CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU ; + qp->path_mtu =CMDQ_MODIFY_QP_PATH_MTU_MTU_2048 ; + } + qp->modify_flags &= + ~CMDQ_MODIFY_QP_MODIFY_MASK_VLAN_ID ; +/* Bono FW requires the max_dest_rd_atomic to be >= 1 */ +if (qp->max_dest_rd_atomic <1 ) + qp->max_dest_rd_atomic =1 ; + qp->modify_flags &= ~CMDQ_MODIFY_QP_MODIFY_MASK_SRC_MAC ; +/* Bono FW 20.6.5 requires SGID_INDEX configuration */ +if (!(qp->modify_flags & +CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX )) { + qp->modify_flags |= +CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX ; + qp->ah.sgid_index =0 ; + } +break ; +default : +break ; + } +break ; +case CMDQ_MODIFY_QP_NEW_STATE_RTR : +switch (qp->state) { +case CMDQ_MODIFY_QP_NEW_STATE_RTS : +/* Bono FW requires the max_rd_atomic to be >= 1 */ +if (qp->max_rd_atomic <1 ) + qp->max_rd_atomic =1 ; +/* Bono FW does not allow PKEY_INDEX, +* DGID, FLOW_LABEL, SGID_INDEX, HOP_LIMIT, +* TRAFFIC_CLASS, DEST_MAC, PATH_MTU, RQ_PSN, +* MIN_RNR_TIMER, MAX_DEST_RD_ATOMIC, DEST_QP_ID +* modification +*/ + qp->modify_flags &= + ~(CMDQ_MODIFY_QP_MODIFY_MASK_PKEY | +CMDQ_MODIFY_QP_MODIFY_MASK_DGID | +CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL | +CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX | +CMDQ_MODIFY_QP_MODIFY_MASK_HOP_LIMIT | +CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS | +CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC | +CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU | +CMDQ_MODIFY_QP_MODIFY_MASK_RQ_PSN | +CMDQ_MODIFY_QP_MODIFY_MASK_MIN_RNR_TIMER | +CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC + |CMDQ_MODIFY_QP_MODIFY_MASK_DEST_QP_ID ); +break ; +default : +break ; + } +break ; +case CMDQ_MODIFY_QP_NEW_STATE_RTS : +break ; +case CMDQ_MODIFY_QP_NEW_STATE_SQD : +break ; +case CMDQ_MODIFY_QP_NEW_STATE_SQE : +break ; +case CMDQ_MODIFY_QP_NEW_STATE_ERR : +break ; +default : +break ; + } +} + +int bnxt_qplib_modify_qp (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_modify_qp req; +struct creq_modify_qp_resp *resp; +u16 cmd_flags =0 , pkey; +u32 temp32[4 ]; +u32 bmask; + +RCFW_CMD_PREP (req,MODIFY_QP , cmd_flags); + +/* Filter out the qp_attr_mask based on the state->new transition */ +__filter_modify_flags (qp); + bmask = qp->modify_flags; + req.modify_mask =cpu_to_le64 (qp->modify_flags); + req.qp_cid =cpu_to_le32 (qp->id); +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_STATE ) { + req.network_type_en_sqd_async_notify_new_state = + (qp->state &CMDQ_MODIFY_QP_NEW_STATE_MASK ) | + (qp->en_sqd_async_notify ? +CMDQ_MODIFY_QP_EN_SQD_ASYNC_NOTIFY :0 ); + } + req.network_type_en_sqd_async_notify_new_state |= qp->nw_type; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS ) + req.access = qp->access; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_PKEY ) { +if (!bnxt_qplib_get_pkey (res, &res->pkey_tbl, + qp->pkey_index, &pkey)) + req.pkey =cpu_to_le16 (pkey); + } +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_QKEY ) + req.qkey =cpu_to_le32 (qp->qkey); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_DGID ) { +memcpy (temp32, qp->ah.dgid.data,sizeof (struct bnxt_qplib_gid )); + req.dgid[0 ] =cpu_to_le32 (temp32[0 ]); + req.dgid[1 ] =cpu_to_le32 (temp32[1 ]); + req.dgid[2 ] =cpu_to_le32 (temp32[2 ]); + req.dgid[3 ] =cpu_to_le32 (temp32[3 ]); + } +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL ) + req.flow_label =cpu_to_le32 (qp->ah.flow_label); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_SGID_INDEX ) + req.sgid_index =cpu_to_le16 (res->sgid_tbl.hw_id + [qp->ah.sgid_index]); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_HOP_LIMIT ) + req.hop_limit = qp->ah.hop_limit; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_TRAFFIC_CLASS ) + req.traffic_class = qp->ah.traffic_class; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_DEST_MAC ) +memcpy (req.dest_mac, qp->ah.dmac,6 ); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_PATH_MTU ) + req.path_mtu =cpu_to_le16 (qp->path_mtu); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_TIMEOUT ) + req.timeout = qp->timeout; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_RETRY_CNT ) + req.retry_cnt = qp->retry_cnt; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_RNR_RETRY ) + req.rnr_retry = qp->rnr_retry; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_MIN_RNR_TIMER ) + req.min_rnr_timer = qp->min_rnr_timer; + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_RQ_PSN ) + req.rq_psn =cpu_to_le32 (qp->rq.psn); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_SQ_PSN ) + req.sq_psn =cpu_to_le32 (qp->sq.psn); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_MAX_RD_ATOMIC ) + req.max_rd_atomic = +ORD_LIMIT_TO_ORRQ_SLOTS (qp->max_rd_atomic); + +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_MAX_DEST_RD_ATOMIC ) + req.max_dest_rd_atomic = +IRD_LIMIT_TO_IRRQ_SLOTS (qp->max_dest_rd_atomic); + + req.sq_size =cpu_to_le32 (qp->sq.hwq.max_elements); + req.rq_size =cpu_to_le32 (qp->rq.hwq.max_elements); + req.sq_sge =cpu_to_le16 (qp->sq.max_sge); + req.rq_sge =cpu_to_le16 (qp->rq.max_sge); + req.max_inline_data =cpu_to_le32 (qp->max_inline_data); +if (bmask &CMDQ_MODIFY_QP_MODIFY_MASK_DEST_QP_ID ) + req.dest_qp_id =cpu_to_le32 (qp->dest_qpn); + + req.vlan_pcp_vlan_dei_vlan_id =cpu_to_le16 (qp->vlan_id); + + resp = (struct creq_modify_qp_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: MODIFY_QP send failed" ); +return -EINVAL ; + } +/**/ +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: FP: MODIFY_QP timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: MODIFY_QP failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } + qp->cur_qp_state = qp->state; +return 0 ; +} + +int bnxt_qplib_query_qp (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_query_qp req; +struct creq_query_qp_resp *resp; +struct creq_query_qp_resp_sb *sb; +u16 cmd_flags =0 ; +u32 temp32[4 ]; +int i; + +RCFW_CMD_PREP (req,QUERY_QP , cmd_flags); + + req.qp_cid =cpu_to_le32 (qp->id); + req.resp_size =sizeof (*sb) /BNXT_QPLIB_CMDQE_UNITS ; + resp = (struct creq_query_qp_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, + (void **)&sb,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: QUERY_QP send failed" ); +return -EINVAL ; + } +/**/ +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: FP: QUERY_QP timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: QUERY_QP failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } +/* Extract the context from the side buffer */ + qp->state = sb->en_sqd_async_notify_state & +CREQ_QUERY_QP_RESP_SB_STATE_MASK ; + qp->en_sqd_async_notify = sb->en_sqd_async_notify_state & +CREQ_QUERY_QP_RESP_SB_EN_SQD_ASYNC_NOTIFY ? + true : false; + qp->access = sb->access; + qp->pkey_index =le16_to_cpu (sb->pkey); + qp->qkey =le32_to_cpu (sb->qkey); + + temp32[0 ] =le32_to_cpu (sb->dgid[0 ]); + temp32[1 ] =le32_to_cpu (sb->dgid[1 ]); + temp32[2 ] =le32_to_cpu (sb->dgid[2 ]); + temp32[3 ] =le32_to_cpu (sb->dgid[3 ]); +memcpy (qp->ah.dgid.data, temp32,sizeof (qp->ah.dgid.data)); + + qp->ah.flow_label =le32_to_cpu (sb->flow_label); + + qp->ah.sgid_index =0 ; +for (i =0 ; i < res->sgid_tbl.max; i++) { +if (res->sgid_tbl.hw_id[i] ==le16_to_cpu (sb->sgid_index)) { + qp->ah.sgid_index = i; +break ; + } + } +if (i == res->sgid_tbl.max) +dev_warn (&res->pdev->dev,"QPLIB: SGID not found??" ); + + qp->ah.hop_limit = sb->hop_limit; + qp->ah.traffic_class = sb->traffic_class; +memcpy (qp->ah.dmac, sb->dest_mac,6 ); + qp->ah.vlan_id =le16_to_cpu ((sb->path_mtu_dest_vlan_id & +CREQ_QUERY_QP_RESP_SB_VLAN_ID_MASK ) >> +CREQ_QUERY_QP_RESP_SB_VLAN_ID_SFT ); + qp->path_mtu = sb->path_mtu_dest_vlan_id & +CREQ_QUERY_QP_RESP_SB_PATH_MTU_MASK ; + qp->timeout = sb->timeout; + qp->retry_cnt = sb->retry_cnt; + qp->rnr_retry = sb->rnr_retry; + qp->min_rnr_timer = sb->min_rnr_timer; + qp->rq.psn =le32_to_cpu (sb->rq_psn); + qp->max_rd_atomic =ORRQ_SLOTS_TO_ORD_LIMIT (sb->max_rd_atomic); + qp->sq.psn =le32_to_cpu (sb->sq_psn); + qp->max_dest_rd_atomic = +IRRQ_SLOTS_TO_IRD_LIMIT (sb->max_dest_rd_atomic); + qp->sq.max_wqe = qp->sq.hwq.max_elements; + qp->rq.max_wqe = qp->rq.hwq.max_elements; + qp->sq.max_sge =le16_to_cpu (sb->sq_sge); + qp->rq.max_sge =le32_to_cpu (sb->rq_sge); + qp->max_inline_data =le32_to_cpu (sb->max_inline_data); + qp->dest_qpn =le32_to_cpu (sb->dest_qp_id); +memcpy (qp->smac, sb->src_mac,6 ); + qp->vlan_id =le16_to_cpu (sb->vlan_pcp_vlan_dei_vlan_id); +return 0 ; +} + +static void __clean_cq (struct bnxt_qplib_cq *cq,u64 qp) +{ +struct bnxt_qplib_hwq *cq_hwq = &cq->hwq; +struct cq_base *hw_cqe, **hw_cqe_ptr; +int i; + +for (i =0 ; i < cq_hwq->max_elements; i++) { + hw_cqe_ptr = (struct cq_base **)cq_hwq->pbl_ptr; + hw_cqe = &hw_cqe_ptr[CQE_PG (i)][CQE_IDX (i)]; +if (!CQE_CMP_VALID (hw_cqe, i, cq_hwq->max_elements)) +continue ; +switch (hw_cqe->cqe_type_toggle &CQ_BASE_CQE_TYPE_MASK ) { +case CQ_BASE_CQE_TYPE_REQ : +case CQ_BASE_CQE_TYPE_TERMINAL : + { +struct cq_req *cqe = (struct cq_req *)hw_cqe; + +if (qp ==le64_to_cpu (cqe->qp_handle)) + cqe->qp_handle =0 ; +break ; + } +case CQ_BASE_CQE_TYPE_RES_RC : +case CQ_BASE_CQE_TYPE_RES_UD : +case CQ_BASE_CQE_TYPE_RES_RAWETH_QP1 : + { +struct cq_res_rc *cqe = (struct cq_res_rc *)hw_cqe; + +if (qp ==le64_to_cpu (cqe->qp_handle)) + cqe->qp_handle =0 ; +break ; + } +default : +break ; + } + } +} + +static unsigned long bnxt_qplib_lock_cqs (struct bnxt_qplib_qp *qp) +{ +unsigned long flags; + +spin_lock_irqsave (&qp->scq->hwq.lock, flags); +if (qp->rcq && qp->rcq != qp->scq) +spin_lock (&qp->rcq->hwq.lock); + +return flags; +} + +static void bnxt_qplib_unlock_cqs (struct bnxt_qplib_qp *qp, +unsigned long flags) +{ +if (qp->rcq && qp->rcq != qp->scq) +spin_unlock (&qp->rcq->hwq.lock); +spin_unlock_irqrestore (&qp->scq->hwq.lock, flags); +} + +int bnxt_qplib_destroy_qp (struct bnxt_qplib_res *res, +struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_rcfw *rcfw = res->rcfw; +struct cmdq_destroy_qp req; +struct creq_destroy_qp_resp *resp; +unsigned long flags; +u16 cmd_flags =0 ; + +RCFW_CMD_PREP (req,DESTROY_QP , cmd_flags); + + req.qp_cid =cpu_to_le32 (qp->id); + resp = (struct creq_destroy_qp_resp *) +bnxt_qplib_rcfw_send_message (rcfw, (void *)&req, +NULL ,0 ); +if (!resp) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: DESTROY_QP send failed" ); +return -EINVAL ; + } +/**/ +if (!bnxt_qplib_rcfw_wait_for_resp (rcfw,le16_to_cpu (req.cookie))) { +/* Cmd timed out */ +dev_err (&rcfw->pdev->dev,"QPLIB: FP: DESTROY_QP timed out" ); +return -ETIMEDOUT ; + } +if (RCFW_RESP_STATUS (resp) || +RCFW_RESP_COOKIE (resp) !=RCFW_CMDQ_COOKIE (req)) { +dev_err (&rcfw->pdev->dev,"QPLIB: FP: DESTROY_QP failed " ); +dev_err (&rcfw->pdev->dev, +"QPLIB: with status 0x%x cmdq 0x%x resp 0x%x" , +RCFW_RESP_STATUS (resp),RCFW_CMDQ_COOKIE (req), +RCFW_RESP_COOKIE (resp)); +return -EINVAL ; + } + +/* Must walk the associated CQs to nullified the QP ptr */ + flags =bnxt_qplib_lock_cqs (qp); +__clean_cq (qp->scq, (u64 )qp); +if (qp->rcq != qp->scq) +__clean_cq (qp->rcq, (u64 )qp); +bnxt_qplib_unlock_cqs (qp, flags); + +bnxt_qplib_free_qp_hdr_buf (res, qp); +bnxt_qplib_free_hwq (res->pdev, &qp->sq.hwq); +kfree (qp->sq.swq); + +bnxt_qplib_free_hwq (res->pdev, &qp->rq.hwq); +kfree (qp->rq.swq); + +if (qp->irrq.max_elements) +bnxt_qplib_free_hwq (res->pdev, &qp->irrq); +if (qp->orrq.max_elements) +bnxt_qplib_free_hwq (res->pdev, &qp->orrq); + +return 0 ; +} +/* CQ */ /* Spinlock must be held */
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h +250 -0
270 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re.h +14 -0
@@ -35,6 +35,14 @@ struct bnxt_re_work {struct net_device *vlan_dev; }; +struct bnxt_re_sqp_entries { +struct bnxt_qplib_sge sge; +u64 wrid; +/* For storing the actual qp1 cqe */ +struct bnxt_qplib_cqe cqe; +struct bnxt_re_qp *qp1_qp; +}; +#define BNXT_RE_MIN_MSIX 2#define BNXT_RE_MAX_MSIX 16#define BNXT_RE_AEQ_IDX 0
@@ -83,6 +91,12 @@ struct bnxt_re_dev {atomic_t mw_count;/* Max of 2 lossless traffic class supported per port */ u16 cosq[2 ]; + +/* QP for for handling QP1 packets */ +u32 sqp_id; +struct bnxt_re_qp *qp1_sqp; +struct bnxt_re_ah *sqp_ah; +struct bnxt_re_sqp_entries sqp_tbl[1024 ]; };#define to_bnxt_re (ptr, type, member) \
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +762 -0
774 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +21 -0
@@ -32,6 +32,19 @@ struct bnxt_re_ah {struct bnxt_qplib_ah qplib_ah; }; +struct bnxt_re_qp { +struct list_head list; +struct bnxt_re_dev *rdev; +struct ib_qp ib_qp; +spinlock_t sq_lock;/* protect sq */ +struct bnxt_qplib_qp qplib_qp; +struct ib_umem *sumem; +struct ib_umem *rumem; +/* QP1 */ +u32 send_psn; +struct ib_ud_header qp1_hdr; +}; +struct bnxt_re_cq {struct bnxt_re_dev *rdev;spinlock_t cq_lock;/* protect cq */
@@ -116,6 +129,14 @@ struct ib_ah *bnxt_re_create_ah(struct ib_pd *pd,int bnxt_re_modify_ah (struct ib_ah *ah,struct ib_ah_attr *ah_attr);int bnxt_re_query_ah (struct ib_ah *ah,struct ib_ah_attr *ah_attr);int bnxt_re_destroy_ah (struct ib_ah *ah); +struct ib_qp *bnxt_re_create_qp (struct ib_pd *pd, +struct ib_qp_init_attr *qp_init_attr, +struct ib_udata *udata); +int bnxt_re_modify_qp (struct ib_qp *qp,struct ib_qp_attr *qp_attr, +int qp_attr_mask,struct ib_udata *udata); +int bnxt_re_query_qp (struct ib_qp *qp,struct ib_qp_attr *qp_attr, +int qp_attr_mask,struct ib_qp_init_attr *qp_init_attr); +int bnxt_re_destroy_qp (struct ib_qp *qp); struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev, const struct ib_cq_init_attr *attr, struct ib_ucontext *context,
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +6 -0
@@ -439,6 +439,12 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->modify_ah = bnxt_re_modify_ah; ibdev->query_ah = bnxt_re_query_ah; ibdev->destroy_ah = bnxt_re_destroy_ah; + + ibdev->create_qp = bnxt_re_create_qp; + ibdev->modify_qp = bnxt_re_modify_qp; + ibdev->query_qp = bnxt_re_query_qp; + ibdev->destroy_qp = bnxt_re_destroy_qp; + ibdev->create_cq = bnxt_re_create_cq; ibdev->destroy_cq = bnxt_re_destroy_cq; ibdev->req_notify_cq = bnxt_re_req_notify_cq;
drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h +10 -0
@@ -40,6 +40,16 @@ struct bnxt_re_cq_resp {__u32 phase; } __packed; +struct bnxt_re_qp_req { +__u64 qpsva; +__u64 qprva; +__u64 qp_handle; +} __packed; + +struct bnxt_re_qp_resp { +__u32 qpid; +} __packed; +enum bnxt_re_shpg_offt {BNXT_RE_BEG_RESV_OFFT =0x00 ,BNXT_RE_AVID_OFFT =0x10 ,
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 21/28 bnxt_re: Support post_send verb
In reply to a message not in the archiveEnables the ib_post_send fastpath verb for posting Send work requests on QPs.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 267 ++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 8 + drivers/infiniband/hw/bnxtre/bnxt_re.h | 5 + drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 542 +++++++++++++++++++++++- drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 2 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 1 + 6 files changed, 822 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c +267 -0
@@ -1063,6 +1063,273 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res,return 0 ; } +void *bnxt_qplib_get_qp1_sq_buf (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_sge *sge) +{ +struct bnxt_qplib_q *sq = &qp->sq; +u32 sw_prod; + +memset (sge,0 ,sizeof (*sge)); + +if (qp->sq_hdr_buf) { + sw_prod =HWQ_CMP (sq->hwq.prod, &sq->hwq); + sge->addr = (dma_addr_t)(qp->sq_hdr_buf_map + + sw_prod * qp->sq_hdr_buf_size); + sge->lkey =0xFFFFFFFF ; + sge->size = qp->sq_hdr_buf_size; +return qp->sq_hdr_buf + sw_prod * sge->size; + } +return NULL ; +} + +void bnxt_qplib_post_send_db (struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_q *sq = &qp->sq; +struct dbr_dbr db_msg = {0 }; +u32 sw_prod; + + sw_prod =HWQ_CMP (sq->hwq.prod, &sq->hwq); + + db_msg.index =cpu_to_le32 ((sw_prod <<DBR_DBR_INDEX_SFT ) & +DBR_DBR_INDEX_MASK ); + db_msg.type_xid = +cpu_to_le32 (((qp->id <<DBR_DBR_XID_SFT ) &DBR_DBR_XID_MASK ) | +DBR_DBR_TYPE_SQ ); +/* Flush all the WQE writes to HW */ +wmb (); +__iowrite64_copy (qp->dpi->dbr, &db_msg,sizeof (db_msg) /sizeof (u64)); +} + +int bnxt_qplib_post_send (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_swqe *wqe) +{ +struct bnxt_qplib_q *sq = &qp->sq; +struct bnxt_qplib_swq *swq; +struct sq_send *hw_sq_send_hdr, **hw_sq_send_ptr; +struct sq_sge *hw_sge; +u32 sw_prod; +u8 wqe_size16; +int i, rc =0 , data_len =0 , pkt_num =0 ; +u32 temp32; + +if (qp->state !=CMDQ_MODIFY_QP_NEW_STATE_RTS ) { + rc = -EINVAL ; + goto done; + } +if (HWQ_CMP ((sq->hwq.prod +1 ), &sq->hwq) == +HWQ_CMP (sq->hwq.cons, &sq->hwq)) { + rc = -ENOMEM ; + goto done; + } + sw_prod =HWQ_CMP (sq->hwq.prod, &sq->hwq); + swq = &sq->swq[sw_prod]; + swq->wr_id = wqe->wr_id; + swq->type = wqe->type; + swq->flags = wqe->flags; +if (qp->sig_type) + swq->flags |=SQ_SEND_FLAGS_SIGNAL_COMP ; + swq->start_psn = sq->psn &BTH_PSN_MASK ; + + hw_sq_send_ptr = (struct sq_send **)sq->hwq.pbl_ptr; + hw_sq_send_hdr = &hw_sq_send_ptr[SQE_PG (sw_prod)][SQE_IDX (sw_prod)]; + +memset (hw_sq_send_hdr,0 ,BNXT_QPLIB_MAX_SQE_ENTRY_SIZE ); + +if (wqe->flags &BNXT_QPLIB_SWQE_FLAGS_INLINE ) { +/* Copy the inline data */ +if (wqe->inline_len >BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH ) { +dev_warn (&sq->hwq.pdev->dev, +"QPLIB: Inline data length > 96 detected" ); + data_len =BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH ; + }else { + data_len = wqe->inline_len; + } +memcpy (hw_sq_send_hdr->data, wqe->inline_data, data_len); + wqe_size16 = (data_len +15 ) >>4 ; + }else { +for (i =0 , hw_sge = (struct sq_sge *)hw_sq_send_hdr->data; + i < wqe->num_sge; i++, hw_sge++) { + hw_sge->va_or_pa =cpu_to_le64 (wqe->sg_list[i].addr); + hw_sge->l_key =cpu_to_le32 (wqe->sg_list[i].lkey); + hw_sge->size =cpu_to_le32 (wqe->sg_list[i].size); + data_len += hw_sge->size; + } +/* Each SGE entry = 1 WQE size16 */ + wqe_size16 = wqe->num_sge; + } + +/* Specifics */ +switch (wqe->type) { +case BNXT_QPLIB_SWQE_TYPE_SEND : +if (qp->type ==CMDQ_CREATE_QP1_TYPE_GSI ) { +/* Assemble info for Raw Ethertype QPs */ +struct sq_send_raweth_qp1 *sqe = + (struct sq_send_raweth_qp1 *)hw_sq_send_hdr; + + sqe->wqe_type = wqe->type; + sqe->flags = wqe->flags; + sqe->wqe_size = wqe_size16 + + ((offsetof(typeof(*sqe), data) + 15) >> 4); + sqe->cfa_action =cpu_to_le16 (wqe->rawqp1.cfa_action); + sqe->lflags =cpu_to_le16 (wqe->rawqp1.lflags); + sqe->length =cpu_to_le32 (data_len); + sqe->cfa_meta =cpu_to_le32 ((wqe->rawqp1.cfa_meta & +SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_MASK ) << +SQ_SEND_RAWETH_QP1_CFA_META_VLAN_VID_SFT ); + +break ; + } +/* else, just fall thru */ +case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM : +case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV : + { +struct sq_send *sqe = (struct sq_send *)hw_sq_send_hdr; + + sqe->wqe_type = wqe->type; + sqe->flags = wqe->flags; + sqe->wqe_size = wqe_size16 + + ((offsetof(typeof(*sqe), data) + 15) >> 4); + sqe->inv_key_or_imm_data =cpu_to_le32 ( + wqe->send.imm_data_or_inv_key); +if (qp->type ==CMDQ_CREATE_QP_TYPE_UD ) { + sqe->q_key =cpu_to_le32 (wqe->send.q_key); + sqe->dst_qp =cpu_to_le32 ( + wqe->send.dst_qp &SQ_SEND_DST_QP_MASK ); + sqe->length =cpu_to_le32 (data_len); + sqe->avid =cpu_to_le32 (wqe->send.avid & +SQ_SEND_AVID_MASK ); + sq->psn = (sq->psn +1 ) &BTH_PSN_MASK ; + }else { + sqe->length =cpu_to_le32 (data_len); + sqe->dst_qp =0 ; + sqe->avid =0 ; +if (qp->mtu) + pkt_num = (data_len + qp->mtu -1 ) / qp->mtu; +if (!pkt_num) + pkt_num =1 ; + sq->psn = (sq->psn + pkt_num) &BTH_PSN_MASK ; + } +break ; + } +case BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE : +case BNXT_QPLIB_SWQE_TYPE_RDMA_WRITE_WITH_IMM : +case BNXT_QPLIB_SWQE_TYPE_RDMA_READ : + { +struct sq_rdma *sqe = (struct sq_rdma *)hw_sq_send_hdr; + + sqe->wqe_type = wqe->type; + sqe->flags = wqe->flags; + sqe->wqe_size = wqe_size16 + + ((offsetof(typeof(*sqe), data) + 15) >> 4); + sqe->imm_data =cpu_to_le32 (wqe->rdma.imm_data_or_inv_key); + sqe->length =cpu_to_le32 ((u32 )data_len); + sqe->remote_va =cpu_to_le64 (wqe->rdma.remote_va); + sqe->remote_key =cpu_to_le32 (wqe->rdma.r_key); +if (qp->mtu) + pkt_num = (data_len + qp->mtu -1 ) / qp->mtu; +if (!pkt_num) + pkt_num =1 ; + sq->psn = (sq->psn + pkt_num) &BTH_PSN_MASK ; +break ; + } +case BNXT_QPLIB_SWQE_TYPE_ATOMIC_CMP_AND_SWP : +case BNXT_QPLIB_SWQE_TYPE_ATOMIC_FETCH_AND_ADD : + { +struct sq_atomic *sqe = (struct sq_atomic *)hw_sq_send_hdr; + + sqe->wqe_type = wqe->type; + sqe->flags = wqe->flags; + sqe->remote_key =cpu_to_le32 (wqe->atomic.r_key); + sqe->remote_va =cpu_to_le64 (wqe->atomic.remote_va); + sqe->swap_data =cpu_to_le64 (wqe->atomic.swap_data); + sqe->cmp_data =cpu_to_le64 (wqe->atomic.cmp_data); +if (qp->mtu) + pkt_num = (data_len + qp->mtu -1 ) / qp->mtu; +if (!pkt_num) + pkt_num =1 ; + sq->psn = (sq->psn + pkt_num) &BTH_PSN_MASK ; +break ; + } +case BNXT_QPLIB_SWQE_TYPE_LOCAL_INV : + { +struct sq_localinvalidate *sqe = + (struct sq_localinvalidate *)hw_sq_send_hdr; + + sqe->wqe_type = wqe->type; + sqe->flags = wqe->flags; + sqe->inv_l_key =cpu_to_le32 (wqe->local_inv.inv_l_key); + +break ; + } +case BNXT_QPLIB_SWQE_TYPE_FAST_REG_MR : + { +struct sq_fr_pmr *sqe = (struct sq_fr_pmr *)hw_sq_send_hdr; + + sqe->wqe_type = wqe->type; + sqe->flags = wqe->flags; + sqe->access_cntl = wqe->frmr.access_cntl | +SQ_FR_PMR_ACCESS_CNTL_LOCAL_WRITE ; + sqe->zero_based_page_size_log = + (wqe->frmr.pg_sz_log &SQ_FR_PMR_PAGE_SIZE_LOG_MASK ) << +SQ_FR_PMR_PAGE_SIZE_LOG_SFT | + (wqe->frmr.zero_based ?SQ_FR_PMR_ZERO_BASED :0 ); + sqe->l_key =cpu_to_le32 (wqe->frmr.l_key); + temp32 =cpu_to_le32 (wqe->frmr.length); +memcpy (sqe->length, &temp32,sizeof (wqe->frmr.length)); + sqe->numlevels_pbl_page_size_log = + ((wqe->frmr.pbl_pg_sz_log << +SQ_FR_PMR_PBL_PAGE_SIZE_LOG_SFT ) & +SQ_FR_PMR_PBL_PAGE_SIZE_LOG_MASK ) | + ((wqe->frmr.levels <<SQ_FR_PMR_NUMLEVELS_SFT ) & +SQ_FR_PMR_NUMLEVELS_MASK ); + +for (i =0 ; i < wqe->frmr.page_list_len; i++) + wqe->frmr.pbl_ptr[i] =cpu_to_le64 ( + wqe->frmr.page_list[i] | +PTU_PTE_VALID ); + sqe->pblptr =cpu_to_le64 (wqe->frmr.pbl_dma_ptr); + sqe->va =cpu_to_le64 (wqe->frmr.va); + +break ; + } +case BNXT_QPLIB_SWQE_TYPE_BIND_MW : + { +struct sq_bind *sqe = (struct sq_bind *)hw_sq_send_hdr; + + sqe->wqe_type = wqe->type; + sqe->flags = wqe->flags; + sqe->access_cntl = wqe->bind.access_cntl; + sqe->mw_type_zero_based = wqe->bind.mw_type | + (wqe->bind.zero_based ?SQ_BIND_ZERO_BASED :0 ); + sqe->parent_l_key =cpu_to_le32 (wqe->bind.parent_l_key); + sqe->l_key =cpu_to_le32 (wqe->bind.r_key); + sqe->va =cpu_to_le64 (wqe->bind.va); + temp32 =cpu_to_le32 (wqe->bind.length); +memcpy (&sqe->length, &temp32,sizeof (wqe->bind.length)); +break ; + } +default : +/* Bad wqe, return error */ + rc = -EINVAL ; + goto done; + } + swq->next_psn = sq->psn &BTH_PSN_MASK ; +if (swq->psn_search) { + swq->psn_search->opcode_start_psn =cpu_to_le32 ( + ((swq->start_psn <<SQ_PSN_SEARCH_START_PSN_SFT ) & +SQ_PSN_SEARCH_START_PSN_MASK ) | + ((wqe->type <<SQ_PSN_SEARCH_OPCODE_SFT ) & +SQ_PSN_SEARCH_OPCODE_MASK )); + swq->psn_search->flags_next_psn =cpu_to_le32 ( + ((swq->next_psn <<SQ_PSN_SEARCH_NEXT_PSN_SFT ) & +SQ_PSN_SEARCH_NEXT_PSN_MASK )); + } + + sq->hwq.prod++; +done: +return rc; +} +/* CQ */ /* Spinlock must be held */
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h +8 -0
@@ -13,6 +13,9 @@ #ifndef __BNXT_QPLIB_FP_H__ #define __BNXT_QPLIB_FP_H__ + +#define BNXT_QPLIB_ETHTYPE_ROCEV1 0x8915 + struct bnxt_qplib_sge { u64 addr; u32 lkey;
@@ -365,6 +368,11 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);int bnxt_qplib_modify_qp (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp);int bnxt_qplib_query_qp (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp);int bnxt_qplib_destroy_qp (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp); +void *bnxt_qplib_get_qp1_sq_buf (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_sge *sge); +void bnxt_qplib_post_send_db (struct bnxt_qplib_qp *qp); +int bnxt_qplib_post_send (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_swqe *wqe);int bnxt_qplib_create_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq);int bnxt_qplib_destroy_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq);
drivers/infiniband/hw/bnxtre/bnxt_re.h +5 -0
@@ -104,6 +104,11 @@ struct bnxt_re_dev {#define to_bnxt_re_dev (ptr, member) \ container_of((ptr), struct bnxt_re_dev, member) + +#define BNXT_RE_ROCE_V1_PACKET 0 +#define BNXT_RE_ROCEV2_IPV4_PACKET 2 +#define BNXT_RE_ROCEV2_IPV6_PACKET 3 +#define rdev_to_dev (rdev) ((rdev) ? (&(rdev)->ibdev.dev) : NULL)#endif
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +539 -3
566 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +2 -0
@@ -137,6 +137,8 @@ int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,int bnxt_re_query_qp (struct ib_qp *qp,struct ib_qp_attr *qp_attr,int qp_attr_mask,struct ib_qp_init_attr *qp_init_attr);int bnxt_re_destroy_qp (struct ib_qp *qp); +int bnxt_re_post_send (struct ib_qp *qp,struct ib_send_wr *send_wr, +struct ib_send_wr **bad_send_wr); struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev, const struct ib_cq_init_attr *attr, struct ib_ucontext *context,
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +1 -0
@@ -445,6 +445,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->query_qp = bnxt_re_query_qp; ibdev->destroy_qp = bnxt_re_destroy_qp; + ibdev->post_send = bnxt_re_post_send; ibdev->create_cq = bnxt_re_create_cq; ibdev->destroy_cq = bnxt_re_destroy_cq; ibdev->req_notify_cq = bnxt_re_req_notify_cq;
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 22/28 bnxt_re: Support post_recv
In reply to a message not in the archiveEnables the fastpath verb ib_post_recv.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 100 ++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 8 ++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 133 ++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 2 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 2 + 5 files changed, 245 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c +100 -0
@@ -1082,6 +1082,37 @@ void *bnxt_qplib_get_qp1_sq_buf(struct bnxt_qplib_qp *qp,return NULL ; } +u32 bnxt_qplib_get_rq_prod_index (struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_q *rq = &qp->rq; + +return HWQ_CMP (rq->hwq.prod, &rq->hwq); +} + +dma_addr_t bnxt_qplib_get_qp_buf_from_index (struct bnxt_qplib_qp *qp,u32 index) +{ +return (qp->rq_hdr_buf_map + index * qp->rq_hdr_buf_size); +} + +void *bnxt_qplib_get_qp1_rq_buf (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_sge *sge) +{ +struct bnxt_qplib_q *rq = &qp->rq; +u32 sw_prod; + +memset (sge,0 ,sizeof (*sge)); + +if (qp->rq_hdr_buf) { + sw_prod =HWQ_CMP (rq->hwq.prod, &rq->hwq); + sge->addr = (dma_addr_t)(qp->rq_hdr_buf_map + + sw_prod * qp->rq_hdr_buf_size); + sge->lkey =0xFFFFFFFF ; + sge->size = qp->rq_hdr_buf_size; +return qp->rq_hdr_buf + sw_prod * sge->size; + } +return NULL ; +} +void bnxt_qplib_post_send_db (struct bnxt_qplib_qp *qp) {struct bnxt_qplib_q *sq = &qp->sq;
@@ -1330,6 +1361,75 @@ int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,return rc; } +void bnxt_qplib_post_recv_db (struct bnxt_qplib_qp *qp) +{ +struct bnxt_qplib_q *rq = &qp->rq; +struct dbr_dbr db_msg = {0 }; +u32 sw_prod; + + sw_prod =HWQ_CMP (rq->hwq.prod, &rq->hwq); + db_msg.index =cpu_to_le32 ((sw_prod <<DBR_DBR_INDEX_SFT ) & +DBR_DBR_INDEX_MASK ); + db_msg.type_xid = +cpu_to_le32 (((qp->id <<DBR_DBR_XID_SFT ) &DBR_DBR_XID_MASK ) | +DBR_DBR_TYPE_RQ ); + +/* Flush the writes to HW Rx WQE before the ringing Rx DB */ +wmb (); +__iowrite64_copy (qp->dpi->dbr, &db_msg,sizeof (db_msg) /sizeof (u64)); +} + +int bnxt_qplib_post_recv (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_swqe *wqe) +{ +struct bnxt_qplib_q *rq = &qp->rq; +struct rq_wqe *rqe, **rqe_ptr; +struct sq_sge *hw_sge; +u32 sw_prod; +int i, rc =0 ; + +if (qp->state ==CMDQ_MODIFY_QP_NEW_STATE_ERR ) { +dev_err (&rq->hwq.pdev->dev, +"QPLIB: FP: QP (0x%x) is in the 0x%x state" , + qp->id, qp->state); + rc = -EINVAL ; + goto done; + } +if (HWQ_CMP ((rq->hwq.prod +1 ), &rq->hwq) == +HWQ_CMP (rq->hwq.cons, &rq->hwq)) { +dev_err (&rq->hwq.pdev->dev, +"QPLIB: FP: QP (0x%x) RQ is full!" , qp->id); + rc = -EINVAL ; + goto done; + } + sw_prod =HWQ_CMP (rq->hwq.prod, &rq->hwq); + rq->swq[sw_prod].wr_id = wqe->wr_id; + + rqe_ptr = (struct rq_wqe **)rq->hwq.pbl_ptr; + rqe = &rqe_ptr[RQE_PG (sw_prod)][RQE_IDX (sw_prod)]; + +memset (rqe,0 ,BNXT_QPLIB_MAX_RQE_ENTRY_SIZE ); + +/* Calculate wqe_size16 and data_len */ +for (i =0 , hw_sge = (struct sq_sge *)rqe->data; + i < wqe->num_sge; i++, hw_sge++) { + hw_sge->va_or_pa =cpu_to_le64 (wqe->sg_list[i].addr); + hw_sge->l_key =cpu_to_le32 (wqe->sg_list[i].lkey); + hw_sge->size =cpu_to_le32 (wqe->sg_list[i].size); + } + rqe->wqe_type = wqe->type; + rqe->flags = wqe->flags; + rqe->wqe_size = wqe->num_sge + + ((offsetof(typeof(*rqe), data) + 15) >> 4); + +/* Supply the rqe->wr_id index to the wr_id_tbl for now */ + rqe->wr_id[0 ] =cpu_to_le32 (sw_prod); + + rq->hwq.prod++; +done: +return rc; +} +/* CQ */ /* Spinlock must be held */
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h +8 -0
@@ -370,9 +370,17 @@ int bnxt_qplib_query_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp);int bnxt_qplib_destroy_qp (struct bnxt_qplib_res *res,struct bnxt_qplib_qp *qp);void *bnxt_qplib_get_qp1_sq_buf (struct bnxt_qplib_qp *qp,struct bnxt_qplib_sge *sge); +void *bnxt_qplib_get_qp1_rq_buf (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_sge *sge); +u32 bnxt_qplib_get_rq_prod_index (struct bnxt_qplib_qp *qp); +dma_addr_t bnxt_qplib_get_qp_buf_from_index (struct bnxt_qplib_qp *qp, +u32 index);void bnxt_qplib_post_send_db (struct bnxt_qplib_qp *qp);int bnxt_qplib_post_send (struct bnxt_qplib_qp *qp,struct bnxt_qplib_swqe *wqe); +void bnxt_qplib_post_recv_db (struct bnxt_qplib_qp *qp); +int bnxt_qplib_post_recv (struct bnxt_qplib_qp *qp, +struct bnxt_qplib_swqe *wqe);int bnxt_qplib_create_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq);int bnxt_qplib_destroy_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq);
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +133 -0
145 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +2 -0
@@ -139,6 +139,8 @@ int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,int bnxt_re_destroy_qp (struct ib_qp *qp);int bnxt_re_post_send (struct ib_qp *qp,struct ib_send_wr *send_wr,struct ib_send_wr **bad_send_wr); +int bnxt_re_post_recv (struct ib_qp *qp,struct ib_recv_wr *recv_wr, +struct ib_recv_wr **bad_recv_wr); struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev, const struct ib_cq_init_attr *attr, struct ib_ucontext *context,
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +2 -0
@@ -446,6 +446,8 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->destroy_qp = bnxt_re_destroy_qp; ibdev->post_send = bnxt_re_post_send; + ibdev->post_recv = bnxt_re_post_recv; + ibdev->create_cq = bnxt_re_create_cq; ibdev->destroy_cq = bnxt_re_destroy_cq; ibdev->req_notify_cq = bnxt_re_req_notify_cq;
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 23/28 bnxt_re: Support poll_cq verb
In reply to a message not in the archiveEnables the fastpath ib_poll_cq verb.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 553 +++++++++++++++++++++++- drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 7 +- drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 519 ++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 1 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 22 +- 5 files changed, 1097 insertions(+), 5 deletions(-)
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c +552 -1
@@ -185,7 +185,7 @@ void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq)int bnxt_qplib_enable_nq (struct pci_dev *pdev,struct bnxt_qplib_nq *nq,int msix_vector,int bar_reg_offset,int (*cqn_handler)(struct bnxt_qplib_nq *nq, -void *), +struct bnxt_qplib_cq *),int (*srqn_handler)(struct bnxt_qplib_nq *nq,void *,u8 event)) {
@@ -1583,6 +1583,557 @@ int bnxt_qplib_destroy_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)return 0 ; } +static int __flush_sq (struct bnxt_qplib_q *sq,struct bnxt_qplib_qp *qp, +struct bnxt_qplib_cqe **pcqe,int *budget) +{ +u32 sw_prod, sw_cons; +struct bnxt_qplib_cqe *cqe; +int rc =0 ; + +/* Now complete all outstanding SQEs with FLUSHED_ERR */ + sw_prod =HWQ_CMP (sq->hwq.prod, &sq->hwq); + cqe = *pcqe; +while (*budget) { + sw_cons =HWQ_CMP (sq->hwq.cons, &sq->hwq); +if (sw_cons == sw_prod) { + sq->flush_in_progress = false; +break ; + } +memset (cqe,0 ,sizeof (*cqe)); + cqe->status =CQ_REQ_STATUS_WORK_REQUEST_FLUSHED_ERR ; + cqe->opcode =CQ_BASE_CQE_TYPE_REQ ; + cqe->qp_handle = (u64 )qp; + cqe->wr_id = sq->swq[sw_cons].wr_id; + cqe->src_qp = qp->id; + cqe->type = sq->swq[sw_cons].type; + cqe++; + (*budget)--; + sq->hwq.cons++; + } + *pcqe = cqe; +if (!budget &&HWQ_CMP (sq->hwq.cons, &sq->hwq) != sw_prod) +/* Out of budget */ + rc = -EAGAIN ; + +return rc; +} + +static int __flush_rq (struct bnxt_qplib_q *rq,struct bnxt_qplib_qp *qp, +int opcode,struct bnxt_qplib_cqe **pcqe,int *budget) +{ +struct bnxt_qplib_cqe *cqe; +u32 sw_prod, sw_cons; +int rc =0 ; + +/* Flush the rest of the RQ */ + sw_prod =HWQ_CMP (rq->hwq.prod, &rq->hwq); + cqe = *pcqe; +while (*budget) { + sw_cons =HWQ_CMP (rq->hwq.cons, &rq->hwq); +if (sw_cons == sw_prod) +break ; +memset (cqe,0 ,sizeof (*cqe)); + cqe->status = +CQ_RES_RC_STATUS_WORK_REQUEST_FLUSHED_ERR ; + cqe->opcode = opcode; + cqe->qp_handle = (u64 )qp; + cqe->wr_id = rq->swq[sw_cons].wr_id; + cqe++; + (*budget)--; + rq->hwq.cons++; + } + *pcqe = cqe; +if (!*budget &&HWQ_CMP (rq->hwq.cons, &rq->hwq) != sw_prod) +/* Out of budget */ + rc = -EAGAIN ; + +return rc; +} + +static int bnxt_qplib_cq_process_req (struct bnxt_qplib_cq *cq, +struct cq_req *hwcqe, +struct bnxt_qplib_cqe **pcqe,int *budget) +{ +struct bnxt_qplib_qp *qp; +struct bnxt_qplib_q *sq; +struct bnxt_qplib_cqe *cqe; +u32 sw_cons, cqe_cons; +int rc =0 ; + + qp = (struct bnxt_qplib_qp *)le64_to_cpu (hwcqe->qp_handle); +if (!qp) { +dev_err (&cq->hwq.pdev->dev, +"QPLIB: FP: Process Req qp is NULL" ); +return -EINVAL ; + } + sq = &qp->sq; + + cqe_cons =HWQ_CMP (le16_to_cpu (hwcqe->sq_cons_idx), &sq->hwq); +if (cqe_cons > sq->hwq.max_elements) { +dev_err (&cq->hwq.pdev->dev, +"QPLIB: FP: CQ Process req reported " ); +dev_err (&cq->hwq.pdev->dev, +"QPLIB: sq_cons_idx 0x%x which exceeded max 0x%x" , + cqe_cons, sq->hwq.max_elements); +return -EINVAL ; + } +/* If we were in the middle of flushing the SQ, continue */ +if (sq->flush_in_progress) + goto flush; + +/* Require to walk the sq's swq to fabricate CQEs for all previously +* signaled SWQEs due to CQE aggregation from the current sq cons +* to the cqe_cons +*/ + cqe = *pcqe; +while (*budget) { + sw_cons =HWQ_CMP (sq->hwq.cons, &sq->hwq); +if (sw_cons == cqe_cons) +break ; +memset (cqe,0 ,sizeof (*cqe)); + cqe->opcode =CQ_BASE_CQE_TYPE_REQ ; + cqe->qp_handle = (u64 )qp; + cqe->src_qp = qp->id; + cqe->wr_id = sq->swq[sw_cons].wr_id; + cqe->type = sq->swq[sw_cons].type; + +/* For the last CQE, check for status. For errors, regardless +* of the request being signaled or not, it must complete with +* the hwcqe error status +*/ +if (HWQ_CMP ((sw_cons +1 ), &sq->hwq) == cqe_cons && + hwcqe->status !=CQ_REQ_STATUS_OK ) { + cqe->status = hwcqe->status; +dev_err (&cq->hwq.pdev->dev, +"QPLIB: FP: CQ Processed Req " ); +dev_err (&cq->hwq.pdev->dev, +"QPLIB: wr_id[%d] = 0x%llx with status 0x%x" , + sw_cons, cqe->wr_id, cqe->status); + cqe++; + (*budget)--; + sq->flush_in_progress = true; +/* Must block new posting of SQ and RQ */ + qp->state =CMDQ_MODIFY_QP_NEW_STATE_ERR ; + }else { +if (sq->swq[sw_cons].flags & +SQ_SEND_FLAGS_SIGNAL_COMP ) { + cqe->status =CQ_REQ_STATUS_OK ; + cqe++; + (*budget)--; + } + } + sq->hwq.cons++; + } + *pcqe = cqe; +if (!*budget &&HWQ_CMP (sq->hwq.cons, &sq->hwq) != cqe_cons) { +/* Out of budget */ + rc = -EAGAIN ; + goto done; + } +if (!sq->flush_in_progress) + goto done; +flush: +/* Require to walk the sq's swq to fabricate CQEs for all +* previously posted SWQEs due to the error CQE received +*/ + rc =__flush_sq (sq, qp, pcqe, budget); +if (!rc) + sq->flush_in_progress = false; +done: +return rc; +} + +static int bnxt_qplib_cq_process_res_rc (struct bnxt_qplib_cq *cq, +struct cq_res_rc *hwcqe, +struct bnxt_qplib_cqe **pcqe, +int *budget) +{ +struct bnxt_qplib_qp *qp; +struct bnxt_qplib_q *rq; +struct bnxt_qplib_cqe *cqe; +u64 wr_id_idx; +int rc =0 ; + + qp = (struct bnxt_qplib_qp *)le64_to_cpu (hwcqe->qp_handle); +if (!qp) { +dev_err (&cq->hwq.pdev->dev,"QPLIB: process_cq RC qp is NULL" ); +return -EINVAL ; + } + cqe = *pcqe; + cqe->opcode = hwcqe->cqe_type_toggle &CQ_BASE_CQE_TYPE_MASK ; + cqe->length =le32_to_cpu (hwcqe->length); + cqe->immdata_or_invrkey =le32_to_cpu (hwcqe->imm_data_or_inv_r_key); + cqe->mr_handle =le64_to_cpu (hwcqe->mr_handle); + cqe->flags =le16_to_cpu (hwcqe->flags); + cqe->status = hwcqe->status; + cqe->qp_handle = (u64 )qp; + + wr_id_idx =le64_to_cpu (hwcqe->srq_or_rq_wr_id & +CQ_RES_RC_SRQ_OR_RQ_WR_ID_MASK ); + rq = &qp->rq; +if (wr_id_idx > rq->hwq.max_elements) { +dev_err (&cq->hwq.pdev->dev,"QPLIB: FP: CQ Process RC " ); +dev_err (&cq->hwq.pdev->dev, +"QPLIB: wr_id idx 0x%llx exceeded RQ max 0x%x" , + wr_id_idx, rq->hwq.max_elements); +return -EINVAL ; + } +if (rq->flush_in_progress) + goto flush_rq; + + cqe->wr_id = rq->swq[wr_id_idx].wr_id; + cqe++; + (*budget)--; + rq->hwq.cons++; + *pcqe = cqe; + +if (hwcqe->status !=CQ_RES_RC_STATUS_OK ) { + rq->flush_in_progress = true; +flush_rq: + rc =__flush_rq (rq, qp,CQ_BASE_CQE_TYPE_RES_RC , pcqe, budget); +if (!rc) + rq->flush_in_progress = false; + } +return rc; +} + +static int bnxt_qplib_cq_process_res_ud (struct bnxt_qplib_cq *cq, +struct cq_res_ud *hwcqe, +struct bnxt_qplib_cqe **pcqe, +int *budget) +{ +struct bnxt_qplib_qp *qp; +struct bnxt_qplib_q *rq; +struct bnxt_qplib_cqe *cqe; +u64 wr_id_idx; +int rc =0 ; + + qp = (struct bnxt_qplib_qp *)le64_to_cpu (hwcqe->qp_handle); +if (!qp) { +dev_err (&cq->hwq.pdev->dev,"QPLIB: process_cq UD qp is NULL" ); +return -EINVAL ; + } + cqe = *pcqe; + cqe->opcode = hwcqe->cqe_type_toggle &CQ_BASE_CQE_TYPE_MASK ; + cqe->length =le32_to_cpu (hwcqe->length); + cqe->immdata_or_invrkey =le32_to_cpu (hwcqe->imm_data); + cqe->flags =le16_to_cpu (hwcqe->flags); + cqe->status = hwcqe->status; + cqe->qp_handle = (u64 )qp; +memcpy (cqe->smac, hwcqe->src_mac,6 ); + wr_id_idx =le64_to_cpu (hwcqe->src_qp_high_srq_or_rq_wr_id + &CQ_RES_UD_SRQ_OR_RQ_WR_ID_MASK ); + cqe->src_qp =le16_to_cpu (hwcqe->src_qp_low) | + (hwcqe->src_qp_high_srq_or_rq_wr_id & +CQ_RES_UD_SRC_QP_HIGH_MASK >>8 ); + + rq = &qp->rq; +if (wr_id_idx > rq->hwq.max_elements) { +dev_err (&cq->hwq.pdev->dev,"QPLIB: FP: CQ Process UD " ); +dev_err (&cq->hwq.pdev->dev, +"QPLIB: wr_id idx 0x%llx exceeded RQ max 0x%x" , + wr_id_idx, rq->hwq.max_elements); +return -EINVAL ; + } +if (rq->flush_in_progress) + goto flush_rq; + + cqe->wr_id = rq->swq[wr_id_idx].wr_id; + cqe++; + (*budget)--; + rq->hwq.cons++; + *pcqe = cqe; + +if (hwcqe->status !=CQ_RES_RC_STATUS_OK ) { + rq->flush_in_progress = true; +flush_rq: + rc =__flush_rq (rq, qp,CQ_BASE_CQE_TYPE_RES_UD , pcqe, budget); +if (!rc) + rq->flush_in_progress = false; + } +return rc; +} + +static int bnxt_qplib_cq_process_res_raweth_qp1 (struct bnxt_qplib_cq *cq, +struct cq_res_raweth_qp1 *hwcqe, +struct bnxt_qplib_cqe **pcqe, +int *budget) +{ +struct bnxt_qplib_qp *qp; +struct bnxt_qplib_q *rq; +struct bnxt_qplib_cqe *cqe; +u64 wr_id_idx; +int rc =0 ; + + qp = (struct bnxt_qplib_qp *)le64_to_cpu (hwcqe->qp_handle); +if (!qp) { +dev_err (&cq->hwq.pdev->dev, +"QPLIB: process_cq Raw/QP1 qp is NULL" ); +return -EINVAL ; + } + cqe = *pcqe; + cqe->opcode = hwcqe->cqe_type_toggle &CQ_BASE_CQE_TYPE_MASK ; + cqe->flags =le16_to_cpu (hwcqe->flags); + cqe->qp_handle = (u64 )qp; + + wr_id_idx =le64_to_cpu (hwcqe->raweth_qp1_payload_offset_srq_or_rq_wr_id + &CQ_RES_RAWETH_QP1_SRQ_OR_RQ_WR_ID_MASK ); + cqe->src_qp = qp->id; +if (qp->id ==1 && !cqe->length) { +/* Add workaround for the length misdetection */ + cqe->length =296 ; + }else { + cqe->length =le16_to_cpu (hwcqe->length); + } + cqe->pkey_index = qp->pkey_index; +memcpy (cqe->smac, qp->smac,6 ); + + cqe->raweth_qp1_flags =le16_to_cpu (hwcqe->raweth_qp1_flags); + cqe->raweth_qp1_flags2 =le16_to_cpu (hwcqe->raweth_qp1_flags2); + + rq = &qp->rq; +if (wr_id_idx > rq->hwq.max_elements) { +dev_err (&cq->hwq.pdev->dev,"QPLIB: FP: CQ Process Raw/QP1 RQ wr_id " ); +dev_err (&cq->hwq.pdev->dev,"QPLIB: ix 0x%llx exceeded RQ max 0x%x" , + wr_id_idx, rq->hwq.max_elements); +return -EINVAL ; + } +if (rq->flush_in_progress) + goto flush_rq; + + cqe->wr_id = rq->swq[wr_id_idx].wr_id; + cqe++; + (*budget)--; + rq->hwq.cons++; + *pcqe = cqe; + +if (hwcqe->status !=CQ_RES_RC_STATUS_OK ) { + rq->flush_in_progress = true; +flush_rq: + rc =__flush_rq (rq, qp,CQ_BASE_CQE_TYPE_RES_RAWETH_QP1 , pcqe, + budget); +if (!rc) + rq->flush_in_progress = false; + } +return rc; +} + +static int bnxt_qplib_cq_process_terminal (struct bnxt_qplib_cq *cq, +struct cq_terminal *hwcqe, +struct bnxt_qplib_cqe **pcqe, +int *budget) +{ +struct bnxt_qplib_qp *qp; +struct bnxt_qplib_q *sq, *rq; +struct bnxt_qplib_cqe *cqe; +u32 sw_cons, cqe_cons; +int rc =0 ; +u8 opcode =0 ; + +/* Check the Status */ +if (hwcqe->status !=CQ_TERMINAL_STATUS_OK ) +dev_warn (&cq->hwq.pdev->dev, +"QPLIB: FP: CQ Process Terminal Error status = 0x%x" , + hwcqe->status); + + qp = (struct bnxt_qplib_qp *)le64_to_cpu (hwcqe->qp_handle); +if (!qp) { +dev_err (&cq->hwq.pdev->dev, +"QPLIB: FP: CQ Process terminal qp is NULL" ); +return -EINVAL ; + } +/* Must block new posting of SQ and RQ */ + qp->state =CMDQ_MODIFY_QP_NEW_STATE_ERR ; + + sq = &qp->sq; + rq = &qp->rq; + + cqe_cons =le16_to_cpu (hwcqe->sq_cons_idx); +if (cqe_cons ==0xFFFF ) + goto do_rq; + +if (cqe_cons > sq->hwq.max_elements) { +dev_err (&cq->hwq.pdev->dev, +"QPLIB: FP: CQ Process terminal reported " ); +dev_err (&cq->hwq.pdev->dev, +"QPLIB: sq_cons_idx 0x%x which exceeded max 0x%x" , + cqe_cons, sq->hwq.max_elements); + goto do_rq; + } +/* If we were in the middle of flushing, continue */ +if (sq->flush_in_progress) + goto flush_sq; + +/* Terminal CQE can also include aggregated successful CQEs prior. +* So we must complete all CQEs from the current sq's cons to the +* cq_cons with status OK +*/ + cqe = *pcqe; +while (*budget) { + sw_cons =HWQ_CMP (sq->hwq.cons, &sq->hwq); +if (sw_cons == cqe_cons) +break ; +if (sq->swq[sw_cons].flags &SQ_SEND_FLAGS_SIGNAL_COMP ) { +memset (cqe,0 ,sizeof (*cqe)); + cqe->status =CQ_REQ_STATUS_OK ; + cqe->opcode =CQ_BASE_CQE_TYPE_REQ ; + cqe->qp_handle = (u64 )qp; + cqe->src_qp = qp->id; + cqe->wr_id = sq->swq[sw_cons].wr_id; + cqe->type = sq->swq[sw_cons].type; + cqe++; + (*budget)--; + } + sq->hwq.cons++; + } + *pcqe = cqe; +if (!budget && sw_cons != cqe_cons) { +/* Out of budget */ + rc = -EAGAIN ; + goto sq_done; + } + sq->flush_in_progress = true; +flush_sq: + rc =__flush_sq (sq, qp, pcqe, budget); +if (!rc) + sq->flush_in_progress = false; +sq_done: +if (rc) +return rc; +do_rq: + cqe_cons =le16_to_cpu (hwcqe->rq_cons_idx); +if (cqe_cons ==0xFFFF ) { + goto done; + }else if (cqe_cons > rq->hwq.max_elements) { +dev_err (&cq->hwq.pdev->dev, +"QPLIB: FP: CQ Processed terminal " ); +dev_err (&cq->hwq.pdev->dev, +"QPLIB: reported rq_cons_idx 0x%x exceeds max 0x%x" , + cqe_cons, rq->hwq.max_elements); + goto done; + } +/* Terminal CQE requires all posted RQEs to complete with FLUSHED_ERR +* from the current rq->cons to the rq->prod regardless what the +* rq->cons the terminal CQE indicates +*/ + rq->flush_in_progress = true; +switch (qp->type) { +case CMDQ_CREATE_QP1_TYPE_GSI : + opcode =CQ_BASE_CQE_TYPE_RES_RAWETH_QP1 ; +break ; +case CMDQ_CREATE_QP_TYPE_RC : + opcode =CQ_BASE_CQE_TYPE_RES_RC ; +break ; +case CMDQ_CREATE_QP_TYPE_UD : + opcode =CQ_BASE_CQE_TYPE_RES_UD ; +break ; + } + + rc =__flush_rq (rq, qp, opcode, pcqe, budget); +if (!rc) + rq->flush_in_progress = false; +done: +return rc; +} + +static int bnxt_qplib_cq_process_cutoff (struct bnxt_qplib_cq *cq, +struct cq_cutoff *hwcqe) +{ +/* Check the Status */ +if (hwcqe->status !=CQ_CUTOFF_STATUS_OK ) { +dev_err (&cq->hwq.pdev->dev, +"QPLIB: FP: CQ Process Cutoff Error status = 0x%x" , + hwcqe->status); +return -EINVAL ; + } +clear_bit (CQ_FLAGS_RESIZE_IN_PROG , &cq->flags); +wake_up_interruptible (&cq->waitq); + +return 0 ; +} + +int bnxt_qplib_poll_cq (struct bnxt_qplib_cq *cq,struct bnxt_qplib_cqe *cqe, +int num_cqes) +{ +struct cq_base *hw_cqe, **hw_cqe_ptr; +unsigned long flags; +u32 sw_cons, raw_cons; +int budget, rc =0 ; + +spin_lock_irqsave (&cq->hwq.lock, flags); + raw_cons = cq->hwq.cons; + budget = num_cqes; + +while (budget) { + sw_cons =HWQ_CMP (raw_cons, &cq->hwq); + hw_cqe_ptr = (struct cq_base **)cq->hwq.pbl_ptr; + hw_cqe = &hw_cqe_ptr[CQE_PG (sw_cons)][CQE_IDX (sw_cons)]; + +/* Check for Valid bit */ +if (!CQE_CMP_VALID (hw_cqe, raw_cons, cq->hwq.max_elements)) +break ; + +/* From the device's respective CQE format to qplib_wc*/ +switch (hw_cqe->cqe_type_toggle &CQ_BASE_CQE_TYPE_MASK ) { +case CQ_BASE_CQE_TYPE_REQ : + rc =bnxt_qplib_cq_process_req (cq, + (struct cq_req *)hw_cqe, + &cqe, &budget); +break ; +case CQ_BASE_CQE_TYPE_RES_RC : + rc =bnxt_qplib_cq_process_res_rc (cq, + (struct cq_res_rc *) + hw_cqe, &cqe, + &budget); +break ; +case CQ_BASE_CQE_TYPE_RES_UD : + rc =bnxt_qplib_cq_process_res_ud + (cq, (struct cq_res_ud *)hw_cqe, &cqe, + &budget); +break ; +case CQ_BASE_CQE_TYPE_RES_RAWETH_QP1 : + rc =bnxt_qplib_cq_process_res_raweth_qp1 + (cq, (struct cq_res_raweth_qp1 *) + hw_cqe, &cqe, &budget); +break ; +case CQ_BASE_CQE_TYPE_TERMINAL : + rc =bnxt_qplib_cq_process_terminal + (cq, (struct cq_terminal *)hw_cqe, + &cqe, &budget); +break ; +case CQ_BASE_CQE_TYPE_CUT_OFF : +bnxt_qplib_cq_process_cutoff + (cq, (struct cq_cutoff *)hw_cqe); +/* Done processing this CQ */ + goto exit; +default : +dev_err (&cq->hwq.pdev->dev, +"QPLIB: process_cq unknown type 0x%lx" , + hw_cqe->cqe_type_toggle & +CQ_BASE_CQE_TYPE_MASK ); + rc = -EINVAL ; +break ; + } +if (rc <0 ) { +if (rc == -EAGAIN ) +break ; +/* Error while processing the CQE, just skip to the +* next one +*/ +dev_err (&cq->hwq.pdev->dev, +"QPLIB: process_cqe error rc = 0x%x" , rc); + } + raw_cons++; + } +if (cq->hwq.cons != raw_cons) { + cq->hwq.cons = raw_cons; +bnxt_qplib_arm_cq (cq,DBR_DBR_TYPE_CQ ); + } +exit: +spin_unlock_irqrestore (&cq->hwq.lock, flags); +return num_cqes - budget; +} +void bnxt_qplib_req_notify_cq (struct bnxt_qplib_cq *cq,u32 arm_type) {unsigned long flags;
drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h +4 -3
@@ -348,7 +348,7 @@ struct bnxt_qplib_nq {int (*cqn_handler) (struct bnxt_qplib_nq *nq, -void *cq); +struct bnxt_qplib_cq *cq); int (*srqn_handler) (struct bnxt_qplib_nq *nq, void *srq,
@@ -359,7 +359,7 @@ void bnxt_qplib_disable_nq(struct bnxt_qplib_nq *nq);int bnxt_qplib_enable_nq (struct pci_dev *pdev,struct bnxt_qplib_nq *nq,int msix_vector,int bar_reg_offset,int (*cqn_handler)(struct bnxt_qplib_nq *nq, -void *cq), +struct bnxt_qplib_cq *cq),int (*srqn_handler)(struct bnxt_qplib_nq *nq,void *srq,u8 event));
@@ -383,7 +383,8 @@ int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp, struct bnxt_qplib_swqe *wqe);int bnxt_qplib_create_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq);int bnxt_qplib_destroy_cq (struct bnxt_qplib_res *res,struct bnxt_qplib_cq *cq); - +int bnxt_qplib_poll_cq (struct bnxt_qplib_cq *cq,struct bnxt_qplib_cqe *cqe, +int num);void bnxt_qplib_req_notify_cq (struct bnxt_qplib_cq *cq,u32 arm_type);void bnxt_qplib_free_nq (struct bnxt_qplib_nq *nq);int bnxt_qplib_alloc_nq (struct pci_dev *pdev,struct bnxt_qplib_nq *nq);
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c +519 -0
525 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h +1 -0
@@ -146,6 +146,7 @@ struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev,struct ib_ucontext *context, struct ib_udata *udata);int bnxt_re_destroy_cq (struct ib_cq *cq); +int bnxt_re_poll_cq (struct ib_cq *cq,int num_entries,struct ib_wc *wc);int bnxt_re_req_notify_cq (struct ib_cq *cq,enum ib_cq_notify_flags flags);struct ib_mr *bnxt_re_get_dma_mr (struct ib_pd *pd,int mr_access_flags);
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +21 -1
@@ -450,6 +450,7 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) ibdev->create_cq = bnxt_re_create_cq; ibdev->destroy_cq = bnxt_re_destroy_cq; + ibdev->poll_cq = bnxt_re_poll_cq; ibdev->req_notify_cq = bnxt_re_req_notify_cq; ibdev->get_dma_mr = bnxt_re_get_dma_mr;
@@ -599,6 +600,25 @@ static int bnxt_re_aeq_handler(struct bnxt_qplib_rcfw *rcfw,return 0 ; } +static int bnxt_re_cqn_handler (struct bnxt_qplib_nq *nq, +struct bnxt_qplib_cq *handle) +{ + struct bnxt_re_cq *cq = to_bnxt_re(handle, struct bnxt_re_cq, + qplib_cq); + +if (!cq) { +dev_err (NULL ,"%s: CQ is NULL, CQN not handled" , +ROCE_DRV_MODULE_NAME ); +return -EINVAL ; + } +if (cq->ib_cq.comp_handler) { +/* Lock comp_handler? */ + (*cq->ib_cq.comp_handler)(&cq->ib_cq, cq->ib_cq.cq_context); + } + +return 0 ; +} +static void bnxt_re_cleanup_res (struct bnxt_re_dev *rdev) {if (rdev->nq.hwq.max_elements)
@@ -620,7 +640,7 @@ static int bnxt_re_init_res(struct bnxt_re_dev *rdev) rc =bnxt_qplib_enable_nq (rdev->en_dev->pdev, &rdev->nq, rdev->msix_entries[BNXT_RE_NQ_IDX ].vector, rdev->msix_entries[BNXT_RE_NQ_IDX ].db_offset, -NULL , + &bnxt_re_cqn_handler,NULL );if (rc)
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 24/28 bnxt_re: Handling dispatching of events to IB stack and cleanup during unload
In reply to a message not in the archiveThis patch implements handling dispatch of appropriate event to the IB stack based on NETDEV events received.
Also implements cleanup of the resources during driver unload.
--- drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 77 +++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +77 -0
@@ -714,6 +714,60 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)return rc; } +static void bnxt_re_dispatch_event (struct ib_device *ibdev,struct ib_qp *qp, +u8 port_num,enum ib_event_type event) +{ +struct ib_event ib_event; + + ib_event.device = ibdev; +if (qp) + ib_event.element.qp = qp; +else + ib_event.element.port_num = port_num; + ib_event.event = event; +ib_dispatch_event (&ib_event); +} + +static bool bnxt_re_is_qp1_or_shadow_qp (struct bnxt_re_dev *rdev, +struct bnxt_re_qp *qp) +{ +return (qp->ib_qp.qp_type ==IB_QPT_GSI ) || (qp == rdev->qp1_sqp); +} + +static void bnxt_re_dev_stop (struct bnxt_re_dev *rdev,bool qp_wait) +{ +int mask =IB_QP_STATE , qp_count, count =1 ; +struct ib_qp_attr qp_attr; +struct bnxt_re_qp *qp; + + qp_attr.qp_state =IB_QPS_ERR ; +mutex_lock (&rdev->qp_lock); +list_for_each_entry (qp, &rdev->qp_list, list) { +/* Modify the state of all QPs except QP1/Shadow QP */ +if (qp && !bnxt_re_is_qp1_or_shadow_qp (rdev, qp)) { +if (qp->qplib_qp.state != +CMDQ_MODIFY_QP_NEW_STATE_RESET || + qp->qplib_qp.state != +CMDQ_MODIFY_QP_NEW_STATE_ERR ) { +bnxt_re_dispatch_event (&rdev->ibdev, &qp->ib_qp, +1 ,IB_EVENT_QP_FATAL ); +bnxt_re_modify_qp (&qp->ib_qp, &qp_attr, mask, +NULL ); + } + } + } + +mutex_unlock (&rdev->qp_lock); +if (qp_wait) { +/* Give the application some time to clean up */ +do { + qp_count =atomic_read (&rdev->qp_count); +msleep (100 ); + }while ((qp_count !=atomic_read (&rdev->qp_count)) && + count--); + } +} +static void bnxt_re_ib_unreg (struct bnxt_re_dev *rdev,bool lock_wait) {int i, rc;
@@ -872,6 +926,8 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev) } }set_bit (BNXT_RE_FLAG_IBDEV_REGISTERED , &rdev->flags); +bnxt_re_dispatch_event (&rdev->ibdev,NULL ,1 ,IB_EVENT_PORT_ACTIVE ); +bnxt_re_dispatch_event (&rdev->ibdev,NULL ,1 ,IB_EVENT_GID_CHANGE );return 0 ; free_sctx:
@@ -950,10 +1006,18 @@ static void bnxt_re_task(struct work_struct *work) "Failed to register with IB: %#x", rc);break ;case NETDEV_UP : +bnxt_re_dispatch_event (&rdev->ibdev,NULL ,1 , +IB_EVENT_PORT_ACTIVE );break ;case NETDEV_DOWN : +bnxt_re_dev_stop (rdev, false);break ;case NETDEV_CHANGE : +if (!netif_carrier_ok (rdev->netdev)) +bnxt_re_dev_stop (rdev, false); +else if (netif_carrier_ok (rdev->netdev)) +bnxt_re_dispatch_event (&rdev->ibdev,NULL ,1 , +IB_EVENT_PORT_ACTIVE );break ;default :break ;
@@ -1071,6 +1135,7 @@ static int __init bnxt_re_mod_init(void) } static void __exit bnxt_re_mod_exit(void) { +struct bnxt_re_dev *rdev, *next;LIST_HEAD (to_be_deleted);/* Free all adapter allocated resources */
@@ -1079,6 +1144,18 @@ static void __exit bnxt_re_mod_exit(void)list_splice_init_rcu (&bnxt_re_dev_list, &to_be_deleted, synchronize_rcu);mutex_unlock (&bnxt_re_dev_lock); + +/* Can use the new list without protection */ +/* Cleanup the devices in reverse order so that the VF device +* cleanup is done before PF cleanup +*/ +list_for_each_entry_safe_reverse (rdev, next, &to_be_deleted, list) { +bnxt_re_dev_stop (rdev, true); +bnxt_re_ib_unreg (rdev, true); +bnxt_re_remove_one (rdev); +bnxt_re_dev_unreg (rdev); + } +unregister_netdevice_notifier (&bnxt_re_netdev_notifier);if (bnxt_re_wq)destroy_workqueue (bnxt_re_wq);
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 25/28 bnxt_re: Support for DCB
In reply to a message not in the archiveThis patch queries the configured RoCE APP Priority on the host using the dcbnl API and programs the RoCE FW with the corresponding Traffic Class(es) for the priority.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 3 +- drivers/infiniband/hw/bnxtre/bnxt_re.h | 6 ++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 134 +++++++++++++++++++++++++++ 3 files changed, 142 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h +2 -1
@@ -130,4 +130,5 @@ int bnxt_qplib_alloc_fast_reg_page_list(struct bnxt_qplib_res *res, struct bnxt_qplib_frpl *frpl, int max);int bnxt_qplib_free_fast_reg_page_list (struct bnxt_qplib_res *res,struct bnxt_qplib_frpl *frpl); -#endif /* __BNXT_QPLIB_SP_H__*/ +int bnxt_qplib_map_tc2cos (struct bnxt_qplib_res *res,u16 *cids); +#endif
drivers/infiniband/hw/bnxtre/bnxt_re.h +6 -0
@@ -16,6 +16,9 @@#define BNXT_RE_REF_WAIT_COUNT 10#define BNXT_RE_DESC "Broadcom NetXtreme-C/E RoCE Driver" +#define BNXT_RE_ROCE_V1_ETH_TYPE 0x8915 +#define BNXT_RE_ROCE_V2_PORT_NO 4791 +#define BNXT_RE_PAGE_SIZE_4K BIT(12)#define BNXT_RE_PAGE_SIZE_8K BIT(13)#define BNXT_RE_PAGE_SIZE_64K BIT(16)
@@ -66,6 +69,9 @@ struct bnxt_re_dev {int id; +struct delayed_work worker; +u8 cur_prio_map; +/* FP Notification Queue (CQ & SRQ) */ struct tasklet_struct nq_task;
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +134 -0
164 lines not on this page · raw message
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 26/28 bnxt_re: Support debugfs
In reply to a message not in the archiveThis patch exports some of the FW debug counters
--- drivers/infiniband/hw/bnxtre/Makefile | 2 +- drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c | 136 +++++++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h | 25 +++++ drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 4 + 4 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h
drivers/infiniband/hw/bnxtre/Makefile +1 -1
@@ -1,6 +1,6 @@ ccflags-y := -Idrivers/net/ethernet/broadcom/bnxt obj-$(CONFIG_INFINIBAND_BNXTRE) += bnxt_re.o -bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o \ +bnxt_re-y := bnxt_re_main.o bnxt_re_ib_verbs.o bnxt_re_debugfs.o \ bnxt_qplib_res.o bnxt_qplib_rcfw.o \ bnxt_qplib_sp.o bnxt_qplib_fp.o
drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c new file +136 -0
136 lines not on this page · raw message
drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h new file +25 -0
@@ -0,0 +1,25 @@ + +/* Broadcom NetXtreme-C/E network driver. +* +* Copyright (c) 2014-2016 Broadcom Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation. +* +*/ + +/* +* Description: DebugFS header +*/ + +#ifndef __BNXT_RE_DEBUGFS__ +#define __BNXT_RE_DEBUGFS__ + +extern struct list_head bnxt_re_dev_list; +extern struct mutex bnxt_re_dev_lock; + +void bnxt_re_debugfs_init (void ); +void bnxt_re_debugfs_remove (void ); + +#endif
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +4 -0
@@ -34,6 +34,7 @@#include "bnxt_qplib_fp.h" #include "bnxt_qplib_rcfw.h" #include "bnxt_re.h" +#include "bnxt_re_debugfs.h" #include "bnxt_re_ib_verbs.h" #include "bnxt.h" static char version[] =
@@ -1252,6 +1253,7 @@ static int __init bnxt_re_mod_init(void)if (!bnxt_re_wq)return -ENOMEM ; +bnxt_re_debugfs_init ();INIT_LIST_HEAD (&bnxt_re_dev_list); rc =register_netdevice_notifier (&bnxt_re_netdev_notifier);
@@ -1263,6 +1265,7 @@ static int __init bnxt_re_mod_init(void)return 0 ; err_netdev: +bnxt_re_debugfs_remove ();destroy_workqueue (bnxt_re_wq);return rc;
@@ -1291,6 +1294,7 @@ static void __exit bnxt_re_mod_exit(void) }unregister_netdevice_notifier (&bnxt_re_netdev_notifier); +bnxt_re_debugfs_remove ();if (bnxt_re_wq)destroy_workqueue (bnxt_re_wq); }
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 27/28 bnxt_re: Set uverbs command mask
In reply to a message not in the archiveThis patch exports available uverbs command mask to the IB stack. Also, populating some of the missing parameters in the ibdev structure used for registration.
--- drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +36 -0
@@ -36,6 +36,7 @@#include "bnxt_re.h" #include "bnxt_re_debugfs.h" #include "bnxt_re_ib_verbs.h" +#include "bnxt_re_uverbs_abi.h" #include "bnxt.h" static char version[] =BNXT_RE_DESC " v" ROCE_DRV_MODULE_VERSION "\n" ;
@@ -418,8 +419,42 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) strlen(BNXT_RE_DESC) + 5); ibdev->phys_port_cnt =1 ; +bnxt_qplib_get_guid (rdev->netdev->dev_addr, (u8 *)&ibdev->node_guid); + ibdev->num_comp_vectors =1 ; ibdev->dma_device = &rdev->en_dev->pdev->dev; + ibdev->local_dma_lkey =BNXT_QPLIB_RSVD_LKEY ; + +/* User space */ + ibdev->uverbs_abi_ver =BNXT_RE_ABI_VERSION ; + ibdev->uverbs_cmd_mask = + (1ull <<IB_USER_VERBS_CMD_GET_CONTEXT ) | + (1ull <<IB_USER_VERBS_CMD_QUERY_DEVICE ) | + (1ull <<IB_USER_VERBS_CMD_QUERY_PORT ) | + (1ull <<IB_USER_VERBS_CMD_ALLOC_PD ) | + (1ull <<IB_USER_VERBS_CMD_DEALLOC_PD ) | + (1ull <<IB_USER_VERBS_CMD_REG_MR ) | + (1ull <<IB_USER_VERBS_CMD_REREG_MR ) | + (1ull <<IB_USER_VERBS_CMD_DEREG_MR ) | + (1ull <<IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL ) | + (1ull <<IB_USER_VERBS_CMD_CREATE_CQ ) | + (1ull <<IB_USER_VERBS_CMD_RESIZE_CQ ) | + (1ull <<IB_USER_VERBS_CMD_DESTROY_CQ ) | + (1ull <<IB_USER_VERBS_CMD_CREATE_QP ) | + (1ull <<IB_USER_VERBS_CMD_MODIFY_QP ) | + (1ull <<IB_USER_VERBS_CMD_QUERY_QP ) | + (1ull <<IB_USER_VERBS_CMD_DESTROY_QP ) | + (1ull <<IB_USER_VERBS_CMD_CREATE_SRQ ) | + (1ull <<IB_USER_VERBS_CMD_MODIFY_SRQ ) | + (1ull <<IB_USER_VERBS_CMD_QUERY_SRQ ) | + (1ull <<IB_USER_VERBS_CMD_DESTROY_SRQ ) | + (1ull <<IB_USER_VERBS_CMD_CREATE_AH ) | + (1ull <<IB_USER_VERBS_CMD_MODIFY_AH ) | + (1ull <<IB_USER_VERBS_CMD_QUERY_AH ) | + (1ull <<IB_USER_VERBS_CMD_DESTROY_AH ); +/* POLL_CQ and REQ_NOTIFY_CQ is directly handled in libbnxt_re */ + +/* Kernel verbs */ ibdev->query_device = bnxt_re_query_device; ibdev->modify_device = bnxt_re_modify_device;
@@ -1046,6 +1081,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)pr_err ("Failed to register with IB: %#x\n" , rc); goto fail; } +dev_info (rdev_to_dev (rdev),"Device registered successfully" );for (i =0 ; i <ARRAY_SIZE (bnxt_re_attributes); i++) { rc =device_create_file (&rdev->ibdev.dev, bnxt_re_attributes[i]);
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 28/28 bnxt_re: Add QP event handling
In reply to a message not in the archiveImplements callback handler for processing affiliated Async events of a QP. This patch also implements the control path command completion handling.
--- drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c +49 -0
@@ -221,6 +221,46 @@ static int bnxt_qplib_process_func_event(struct bnxt_qplib_rcfw *rcfw,return 0 ; } +static int bnxt_qplib_process_qp_event (struct bnxt_qplib_rcfw *rcfw, +struct creq_qp_event *qp_event) +{ +struct bnxt_qplib_crsq *crsq = &rcfw->crsq; +struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq; +struct bnxt_qplib_crsqe *crsqe; +u16 cbit, cookie, blocked =0 ; +unsigned long flags; +u32 sw_cons; + +switch (qp_event->event) { +case CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION : +break ; +default : + { +/* Command Response */ +spin_lock_irqsave (&cmdq->lock, flags); + sw_cons =HWQ_CMP (crsq->cons, crsq); + crsqe = &crsq->crsq[sw_cons]; + crsq->cons++; +memcpy (&crsqe->qp_event, qp_event,sizeof (crsqe->qp_event)); + + cookie =le16_to_cpu (crsqe->qp_event.cookie); + blocked = cookie &RCFW_CMD_IS_BLOCKING ; + cookie &=RCFW_MAX_COOKIE_VALUE ; + cbit = cookie %RCFW_MAX_OUTSTANDING_CMD ; +if (!test_and_clear_bit (cbit, rcfw->cmdq_bitmap)) +dev_warn (&rcfw->pdev->dev, +"QPLIB: CMD bit %d was not requested" , cbit); + + cmdq->cons += crsqe->req_size; +spin_unlock_irqrestore (&cmdq->lock, flags); +if (!blocked) +wake_up (&rcfw->waitq); +break ; + } + } +return 0 ; +} +/* SP - CREQ Completion handlers */ static void bnxt_qplib_service_creq (unsigned long data) {
@@ -244,6 +284,15 @@ static void bnxt_qplib_service_creq(unsigned long data) type = creqe->type &CREQ_BASE_TYPE_MASK ;switch (type) {case CREQ_BASE_TYPE_QP_EVENT : +if (!bnxt_qplib_process_qp_event + (rcfw, (struct creq_qp_event *)creqe)) + rcfw->creq_qp_event_processed++; +else { +dev_warn (&rcfw->pdev->dev,"QPLIB: crsqe with" ); +dev_warn (&rcfw->pdev->dev, +"QPLIB: type = 0x%x not handled" , + type); + }break ;case CREQ_BASE_TYPE_FUNC_EVENT : if (!bnxt_qplib_process_func_event
Signature · 6 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Selvin Xavier
Hi Doug,
This series introduces the RoCE driver for the Broadcom NetXtreme-C/E 10/25/40/50 gigabit RoCE HCAs. This driver is dependent on the
bnxt_enNIC driver.This patch series is based on the "
bnxt_re" branch on Doug's repository + four pendingbnxt_enNIC driver patches that are yet to be pulled into net-next tree.
Please be clear about what you are expecting done with those four patches. If Dave is currently reviewing them, then I need to know if/when he takes them so I can rebase the bnxt_en branch on his net-next and pick them up that way.
Quoted 86 lines
Please review and consider applying this to linux-rdma repository.
Thanks,
Selvin XavierMichael Chan (7):
bnxt_en: Addbnxt_set_max_func_irqs().
bnxt_en: Enable MSIX early inbnxt_init_one().
bnxt_en: Move function reset tobnxt_init_one().
bnxt_en: Improve completion ring allocation for VFs.
bnxt_en: Reserve RDMA resources by default.
bnxt_en: Refactor the driver registration function with firmware.
bnxt_en: Add interface to support RDMA driver.Selvin Xavier (21):
bnxt_re: Addbnxt_reRoCE driver files
bnxt_re: Introducing autogenerated Host Software Interface(hsi) file
bnxt_re: register with the NIC driver
bnxt_re: Enabling RoCE control path
bnxt_re: Adding Notification Queue support
bnxt_re: Support for PD, ucontext and mmap verbs
bnxt_re: Support for query and modify device verbs
bnxt_re: Adding support for port related verbs
bnxt_re: Support for GID related verbs
bnxt_re: Support for CQ verbs
bnxt_re: Support for AH verbs
bnxt_re: Support memory registration verbs
bnxt_re: Support QP verbs
bnxt_re: Supportpost_sendverb
bnxt_re: Supportpost_recv
bnxt_re: Supportpoll_cqverb
bnxt_re: Handling dispatching of events to IB stack and cleanup during
unload
bnxt_re: Support for DCB
bnxt_re: Support debugfs
bnxt_re: Set uverbs command mask
bnxt_re: Add QP event handlingdrivers/infiniband/Kconfig | 2 + drivers/infiniband/hw/Makefile | 1 + drivers/infiniband/hw/bnxtre/Kconfig | 9 + drivers/infiniband/hw/bnxtre/Makefile | 6 + drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c | 2146 +++++++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h | 391 ++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c | 660 +++ drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h | 193 + drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c | 802 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h | 197 + drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c | 811 ++++ drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h | 134 + drivers/infiniband/hw/bnxtre/bnxt_re.h | 120 + drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c | 136 + drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h | 25 + drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h | 5201 +++++++++++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c | 3190 +++++++++++++ drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h | 171 + drivers/infiniband/hw/bnxtre/bnxt_re_main.c | 1339 ++++++ drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 60 + drivers/net/ethernet/broadcom/bnxt/Makefile | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 355 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 22 +- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 14 +- drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 288 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 91 + 26 files changed, 16251 insertions(+), 115 deletions(-) create mode 100644 drivers/infiniband/hw/bnxtre/Kconfig create mode 100644 drivers/infiniband/hw/bnxtre/Makefile create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_fp.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_rcfw.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_res.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_res.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_qplib_sp.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_debugfs.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_hsi.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_ib_verbs.h create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_main.c create mode 100644 drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD
A message that is not in the archive (sent off-list or not yet received): ee2b9e6f-de43-ab80-d2a7-d431e33c45ba-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Quoted 4 lines · Doug Ledford
Please be clear about what you are expecting done with those four patches. If Dave is currently reviewing them, then I need to know if/when he takes them so I can rebase the
bnxt_enbranch on his net-next and pick them up that way.
These patches are pulled to net-next already. Now, since David insisted on splitting this patch series to two,
Michael will push the bnxt_en patch series to net-next. I will push the bnxt_re v2 patch set on top of these changes.
You can rebase bnxt_re branch before applying v2 changes. Let me know if you think otherwise.
Thanks,
Selvin
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Selvin Xavier
drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 60 +
This file probably needs to be in include/uapi/rdma like the others
Do you have a git tree someplace for this?
Do you have the user space component ready for rdma-core as well?
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20161205165144.GB24852-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Hi Jason,
Quoted 5 lines · Jason Gunthorpe
Quoted 1 line · Selvin Xavier
drivers/infiniband/hw/bnxtre/bnxt_re_uverbs_abi.h | 60 +This file probably needs to be in
include/uapi/rdmalike the others
Sure.. i will this include as a part of V2.
Quoted 2 lines
Do you have a git tree someplace for this?
I assume you are referring to our uverbs library. We have the component ready but is not uploaded to external git yet. We will publish it soon and let you know the pointers.
Quoted 2 lines
Do you have the user space component ready for rdma-core as well?
This is not ready yet. Currently working on it.
Quoted 1 line
Jason
Thanks,
Selvin Xavier
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CA+sbYW1sUrv8CBHScMjU7ozBm709-tiVWaynDQK_Dq3AqAfggA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 3 lines · Selvin Xavier
Quoted 1 line
Do you have a git tree someplace for this?
I assume you are referring to our uverbs library.
No, I mean this series for linux. It is very hard to read these patches when they touch the same file again and again and have dependencies on net trees and things. I encourage people to include a git tree for such large works..
Quoted 3 lines
Quoted 2 lines
Do you have the user space component ready for rdma-core as well?
This is not ready yet. Currently working on it.
I'm also encouraging people to have their user space ready so the kernel driver can be properly reviewed.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20161206163456.GB28066-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Quoted 9 lines · Jason Gunthorpe
Quoted 3 lines · Selvin Xavier
Quoted 1 line
Do you have a git tree someplace for this?
I assume you are referring to our uverbs library.
No, I mean this series for linux. It is very hard to read these patches when they touch the same file again and again and have dependencies on net trees and things. I encourage people to include a git tree for such large works..
I will send out our repository info along with the v2 patch set.
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Do you have the user space component ready for rdma-core as well?
This is not ready yet. Currently working on it.
I'm also encouraging people to have their user space ready so the kernel driver can be properly reviewed.
The user space library is also ready. We would be posting it out soon.
Quoted 2 lines
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Selvin Xavier
Hi Doug,
This series introduces the RoCE driver for the Broadcom NetXtreme-C/E 10/25/40/50 gigabit RoCE HCAs. This driver is dependent on the
bnxt_enNIC driver.
Quoted 8 lines
This patch series is based on the "
bnxt_re" branch on Doug's repository + four pendingbnxt_enNIC driver patches that are yet to be pulled into net-next tree.Please review and consider applying this to linux-rdma repository.
Thanks,
Selvin Xavier
Compiling this series seems to have problems...
The fix appears to be:
===
$ git diff
(quoted diff) +0 -0
w/drivers/infiniband/hw/bnxtre/bnxt_re_main.c
index 9f3960037931..1bd67887a23c 100644
drivers/infiniband/hw/bnxtre/bnxt_re_main.c +1 -0
@@ -19,6 +19,7 @@#include <linux/rculist.h> #include <linux/spinlock.h> #include <linux/pci.h> +#include <net/dcbnl.h> #include <net/ipv6.h> #include <net/addrconf.h> ===
jtoppins@jtoppins:~/projects/linux-rhel7$ git log -1 --oneline net-next/master 25e3e84b183a dummy: expend mtu range for dummy device jtoppins@jtoppins:~/projects/linux-rhel7$ git merge-base net-next/master HEAD 25e3e84b183a2c25b1e8303f815a6aa5bf78358a
jtoppins@jtoppins:~/projects/linux-rhel7$ make defconfig *** Default configuration is based on 'x86_64_defconfig' # # configuration written to .config # jtoppins@jtoppins:~/projects/linux-rhel7$ make menuconfig HOSTCC scripts/kconfig/mconf.o HOSTCC scripts/kconfig/lxdialog/checklist.o HOSTCC scripts/kconfig/lxdialog/util.o HOSTCC scripts/kconfig/lxdialog/inputbox.o HOSTCC scripts/kconfig/lxdialog/textbox.o HOSTCC scripts/kconfig/lxdialog/yesno.o HOSTCC scripts/kconfig/lxdialog/menubox.o HOSTLD scripts/kconfig/mconf scripts/kconfig/mconf Kconfig configuration written to .config
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
jtoppins@jtoppins:~/projects/linux-rhel7$ grep "BNXTRE" .config
CONFIG_INFINIBAND_BNXTRE=m
jtoppins@jtoppins:~/projects/linux-rhel7$ make
drivers/infiniband/hw/bnxtre/bnxt_re.ko
SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_32.h
SYSHDR
arch/x86/entry/syscalls/../../include/generated/asm/unistd_32_ia32.h
SYSHDR
arch/x86/entry/syscalls/../../include/generated/asm/unistd_64_x32.h
SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_64.h
SYSHDR
arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_32.h
SYSHDR
arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_64.h
SYSHDR
arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_x32.h
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
HOSTLD arch/x86/tools/relocs
CHK include/config/kernel.release
UPD include/config/kernel.release
WRAP arch/x86/include/generated/asm/clkdev.h
WRAP arch/x86/include/generated/asm/cputime.h
WRAP arch/x86/include/generated/asm/dma-contiguous.h
WRAP arch/x86/include/generated/asm/early_ioremap.h
WRAP arch/x86/include/generated/asm/mcs_spinlock.h
WRAP arch/x86/include/generated/asm/mm-arch-hooks.h
CHK include/generated/uapi/linux/version.h
UPD include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
CC kernel/bounds.s
CHK include/generated/bounds.h
UPD include/generated/bounds.h
CHK include/generated/timeconst.h
UPD include/generated/timeconst.h
CC arch/x86/kernel/asm-offsets.s
CHK include/generated/asm-offsets.h
UPD include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/modpost.o
CC scripts/mod/devicetable-offsets.s
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/mod/sumversion.o
HOSTLD scripts/mod/modpost
HOSTCC scripts/selinux/genheaders/genheaders
HOSTCC scripts/selinux/mdp/mdp
HOSTCC scripts/kallsyms
HOSTCC scripts/pnmtologo
HOSTCC scripts/conmakehash
HOSTCC scripts/sortextable
CC [M] drivers/infiniband/hw/bnxtre/bnxt_re_main.o
drivers/infiniband/hw/bnxtre/bnxt_re_main.c: In function
‘bnxt_re_get_priority_mask’:
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:850:17: error: storage size
of ‘app’ isn’t known
struct dcb_app app;
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:855:17: error:
‘IEEE_8021QAZ_APP_SEL_ETHERTYPE’ undeclared (first use in this function)
app.selector = IEEE_8021QAZ_APP_SEL_ETHERTYPE;
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:855:17: note: each
undeclared identifier is reported only once for each function it appears in
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:857:2: error: implicit
declaration of function ‘dcb_ieee_getapp_mask’
[-Werror=implicit-function-declaration]
tmp_map = dcb_ieee_getapp_mask(netdev, &app);
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:860:17: error:
‘IEEE_8021QAZ_APP_SEL_DGRAM’ undeclared (first use in this function)
app.selector = IEEE_8021QAZ_APP_SEL_DGRAM;
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:850:17: warning: unused
variable ‘app’ [-Wunused-variable]
struct dcb_app app;
^
cc1: some warnings being treated as errors
make[1]: *** [drivers/infiniband/hw/bnxtre/bnxt_re_main.o] Error 1
make: *** [drivers/infiniband/hw/bnxtre/bnxt_re.ko] Error 2
jtoppins@jtoppins:~/projects/linux-rhel7$It seems this is the patch that has the problem:
Author: Selvin Xavier <selvin.xavier-dY08KVG/lbpWk0Htik3J/[email protected]> Date: Sun Dec 4 22:38:29 2016 -0800
bnxt_re: Support for DCB
This patch queries the configured RoCE APP Priority on the host using the dcbnl API and programs the RoCE FW with the corresponding Traffic Class(es) for the priority.
Running this also fails:
$ make M=drivers/infiniband/hw/bnxtre bnxt_re.ko
CC [M] drivers/infiniband/hw/bnxtre/bnxt_re_main.o
drivers/infiniband/hw/bnxtre/bnxt_re_main.c: In function
‘bnxt_re_get_priority_mask’:
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:850:17: error: storage size
of ‘app’ isn’t known
struct dcb_app app;
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:855:17: error:
‘IEEE_8021QAZ_APP_SEL_ETHERTYPE’ undeclared (first use in this function)
app.selector = IEEE_8021QAZ_APP_SEL_ETHERTYPE;
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:855:17: note: each
undeclared identifier is reported only once for each function it appears in
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:857:2: error: implicit
declaration of function ‘dcb_ieee_getapp_mask’
[-Werror=implicit-function-declaration]
tmp_map = dcb_ieee_getapp_mask(netdev, &app);
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:860:17: error:
‘IEEE_8021QAZ_APP_SEL_DGRAM’ undeclared (first use in this function)
app.selector = IEEE_8021QAZ_APP_SEL_DGRAM;
^
drivers/infiniband/hw/bnxtre/bnxt_re_main.c:850:17: warning: unused
variable ‘app’ [-Wunused-variable]
struct dcb_app app;
^
cc1: some warnings being treated as errors
make[1]: *** [drivers/infiniband/hw/bnxtre/bnxt_re_main.o] Error 1
make: *** [bnxt_re.ko] Error 2v2?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): a909ae78-ed49-407a-29c7-b86729f356b8-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Quoted 1 line · Jonathan Toppins
+#include <
net/dcbnl.h>
in the kernel which i used for compilation and testing, linux/netdevice.h is including net/dcbnl.h. bnxt_re_main.c is including netdevice.h. Anyway, i will add this explicitly in bnxt_re_main.c in V2.
Doug,
Since David Miller applied the bnxt_en changes to his net-next tree
(both pending patches and bnxt_re related changes), can you please pull those changes to your bnxt_re branch?
Thanks,
Selvin
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CA+sbYW1P4MqsBF14d9ZK_VjV4edU2bh=sLNTVnGs9F3ojF6vWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 8 lines · Selvin Xavier
Quoted 1 line · Jonathan Toppins
+#include <
net/dcbnl.h>in the kernel which i used for compilation and testing,
linux/netdevice.his includingnet/dcbnl.h.bnxt_re_main.cis includingnetdevice.h. Anyway, i will add this explicitly inbnxt_re_main.cin V2.
Quoted 8 lines
Doug,
Since David Miller applied thebnxt_enchanges to his net-next tree
(both pending patches andbnxt_rerelated changes), can you please pull those changes to yourbnxt_rebranch?Thanks,
Selvin
I had already pulled the changes, I just hadn't pushed them. Now pushed.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD
A message that is not in the archive (sent off-list or not yet received): cd667d80-cc1b-c8df-07d1-a5e7b9f94c68-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Quoted 14 lines · Doug Ledford
Quoted 13 lines · Selvin Xavier
Quoted 1 line · Jonathan Toppins
+#include <
net/dcbnl.h>in the kernel which i used for compilation and testing,
linux/netdevice.his includingnet/dcbnl.h.bnxt_re_main.cis includingnetdevice.h. Anyway, i will add this explicitly inbnxt_re_main.cin V2.Doug,
Since David Miller applied thebnxt_enchanges to his net-next tree
(both pending patches andbnxt_rerelated changes), can you please pull those changes to yourbnxt_rebranch?
Quoted 6 lines
Quoted 3 lines
Thanks,
SelvinI had already pulled the changes, I just hadn't pushed them. Now pushed.
hummm ok I will retest. When I did the original compile test I did it on top of net-next/master as well as rdma/k.o/for-4.10 + merge of net-next/master + patches in this series not already merged into net-next and still got compile error. So clearly there was a patch from somewhere else I was missing.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/28 bnxt_en: Enable MSIX early in bnxt_init_one().
In reply to Selvin XavierFrom: Michael Chan <[email protected]>
To better support the new RDMA driver, we need to move pci_enable_msix() from bnxt_open() to bnxt_init_one(). This way, MSIX vectors are available to the RDMA driver whether the network device is up or down.
Part of the existing bnxt_setup_int_mode() function is now refactored into a new bnxt_init_int_mode(). bnxt_init_int_mode() is called during bnxt_init_one() to enable MSIX. The remaining logic in bnxt_setup_int_mode() to map the IRQs to the completion rings is called during bnxt_open().
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 183 +++++++++++++++++++----------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 115 insertions(+), 69 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +114 -69
@@ -4743,6 +4743,80 @@ static int bnxt_trim_rings(struct bnxt *bp, int *rx, int *tx, int max,return 0 ; } +static void bnxt_setup_msix (struct bnxt *bp) +{ +const int len =sizeof (bp->irq_tbl[0 ].name); +struct net_device *dev = bp->dev; +int tcs, i; + + tcs =netdev_get_num_tc (dev); +if (tcs >1 ) { + bp->tx_nr_rings_per_tc = bp->tx_nr_rings / tcs; +if (bp->tx_nr_rings_per_tc ==0 ) { +netdev_reset_tc (dev); + bp->tx_nr_rings_per_tc = bp->tx_nr_rings; + }else { +int i, off, count; + + bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs; +for (i =0 ; i < tcs; i++) { + count = bp->tx_nr_rings_per_tc; + off = i * count; +netdev_set_tc_queue (dev, i, count, off); + } + } + } + +for (i =0 ; i < bp->cp_nr_rings; i++) { +char *attr; + +if (bp->flags &BNXT_FLAG_SHARED_RINGS ) + attr ="TxRx" ; +else if (i < bp->rx_nr_rings) + attr ="rx" ; +else + attr ="tx" ; + +snprintf (bp->irq_tbl[i].name, len,"%s-%s-%d" , dev->name, attr, + i); + bp->irq_tbl[i].handler = bnxt_msix; + } +} + +static void bnxt_setup_inta (struct bnxt *bp) +{ +const int len =sizeof (bp->irq_tbl[0 ].name); + +if (netdev_get_num_tc (bp->dev)) +netdev_reset_tc (bp->dev); + +snprintf (bp->irq_tbl[0 ].name, len,"%s-%s-%d" , bp->dev->name,"TxRx" , +0 ); + bp->irq_tbl[0 ].handler = bnxt_inta; +} + +static int bnxt_setup_int_mode (struct bnxt *bp) +{ +int rc; + +if (bp->flags &BNXT_FLAG_USING_MSIX ) +bnxt_setup_msix (bp); +else +bnxt_setup_inta (bp); + + rc =bnxt_set_real_num_queues (bp); +return rc; +} + +static unsigned int bnxt_get_max_func_irqs (struct bnxt *bp) +{ +if (BNXT_PF (bp)) +return bp->pf.max_irqs; +#if defined(CONFIG_BNXT_SRIOV ) +return bp->vf.max_irqs; +#endif +} +void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max_irqs) {if (BNXT_PF (bp))
@@ -4753,16 +4827,12 @@ void bnxt_set_max_func_irqs(struct bnxt *bp, unsigned int max_irqs)#endif } -static int bnxt_setup_msix (struct bnxt *bp) +static int bnxt_init_msix (struct bnxt *bp) { -struct msix_entry *msix_ent; -struct net_device *dev = bp->dev;int i, total_vecs, rc =0 , min =1 ; -const int len =sizeof (bp->irq_tbl[0 ].name); - - bp->flags &= ~BNXT_FLAG_USING_MSIX ; - total_vecs = bp->cp_nr_rings; +struct msix_entry *msix_ent; + total_vecs =bnxt_get_max_func_irqs (bp); msix_ent =kcalloc (total_vecs,sizeof (struct msix_entry ),GFP_KERNEL );if (!msix_ent)return -ENOMEM ;
@@ -4783,8 +4853,10 @@ static int bnxt_setup_msix(struct bnxt *bp) bp->irq_tbl =kcalloc (total_vecs,sizeof (struct bnxt_irq ),GFP_KERNEL );if (bp->irq_tbl) { -int tcs; +for (i =0 ; i < total_vecs; i++) + bp->irq_tbl[i].vector = msix_ent[i].vector; + bp->total_irqs = total_vecs;/* Trim rings based upon num of vectors allocated */ rc =bnxt_trim_rings (bp, &bp->rx_nr_rings, &bp->tx_nr_rings, total_vecs, min ==1 );
@@ -4792,43 +4864,10 @@ static int bnxt_setup_msix(struct bnxt *bp) goto msix_setup_exit; bp->tx_nr_rings_per_tc = bp->tx_nr_rings; - tcs =netdev_get_num_tc (dev); -if (tcs >1 ) { - bp->tx_nr_rings_per_tc = bp->tx_nr_rings / tcs; -if (bp->tx_nr_rings_per_tc ==0 ) { -netdev_reset_tc (dev); - bp->tx_nr_rings_per_tc = bp->tx_nr_rings; - }else { -int i, off, count; + bp->cp_nr_rings = (min ==1 ) ? +max_t (int, bp->tx_nr_rings, bp->rx_nr_rings) : + bp->tx_nr_rings + bp->rx_nr_rings; - bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tcs; -for (i =0 ; i < tcs; i++) { - count = bp->tx_nr_rings_per_tc; - off = i * count; -netdev_set_tc_queue (dev, i, count, off); - } - } - } - bp->cp_nr_rings = total_vecs; - -for (i =0 ; i < bp->cp_nr_rings; i++) { -char *attr; - - bp->irq_tbl[i].vector = msix_ent[i].vector; -if (bp->flags &BNXT_FLAG_SHARED_RINGS ) - attr ="TxRx" ; -else if (i < bp->rx_nr_rings) - attr ="rx" ; -else - attr ="tx" ; - -snprintf (bp->irq_tbl[i].name, len, -"%s-%s-%d" , dev->name, attr, i); - bp->irq_tbl[i].handler = bnxt_msix; - } - rc =bnxt_set_real_num_queues (bp); -if (rc) - goto msix_setup_exit; }else { rc = -ENOMEM ; goto msix_setup_exit;
@@ -4838,52 +4877,54 @@ static int bnxt_setup_msix(struct bnxt *bp)return 0 ; msix_setup_exit: -netdev_err (bp->dev,"bnxt_setup_msix err: %x\n" , rc); +netdev_err (bp->dev,"bnxt_init_msix err: %x\n" , rc); +kfree (bp->irq_tbl); + bp->irq_tbl =NULL ;pci_disable_msix (bp->pdev);kfree (msix_ent);return rc; } -static int bnxt_setup_inta (struct bnxt *bp) +static int bnxt_init_inta (struct bnxt *bp) { -int rc; -const int len =sizeof (bp->irq_tbl[0 ].name); - -if (netdev_get_num_tc (bp->dev)) -netdev_reset_tc (bp->dev); - bp->irq_tbl =kcalloc (1 ,sizeof (struct bnxt_irq ),GFP_KERNEL ); -if (!bp->irq_tbl) { - rc = -ENOMEM ; -return rc; - } +if (!bp->irq_tbl) +return -ENOMEM ; + + bp->total_irqs =1 ; bp->rx_nr_rings =1 ; bp->tx_nr_rings =1 ; bp->cp_nr_rings =1 ; bp->tx_nr_rings_per_tc = bp->tx_nr_rings; bp->flags |=BNXT_FLAG_SHARED_RINGS ; bp->irq_tbl[0 ].vector = bp->pdev->irq; -snprintf (bp->irq_tbl[0 ].name, len, -"%s-%s-%d" , bp->dev->name,"TxRx" ,0 ); - bp->irq_tbl[0 ].handler = bnxt_inta; - rc =bnxt_set_real_num_queues (bp); -return rc; +return 0 ; } -static int bnxt_setup_int_mode (struct bnxt *bp) +static int bnxt_init_int_mode (struct bnxt *bp) {int rc =0 ;if (bp->flags &BNXT_FLAG_MSIX_CAP ) - rc =bnxt_setup_msix (bp); + rc =bnxt_init_msix (bp);if (!(bp->flags &BNXT_FLAG_USING_MSIX ) &&BNXT_PF (bp)) {/* fallback to INTA */ - rc =bnxt_setup_inta (bp); + rc =bnxt_init_inta (bp); }return rc; } +static void bnxt_clear_int_mode (struct bnxt *bp) +{ +if (bp->flags &BNXT_FLAG_USING_MSIX ) +pci_disable_msix (bp->pdev); + +kfree (bp->irq_tbl); + bp->irq_tbl =NULL ; + bp->flags &= ~BNXT_FLAG_USING_MSIX ; +} +static void bnxt_free_irq (struct bnxt *bp) {struct bnxt_irq *irq;
@@ -4902,10 +4943,6 @@ static void bnxt_free_irq(struct bnxt *bp)free_irq (irq->vector, bp->bnapi[i]); irq->requested =0 ; } -if (bp->flags &BNXT_FLAG_USING_MSIX ) -pci_disable_msix (bp->pdev); -kfree (bp->irq_tbl); - bp->irq_tbl =NULL ; }static int bnxt_request_irq (struct bnxt *bp)
@@ -6695,6 +6732,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)cancel_work_sync (&bp->sp_task); bp->sp_event =0 ; +bnxt_clear_int_mode (bp);bnxt_hwrm_func_drv_unrgtr (bp);bnxt_free_hwrm_resources (bp);bnxt_dcb_free (bp);
@@ -6990,10 +7028,14 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc) goto init_err; - rc =register_netdev (dev); + rc =bnxt_init_int_mode (bp);if (rc) goto init_err; + rc =register_netdev (dev); +if (rc) + goto init_err_clr_int; +netdev_info (dev,"%s found at mem %lx, node addr %pM\n" , board_info[ent->driver_data].name, (long )pci_resource_start (pdev,0 ), dev->dev_addr);
@@ -7002,6 +7044,9 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)return 0 ; +init_err_clr_int: +bnxt_clear_int_mode (bp); + init_err:pci_iounmap (pdev, bp->bar0);pci_release_regions (pdev);
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -1024,6 +1024,7 @@ struct bnxt {#define BNXT_STATE_FN_RST_DONE 2struct bnxt_irq *irq_tbl; +int total_irqs;u8 mac_addr[ETH_ALEN ];#ifdef CONFIG_BNXT_DCB
Signature · 1 line
2.5.5
PATCH 3/28 bnxt_en: Move function reset to bnxt_init_one().
In reply to Selvin XavierFrom: Michael Chan <[email protected]>
Now that MSIX is enabled in bnxt_init_one(), resources may be allocated by the RDMA driver before the network device is opened. So we cannot do function reset in bnxt_open() which will clear all the resources.
The proper place to do function reset now is in bnxt_init_one(). If we get AER, we'll do function reset as well.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 25 ++++++------------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - 2 files changed, 6 insertions(+), 20 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +6 -19
@@ -5613,22 +5613,7 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)static int bnxt_open (struct net_device *dev) {struct bnxt *bp =netdev_priv (dev); -int rc =0 ; -if (!test_bit (BNXT_STATE_FN_RST_DONE , &bp->state)) { - rc =bnxt_hwrm_func_reset (bp); -if (rc) { -netdev_err (bp->dev,"hwrm chip reset failure rc: %x\n" , - rc); - rc = -EBUSY ; -return rc; - } -/* Do func_reset during the 1st PF open only to prevent killing -* the VFs when the PF is brought down and up. -*/ -if (BNXT_PF (bp)) -set_bit (BNXT_STATE_FN_RST_DONE , &bp->state); - }return __bnxt_open_nic (bp, true, true); }
@@ -7028,6 +7013,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc) goto init_err; + rc =bnxt_hwrm_func_reset (bp); +if (rc) + goto init_err; + rc =bnxt_init_int_mode (bp);if (rc) goto init_err;
@@ -7069,7 +7058,6 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) {struct net_device *netdev =pci_get_drvdata (pdev); -struct bnxt *bp =netdev_priv (netdev);netdev_info (netdev,"PCI I/O error detected\n" );
@@ -7084,8 +7072,6 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,if (netif_running (netdev))bnxt_close (netdev); -/* So that func_reset will be done during slot_reset */ -clear_bit (BNXT_STATE_FN_RST_DONE , &bp->state);pci_disable_device (pdev);rtnl_unlock ();
@@ -7119,7 +7105,8 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev) }else {pci_set_master (pdev); -if (netif_running (netdev)) + err =bnxt_hwrm_func_reset (bp); +if (!err &&netif_running (netdev)) err =bnxt_open (netdev);if (!err)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +0 -1
@@ -1021,7 +1021,6 @@ struct bnxt {unsigned long state;#define BNXT_STATE_OPEN 0#define BNXT_STATE_IN_SP_TASK 1 -#define BNXT_STATE_FN_RST_DONE 2struct bnxt_irq *irq_tbl;int total_irqs;
Signature · 1 line
2.5.5
PATCH 4/28 bnxt_en: Improve completion ring allocation for VFs.
In reply to Selvin XavierFrom: Michael Chan <[email protected]>
All available remaining completion rings not used by the PF should be made available for the VFs so that there are enough rings in the VF to support RDMA. The earlier workaround code of capping the rings by the statistics context is removed.
When SRIOV is disabled, call a new function bnxt_restore_pf_fw_resources() to restore FW resources. Later on we need to add some logic to account for RDMA resources.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 +++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 14 ++++---------- 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +7 -1
@@ -4152,7 +4152,7 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)return rc; } -int bnxt_hwrm_func_qcaps (struct bnxt *bp) +static int bnxt_hwrm_func_qcaps (struct bnxt *bp) {int rc =0 ;struct hwrm_func_qcaps_input req = {0 };
@@ -6856,6 +6856,12 @@ static int bnxt_set_dflt_rings(struct bnxt *bp)return rc; } +void bnxt_restore_pf_fw_resources (struct bnxt *bp) +{ +ASSERT_RTNL (); +bnxt_hwrm_func_qcaps (bp); +} +static void bnxt_parse_log_pcie_link (struct bnxt *bp) {enum pcie_link_width width =PCIE_LNK_WIDTH_UNKNOWN ;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -1
@@ -1234,7 +1234,6 @@ int _hwrm_send_message(struct bnxt *, void *, u32, int);int hwrm_send_message (struct bnxt *,void *,u32 ,int );int hwrm_send_message_silent (struct bnxt *,void *,u32 ,int );int bnxt_hwrm_set_coal (struct bnxt *); -int bnxt_hwrm_func_qcaps (struct bnxt *);void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max);void bnxt_tx_disable (struct bnxt *bp);void bnxt_tx_enable (struct bnxt *bp);
@@ -1245,4 +1244,5 @@ int bnxt_open_nic(struct bnxt *, bool, bool);int bnxt_close_nic (struct bnxt *,bool ,bool );int bnxt_setup_mq_tc (struct net_device *dev,u8 tc);int bnxt_get_max_rings (struct bnxt *,int *,int *,bool ); +void bnxt_restore_pf_fw_resources (struct bnxt *bp);#endif
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +4 -10
@@ -420,15 +420,7 @@ static int bnxt_hwrm_func_cfg(struct bnxt *bp, int num_vfs)bnxt_hwrm_cmd_hdr_init (bp, &req,HWRM_FUNC_CFG ,-1 ,-1 );/* Remaining rings are distributed equally amongs VF's for now */ -/* TODO: the following workaroud is needed to restrict total number -* of vf_cp_rings not exceed number of HW ring groups. This WA should -* be removed once new HWRM provides HW ring groups capability in -* hwrm_func_qcap. -*/ - vf_cp_rings =min_t (u16, pf->max_cp_rings, pf->max_stat_ctxs); - vf_cp_rings = (vf_cp_rings - bp->cp_nr_rings) / num_vfs; -/* TODO: restore this logic below once the WA above is removed */ -/* vf_cp_rings = (pf->max_cp_rings - bp->cp_nr_rings) / num_vfs; */ + vf_cp_rings = (pf->max_cp_rings - bp->cp_nr_rings) / num_vfs; vf_stat_ctx = (pf->max_stat_ctxs - bp->num_stat_ctxs) / num_vfs;if (bp->flags &BNXT_FLAG_AGG_RINGS ) vf_rx_rings = (pf->max_rx_rings - bp->rx_nr_rings * 2) /
@@ -590,7 +582,9 @@ void bnxt_sriov_disable(struct bnxt *bp) bp->pf.active_vfs =0 ;/* Reclaim all resources for the PF. */ -bnxt_hwrm_func_qcaps (bp); +rtnl_lock (); +bnxt_restore_pf_fw_resources (bp); +rtnl_unlock (); }int bnxt_sriov_configure (struct pci_dev *pdev,int num_vfs)
Signature · 1 line
2.5.5
PATCH 5/28 bnxt_en: Reserve RDMA resources by default.
In reply to Selvin XavierFrom: Michael Chan <[email protected]>
If the device supports RDMA, we'll setup network default rings so that there are enough minimum resources for RDMA, if possible. However, the user can still increase network rings to the max if he wants. The actual RDMA resources won't be reserved until the RDMA driver registers.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 58 ++++++++++++++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 9 +++++ 2 files changed, 66 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +57 -1
@@ -4166,6 +4166,11 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp)if (rc) goto hwrm_func_qcaps_exit; +if (resp->flags &cpu_to_le32 (FUNC_QCAPS_RESP_FLAGS_ROCE_V1_SUPPORTED )) + bp->flags |=BNXT_FLAG_ROCEV1_CAP ; +if (resp->flags &cpu_to_le32 (FUNC_QCAPS_RESP_FLAGS_ROCE_V2_SUPPORTED )) + bp->flags |=BNXT_FLAG_ROCEV2_CAP ; + bp->tx_push_thresh =0 ;if (resp->flags &cpu_to_le32 (FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED ))
@@ -4808,6 +4813,24 @@ static int bnxt_setup_int_mode(struct bnxt *bp)return rc; } +unsigned int bnxt_get_max_func_stat_ctxs (struct bnxt *bp) +{ +if (BNXT_PF (bp)) +return bp->pf.max_stat_ctxs; +#if defined(CONFIG_BNXT_SRIOV ) +return bp->vf.max_stat_ctxs; +#endif +} + +unsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp) +{ +if (BNXT_PF (bp)) +return bp->pf.max_cp_rings; +#if defined(CONFIG_BNXT_SRIOV ) +return bp->vf.max_cp_rings; +#endif +} +static unsigned int bnxt_get_max_func_irqs (struct bnxt *bp) {if (BNXT_PF (bp))
@@ -6832,6 +6855,39 @@ int bnxt_get_max_rings(struct bnxt *bp, int *max_rx, int *max_tx, bool shared)return bnxt_trim_rings (bp, max_rx, max_tx, cp, shared); } +static int bnxt_get_dflt_rings (struct bnxt *bp,int *max_rx,int *max_tx, +bool shared) +{ +int rc; + + rc =bnxt_get_max_rings (bp, max_rx, max_tx, shared); +if (rc) +return rc; + +if (bp->flags &BNXT_FLAG_ROCE_CAP ) { +int max_cp, max_stat, max_irq; + +/* Reserve minimum resources for RoCE */ + max_cp =bnxt_get_max_func_cp_rings (bp); + max_stat =bnxt_get_max_func_stat_ctxs (bp); + max_irq =bnxt_get_max_func_irqs (bp); +if (max_cp <=BNXT_MIN_ROCE_CP_RINGS || + max_irq <=BNXT_MIN_ROCE_CP_RINGS || + max_stat <=BNXT_MIN_ROCE_STAT_CTXS ) +return 0 ; + + max_cp -=BNXT_MIN_ROCE_CP_RINGS ; + max_irq -=BNXT_MIN_ROCE_CP_RINGS ; + max_stat -=BNXT_MIN_ROCE_STAT_CTXS ; + max_cp =min_t (int, max_cp, max_irq); + max_cp =min_t (int, max_cp, max_stat); + rc =bnxt_trim_rings (bp, max_rx, max_tx, max_cp, shared); +if (rc) + rc =0 ; + } +return rc; +} +static int bnxt_set_dflt_rings (struct bnxt *bp) {int dflt_rings, max_rx_rings, max_tx_rings, rc;
@@ -6840,7 +6896,7 @@ static int bnxt_set_dflt_rings(struct bnxt *bp)if (sh) bp->flags |=BNXT_FLAG_SHARED_RINGS ; dflt_rings =netif_get_num_default_rss_queues (); - rc =bnxt_get_max_rings (bp, &max_rx_rings, &max_tx_rings, sh); + rc =bnxt_get_dflt_rings (bp, &max_rx_rings, &max_tx_rings, sh);if (rc)return rc; bp->rx_nr_rings =min_t (int, dflt_rings, max_rx_rings);
drivers/net/ethernet/broadcom/bnxt/bnxt.h +9 -0
@@ -387,6 +387,9 @@ struct rx_tpa_end_cmp_ext {#define DB_KEY_TX_PUSH (0x4 << 28)#define DB_LONG_TX_PUSH (0x2 << 24) +#define BNXT_MIN_ROCE_CP_RINGS 2 +#define BNXT_MIN_ROCE_STAT_CTXS 1 +#define INVALID_HW_RING_ID ((u16)-1)/* The hardware supports certain page sizes. Use the supported page sizes
@@ -953,6 +956,10 @@ struct bnxt {#define BNXT_FLAG_PORT_STATS 0x400#define BNXT_FLAG_UDP_RSS_CAP 0x800#define BNXT_FLAG_EEE_CAP 0x1000 +#define BNXT_FLAG_ROCEV1_CAP 0x8000 +#define BNXT_FLAG_ROCEV2_CAP 0x10000 +#define BNXT_FLAG_ROCE_CAP (BNXT_FLAG_ROCEV1_CAP | \ + BNXT_FLAG_ROCEV2_CAP)#define BNXT_FLAG_CHIP_NITRO_A0 0x1000000#define BNXT_FLAG_ALL_CONFIG_FEATS (BNXT_FLAG_TPA | \
@@ -1234,6 +1241,8 @@ int _hwrm_send_message(struct bnxt *, void *, u32, int);int hwrm_send_message (struct bnxt *,void *,u32 ,int );int hwrm_send_message_silent (struct bnxt *,void *,u32 ,int );int bnxt_hwrm_set_coal (struct bnxt *); +unsigned int bnxt_get_max_func_stat_ctxs (struct bnxt *bp); +unsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp);void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max);void bnxt_tx_disable (struct bnxt *bp);void bnxt_tx_enable (struct bnxt *bp);
Signature · 1 line
2.5.5
PATCH 7/28 bnxt_en: Add interface to support RDMA driver.
In reply to Selvin XavierFrom: Michael Chan <[email protected]>
Since the network driver and RDMA driver operate on the same PCI function, we need to create an interface to allow the RDMA driver to share resources with the network driver.
1. Create a new bnxt_en_dev struct which will be returned by bnxt_ulp_probe() upon success. After that, all calls from the RDMA driver to bnxt_en will pass a pointer to this struct.
2. This struct contains additional function pointers to register, request msix, send fw messages, register for async events.
3. If the RDMA driver wants to enable RDMA on the function, it needs to call the function pointer bnxt_register_device(). A ulp_ops structure is passed for upcalls from bnxt_en to the RDMA driver.
4. MSIX is requested by calling the function pointer bnxt_request_msix().
5. The RMDA driver can call firmware APIs using the bnxt_send_fw_msg() function pointer.
6. 1 stats context is reserved when the RDMA driver registers. MSIX and completion rings are reserved when the RDMA driver requests for MSIX.
7. When the RDMA driver calls bnxt_unregister_device(), all RDMA resources will be cleaned up.
--- drivers/net/ethernet/broadcom/bnxt/Makefile | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 34 ++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 6 + drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 288 ++++++++++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 91 ++++++++ 5 files changed, 417 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c create mode 100644 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h
drivers/net/ethernet/broadcom/bnxt/Makefile +1 -1
@@ -1,3 +1,3 @@ obj-$(CONFIG_BNXT) += bnxt_en.o -bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o +bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp.o
drivers/net/ethernet/broadcom/bnxt/bnxt.c +31 -3
@@ -52,6 +52,7 @@#include "bnxt_hsi.h" #include "bnxt.h" +#include "bnxt_ulp.h" #include "bnxt_sriov.h" #include "bnxt_ethtool.h" #include "bnxt_dcb.h"
@@ -1528,12 +1529,11 @@ static int bnxt_async_event_process(struct bnxt *bp,set_bit (BNXT_RESET_TASK_SILENT_SP_EVENT , &bp->sp_event);break ;default : -netdev_err (bp->dev,"unhandled ASYNC event (id 0x%x)\n" , - event_id); goto async_event_process_exit; }schedule_work (&bp->sp_task); async_event_process_exit: +bnxt_ulp_async_events (bp, cmpl);return 0 ; }
@@ -3547,7 +3547,7 @@ static int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, u16 vnic_id, u16 ctx_idx)return rc; } -static int bnxt_hwrm_vnic_cfg (struct bnxt *bp,u16 vnic_id) +int bnxt_hwrm_vnic_cfg (struct bnxt *bp,u16 vnic_id) {unsigned int ring =0 , grp_idx;struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id];
@@ -3595,6 +3595,9 @@ static int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id)#endif if ((bp->flags &BNXT_FLAG_STRIP_VLAN ) || def_vlan) req.flags |=cpu_to_le32 (VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE ); +if (!vnic_id &&bnxt_ulp_registered (bp->edev,BNXT_ROCE_ULP )) + req.flags |= +cpu_to_le32 (VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE );return hwrm_send_message (bp, &req,sizeof (req),HWRM_CMD_TIMEOUT ); }
@@ -4842,6 +4845,16 @@ unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp)#endif } +void bnxt_set_max_func_stat_ctxs (struct bnxt *bp,unsigned int max) +{ +if (BNXT_PF (bp)) + bp->pf.max_stat_ctxs = max; +#if defined(CONFIG_BNXT_SRIOV ) + else + bp->vf.max_stat_ctxs = max; +#endif +} +unsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp) {if (BNXT_PF (bp))
@@ -4851,6 +4864,16 @@ unsigned int bnxt_get_max_func_cp_rings(struct bnxt *bp)#endif } +void bnxt_set_max_func_cp_rings (struct bnxt *bp,unsigned int max) +{ +if (BNXT_PF (bp)) + bp->pf.max_cp_rings = max; +#if defined(CONFIG_BNXT_SRIOV ) + else + bp->vf.max_cp_rings = max; +#endif +} +static unsigned int bnxt_get_max_func_irqs (struct bnxt *bp) {if (BNXT_PF (bp))
@@ -6767,6 +6790,8 @@ static void bnxt_remove_one(struct pci_dev *pdev)pci_iounmap (pdev, bp->bar2);pci_iounmap (pdev, bp->bar1);pci_iounmap (pdev, bp->bar0); +kfree (bp->edev); + bp->edev =NULL ;free_netdev (dev);pci_release_regions (pdev);
@@ -6936,6 +6961,7 @@ void bnxt_restore_pf_fw_resources(struct bnxt *bp) {ASSERT_RTNL ();bnxt_hwrm_func_qcaps (bp); +bnxt_subtract_ulp_resources (bp,BNXT_ROCE_ULP ); }static void bnxt_parse_log_pcie_link (struct bnxt *bp)
@@ -7047,6 +7073,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)if (rc) goto init_err; + bp->ulp_probe = bnxt_ulp_probe; +/* Get the MAX capabilities for this function */ rc =bnxt_hwrm_func_qcaps (bp);if (rc) {
drivers/net/ethernet/broadcom/bnxt/bnxt.h +6 -0
@@ -972,6 +972,9 @@ struct bnxt {#define BNXT_SINGLE_PF (bp) (BNXT_PF(bp) && !BNXT_NPAR(bp))#define BNXT_CHIP_TYPE_NITRO_A0 (bp) ((bp)->flags & BNXT_FLAG_CHIP_NITRO_A0) +struct bnxt_en_dev *edev; +struct bnxt_en_dev * (*ulp_probe)(struct net_device *); +struct bnxt_napi **bnapi;struct bnxt_rx_ring_info *rx_ring;
@@ -1242,9 +1245,12 @@ int hwrm_send_message(struct bnxt *, void *, u32, int);int hwrm_send_message_silent (struct bnxt *,void *,u32 ,int );int bnxt_hwrm_func_rgtr_async_events (struct bnxt *bp,unsigned long *bmap,int bmap_size); +int bnxt_hwrm_vnic_cfg (struct bnxt *bp,u16 vnic_id);int bnxt_hwrm_set_coal (struct bnxt *);unsigned int bnxt_get_max_func_stat_ctxs (struct bnxt *bp); +void bnxt_set_max_func_stat_ctxs (struct bnxt *bp,unsigned int max);unsigned int bnxt_get_max_func_cp_rings (struct bnxt *bp); +void bnxt_set_max_func_cp_rings (struct bnxt *bp,unsigned int max);void bnxt_set_max_func_irqs (struct bnxt *bp,unsigned int max);void bnxt_tx_disable (struct bnxt *bp);void bnxt_tx_enable (struct bnxt *bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c new file +288 -0
288 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
2.5.5