octeontx2-af: NPC MCAM support and FLR handling
v2 cover octeontx2-af: NPC MCAM support and FLR handling
From: Sunil Goutham <[email protected]>
This patchset is a continuation to earlier submitted three patch series to add a new driver for Marvell's OcteonTX2 SOC's Resource virtualization unit (RVU) admin function driver.
1. octeontx2-af: Add RVU Admin Function driver
https://www.spinics.net/lists/netdev/msg528272.html
2. octeontx2-af: NPA and NIX blocks initialization
https://www.spinics.net/lists/netdev/msg529163.html
3. octeontx2-af: NPC parser and NIX blocks initialization
https://www.spinics.net/lists/netdev/msg530252.html
This patch series adds support for below
RVU generic:
- Function Level Reset irq handler
When FLR is triggered for PFs, AF receives interrupt. This patchset adds logic for cleaning up of NPA, NIX and NPC block resources being used by PF.
- Mailbox communication between AF and it's VFs. Unlike VFs of PF1-PFn, AF which is PF0 can communicate with it's VFs directly. Added support for the same.
- AF's VFs IO configuration
These VFs are mapped to use internal HW loopback channels instead of CGX LMACs. Each pair of VFs work as two of ends of hardwired interfaces. VF0's TX is VF1's Rx & viceversa.
NPC block:
- MCAM entry management
Alloc/Free of contiguous/non-contiguous and lower/higher priority MCAM entry allocation and programming support.
- MCAM counters management and map/unmap with MCAM entries
- Default KEY extract profile
- HW errata workarounds
NIX block:
- Minimum and maximum allowed packet length config
- HW errata workarounds
Few more changes like shift to use mutex instead of spinlock etc are done in this patchset.
Changes from v1:
1 Converted all mailbox message handler API names to small letters
from mixed small and capital letters.
- Suggested by David Miller.
2 Fixed endian issues in patch 'Add support for stripping STAG/CTAG'
- Suggested by Arnd Bergmann
3 Elaborated commit message of patch 'Add FLR interrupt handler'
to make it a bit more easy to understand.
- Suggested by Arnd Bergmann
Will fix the padding and alignment in mailbox message structure in a follow-up patch.
Geetha sowjanya (2):
octeontx2-af: Add FLR interrupt handler
octeontx2-af: Teardown NPA, NIX LF upon receiving FLR
Kiran Kumar (1):
octeontx2-af: Support to get NIX HW constants from AF
Linu Cherian (1):
octeontx2-af: Add interrupt handlers for Master Enable event
Santosh Shukla (1):
octeontx2-af: Add MKEX default profile
Stanislaw Kardach (1):
octeontx2-af: Relax resource lock into mutex
Sunil Goutham (11):
octeontx2-af: Convert mbox handlers APIs to lowercase
octeontx2-af: Support to modify min/max allowed packet lengths
octeontx2-af: NPC MCAM entry alloc/free support
octeontx2-af: MCAM entry installation support
octeontx2-af: Support for NPC MCAM counters
octeontx2-af: Map or unmap NPC MCAM entry and counter
octeontx2-af: Alloc and config NPC MCAM entry at a time
octeontx2-af: Support to enable/disable default MCAM entries
octeontx2-af: Verify NPA/SSO/NIX PF_FUNC mapping
octeontx2-af: Add FLR handling support for AF's VFs
octeontx2-af: Workarounds for HW errata
Tomasz Duszynski (4):
octeontx2-af: Add support for stripping STAG/CTAG
octeontx2-af: Mbox communication support btw AF and it's VFs
octeontx2-af: Enable sriov on AF to create VFs
octeontx2-af: Configure AF VFs to talk over LBK channels
drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 1 + drivers/net/ethernet/marvell/octeontx2/af/common.h | 7 + drivers/net/ethernet/marvell/octeontx2/af/mbox.c | 2 +- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 280 +++- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 6 + drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 953 ++++++++++++-- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 174 ++- .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 36 +- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 519 +++++++- .../net/ethernet/marvell/octeontx2/af/rvu_npa.c | 25 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 1383 +++++++++++++++++++- 11 files changed, 3064 insertions(+), 322 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/21 octeontx2-af: Convert mbox handlers APIs to lowercase
From: Sunil Goutham <[email protected]>
This patch converts all mailbox message handler API names to lowercase.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.c | 2 +- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 73 ++++++++++++---------- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 16 ++--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 56 ++++++++--------- .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 30 ++++----- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 24 +++---- .../net/ethernet/marvell/octeontx2/af/rvu_npa.c | 8 +-- 7 files changed, 107 insertions(+), 102 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.c +1 -1
@@ -290,7 +290,7 @@ EXPORT_SYMBOL(otx2_mbox_nonempty);const char *otx2_mbox_id2name (u16 id) {switch (id) { -#define M (_name, _id, _1, _2) case _id: return # _name; +#define M (_name, _id, _1, _2, _3) case _id: return # _name; MBOX_MESSAGES#undef Mdefault :
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +39 -34
93 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +8 -8
@@ -830,7 +830,7 @@ int rvu_aq_alloc(struct rvu *rvu, struct admin_queue **ad_queue,return 0 ; } -static int rvu_mbox_handler_READY (struct rvu *rvu,struct msg_req *req, +static int rvu_mbox_handler_ready (struct rvu *rvu,struct msg_req *req,struct ready_msg_rsp *rsp) {return 0 ;
@@ -960,7 +960,7 @@ static int rvu_detach_rsrcs(struct rvu *rvu, struct rsrc_detach *detach,return 0 ; } -static int rvu_mbox_handler_DETACH_RESOURCES (struct rvu *rvu, +static int rvu_mbox_handler_detach_resources (struct rvu *rvu,struct rsrc_detach *detach,struct msg_rsp *rsp) {
@@ -1108,7 +1108,7 @@ static int rvu_check_rsrc_availability(struct rvu *rvu,return -ENOSPC ; } -static int rvu_mbox_handler_ATTACH_RESOURCES (struct rvu *rvu, +static int rvu_mbox_handler_attach_resources (struct rvu *rvu,struct rsrc_attach *attach,struct msg_rsp *rsp) {
@@ -1231,7 +1231,7 @@ static void rvu_clear_msix_offset(struct rvu *rvu, struct rvu_pfvf *pfvf,rvu_free_rsrc_contig (&pfvf->msix, nvecs, offset); } -static int rvu_mbox_handler_MSIX_OFFSET (struct rvu *rvu,struct msg_req *req, +static int rvu_mbox_handler_msix_offset (struct rvu *rvu,struct msg_req *req,struct msix_offset_rsp *rsp) {struct rvu_hwinfo *hw = rvu->hw;
@@ -1288,7 +1288,7 @@ static int rvu_process_mbox_msg(struct rvu *rvu, int devid, goto bad_message;switch (req->id) { -#define M (_name, _id, _req_type, _rsp_type) \ +#define M (_name, _id, _fn_name, _req_type, _rsp_type) \ case _id: { \ struct _rsp_type *rsp; \ int err; \
@@ -1303,9 +1303,9 @@ static int rvu_process_mbox_msg(struct rvu *rvu, int devid, rsp->hdr.rc =0 ; \ } \ \ - err = rvu_mbox_handler_ ## _name(rvu, \ - (struct _req_type *)req, \ - rsp); \ + err = rvu_mbox_handler_ ## _fn_name(rvu, \ + (struct _req_type *)req, \ + rsp); \if (rsp && err) \ rsp->hdr.rc = err; \ \
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +28 -28
112 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +15 -15
@@ -20,9 +20,9 @@ struct cgx_evq_entry {struct cgx_link_event link_event; }; -#define M (_name, _id, _req_type, _rsp_type) \ +#define M (_name, _id, _fn_name, _req_type, _rsp_type) \ static struct _req_type __maybe_unused \ -*otx2_mbox_alloc_msg_ ## _name(struct rvu *rvu, int devid) \ +*otx2_mbox_alloc_msg_ ## _fn_name(struct rvu *rvu, int devid) \ { \ struct _req_type *req; \ \
@@ -177,7 +177,7 @@ static void cgx_notify_pfs(struct cgx_link_event *event, struct rvu *rvu) }/* Send mbox message to PF */ - msg =otx2_mbox_alloc_msg_CGX_LINK_EVENT (rvu, pfid); + msg =otx2_mbox_alloc_msg_cgx_link_event (rvu, pfid);if (!msg)continue ; msg->link_info = *linfo;
@@ -303,21 +303,21 @@ int rvu_cgx_config_rxtx(struct rvu *rvu, u16 pcifunc, bool start)return 0 ; } -int rvu_mbox_handler_CGX_START_RXTX (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_start_rxtx (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {rvu_cgx_config_rxtx (rvu, req->hdr.pcifunc, true);return 0 ; } -int rvu_mbox_handler_CGX_STOP_RXTX (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_stop_rxtx (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {rvu_cgx_config_rxtx (rvu, req->hdr.pcifunc, false);return 0 ; } -int rvu_mbox_handler_CGX_STATS (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_stats (struct rvu *rvu,struct msg_req *req,struct cgx_stats_rsp *rsp) {int pf =rvu_get_pf (req->hdr.pcifunc);
@@ -354,7 +354,7 @@ int rvu_mbox_handler_CGX_STATS(struct rvu *rvu, struct msg_req *req,return 0 ; } -int rvu_mbox_handler_CGX_MAC_ADDR_SET (struct rvu *rvu, +int rvu_mbox_handler_cgx_mac_addr_set (struct rvu *rvu,struct cgx_mac_addr_set_or_get *req,struct cgx_mac_addr_set_or_get *rsp) {
@@ -368,7 +368,7 @@ int rvu_mbox_handler_CGX_MAC_ADDR_SET(struct rvu *rvu,return 0 ; } -int rvu_mbox_handler_CGX_MAC_ADDR_GET (struct rvu *rvu, +int rvu_mbox_handler_cgx_mac_addr_get (struct rvu *rvu,struct cgx_mac_addr_set_or_get *req,struct cgx_mac_addr_set_or_get *rsp) {
@@ -387,7 +387,7 @@ int rvu_mbox_handler_CGX_MAC_ADDR_GET(struct rvu *rvu,return 0 ; } -int rvu_mbox_handler_CGX_PROMISC_ENABLE (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_promisc_enable (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {u16 pcifunc = req->hdr.pcifunc;
@@ -407,7 +407,7 @@ int rvu_mbox_handler_CGX_PROMISC_ENABLE(struct rvu *rvu, struct msg_req *req,return 0 ; } -int rvu_mbox_handler_CGX_PROMISC_DISABLE (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_promisc_disable (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {u16 pcifunc = req->hdr.pcifunc;
@@ -451,21 +451,21 @@ static int rvu_cgx_config_linkevents(struct rvu *rvu, u16 pcifunc, bool en)return 0 ; } -int rvu_mbox_handler_CGX_START_LINKEVENTS (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_start_linkevents (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {rvu_cgx_config_linkevents (rvu, req->hdr.pcifunc, true);return 0 ; } -int rvu_mbox_handler_CGX_STOP_LINKEVENTS (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_stop_linkevents (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {rvu_cgx_config_linkevents (rvu, req->hdr.pcifunc, false);return 0 ; } -int rvu_mbox_handler_CGX_GET_LINKINFO (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_get_linkinfo (struct rvu *rvu,struct msg_req *req,struct cgx_link_info_msg *rsp) {u8 cgx_id, lmac_id;
@@ -500,14 +500,14 @@ static int rvu_cgx_config_intlbk(struct rvu *rvu, u16 pcifunc, bool en) lmac_id, en); } -int rvu_mbox_handler_CGX_INTLBK_ENABLE (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_intlbk_enable (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {rvu_cgx_config_intlbk (rvu, req->hdr.pcifunc, true);return 0 ; } -int rvu_mbox_handler_CGX_INTLBK_DISABLE (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_cgx_intlbk_disable (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {rvu_cgx_config_intlbk (rvu, req->hdr.pcifunc, false);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +12 -12
@@ -637,21 +637,21 @@ static int nix_lf_hwctx_disable(struct rvu *rvu, struct hwctx_disable_req *req)return err; } -int rvu_mbox_handler_NIX_AQ_ENQ (struct rvu *rvu, +int rvu_mbox_handler_nix_aq_enq (struct rvu *rvu,struct nix_aq_enq_req *req,struct nix_aq_enq_rsp *rsp) {return rvu_nix_aq_enq_inst (rvu, req, rsp); } -int rvu_mbox_handler_NIX_HWCTX_DISABLE (struct rvu *rvu, +int rvu_mbox_handler_nix_hwctx_disable (struct rvu *rvu,struct hwctx_disable_req *req,struct msg_rsp *rsp) {return nix_lf_hwctx_disable (rvu, req); } -int rvu_mbox_handler_NIX_LF_ALLOC (struct rvu *rvu, +int rvu_mbox_handler_nix_lf_alloc (struct rvu *rvu,struct nix_lf_alloc_req *req,struct nix_lf_alloc_rsp *rsp) {
@@ -826,7 +826,7 @@ int rvu_mbox_handler_NIX_LF_ALLOC(struct rvu *rvu,return rc; } -int rvu_mbox_handler_NIX_LF_FREE (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_nix_lf_free (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {struct rvu_hwinfo *hw = rvu->hw;
@@ -918,7 +918,7 @@ static void nix_reset_tx_linkcfg(struct rvu *rvu, int blkaddr, NIX_AF_TL3_TL2X_LINKX_CFG(schq, link), 0x00); } -int rvu_mbox_handler_NIX_TXSCH_ALLOC (struct rvu *rvu, +int rvu_mbox_handler_nix_txsch_alloc (struct rvu *rvu,struct nix_txsch_alloc_req *req,struct nix_txsch_alloc_rsp *rsp) {
@@ -1073,7 +1073,7 @@ static int nix_txschq_free(struct rvu *rvu, u16 pcifunc)return 0 ; } -int rvu_mbox_handler_NIX_TXSCH_FREE (struct rvu *rvu, +int rvu_mbox_handler_nix_txsch_free (struct rvu *rvu,struct nix_txsch_free_req *req,struct msg_rsp *rsp) {
@@ -1118,7 +1118,7 @@ static bool is_txschq_config_valid(struct rvu *rvu, u16 pcifunc, int blkaddr,return true; } -int rvu_mbox_handler_NIX_TXSCHQ_CFG (struct rvu *rvu, +int rvu_mbox_handler_nix_txschq_cfg (struct rvu *rvu,struct nix_txschq_config *req,struct msg_rsp *rsp) {
@@ -1209,7 +1209,7 @@ static int nix_rx_vtag_cfg(struct rvu *rvu, int nixlf, int blkaddr,return 0 ; } -int rvu_mbox_handler_NIX_VTAG_CFG (struct rvu *rvu, +int rvu_mbox_handler_nix_vtag_cfg (struct rvu *rvu,struct nix_vtag_config *req,struct msg_rsp *rsp) {
@@ -1506,7 +1506,7 @@ static int nix_setup_txschq(struct rvu *rvu, struct nix_hw *nix_hw, int blkaddr)return 0 ; } -int rvu_mbox_handler_NIX_STATS_RST (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_nix_stats_rst (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {struct rvu_hwinfo *hw = rvu->hw;
@@ -1564,7 +1564,7 @@ static int get_flowkey_alg_idx(u32 flow_cfg)return FLOW_KEY_ALG_PORT ; } -int rvu_mbox_handler_NIX_RSS_FLOWKEY_CFG (struct rvu *rvu, +int rvu_mbox_handler_nix_rss_flowkey_cfg (struct rvu *rvu,struct nix_rss_flowkey_cfg *req,struct msg_rsp *rsp) {
@@ -1720,7 +1720,7 @@ static void nix_rx_flowkey_alg_cfg(struct rvu *rvu, int blkaddr) } } -int rvu_mbox_handler_NIX_SET_MAC_ADDR (struct rvu *rvu, +int rvu_mbox_handler_nix_set_mac_addr (struct rvu *rvu,struct nix_set_mac_addr *req,struct msg_rsp *rsp) {
@@ -1745,7 +1745,7 @@ int rvu_mbox_handler_NIX_SET_MAC_ADDR(struct rvu *rvu,return 0 ; } -int rvu_mbox_handler_NIX_SET_RX_MODE (struct rvu *rvu,struct nix_rx_mode *req, +int rvu_mbox_handler_nix_set_rx_mode (struct rvu *rvu,struct nix_rx_mode *req,struct msg_rsp *rsp) {bool allmulti = false, disable_promisc = false;
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c +4 -4
@@ -241,14 +241,14 @@ static int npa_lf_hwctx_disable(struct rvu *rvu, struct hwctx_disable_req *req)return err; } -int rvu_mbox_handler_NPA_AQ_ENQ (struct rvu *rvu, +int rvu_mbox_handler_npa_aq_enq (struct rvu *rvu,struct npa_aq_enq_req *req,struct npa_aq_enq_rsp *rsp) {return rvu_npa_aq_enq_inst (rvu, req, rsp); } -int rvu_mbox_handler_NPA_HWCTX_DISABLE (struct rvu *rvu, +int rvu_mbox_handler_npa_hwctx_disable (struct rvu *rvu,struct hwctx_disable_req *req,struct msg_rsp *rsp) {
@@ -273,7 +273,7 @@ static void npa_ctx_free(struct rvu *rvu, struct rvu_pfvf *pfvf) pfvf->npa_qints_ctx =NULL ; } -int rvu_mbox_handler_NPA_LF_ALLOC (struct rvu *rvu, +int rvu_mbox_handler_npa_lf_alloc (struct rvu *rvu,struct npa_lf_alloc_req *req,struct npa_lf_alloc_rsp *rsp) {
@@ -372,7 +372,7 @@ int rvu_mbox_handler_NPA_LF_ALLOC(struct rvu *rvu,return rc; } -int rvu_mbox_handler_NPA_LF_FREE (struct rvu *rvu,struct msg_req *req, +int rvu_mbox_handler_npa_lf_free (struct rvu *rvu,struct msg_req *req,struct msg_rsp *rsp) {struct rvu_hwinfo *hw = rvu->hw;
Signature · 1 line
2.7.4
PATCH v2 2/21 octeontx2-af: Support to modify min/max allowed packet lengths
In reply to [email protected]From: Sunil Goutham <[email protected]>
This patch adds support for RVU PF/VFs to modify min/max packet lengths allowed by HW. For VFs on PF0, settings will be automatically applied on LBK link. RX link's min/maxlen is configured to min/max of PF and it's all VFs. On the TX side if requested all SMQs attached to the requesting NIXLF will be updated with new min/max lengths.
Also updates transmit credits for Tx links based on new maxlen.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.h | 1 + drivers/net/ethernet/marvell/octeontx2/af/common.h | 5 + drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 12 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 199 +++++++++++++++++++++ 5 files changed, 220 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/cgx.h +1 -0
@@ -22,6 +22,7 @@#define MAX_CGX 3#define MAX_LMAC_PER_CGX 4 +#define CGX_FIFO_LEN 65536/* 64K for both Rx & Tx */ #define CGX_OFFSET (x) ((x) * MAX_LMAC_PER_CGX)/* Registers */
drivers/net/ethernet/marvell/octeontx2/af/common.h +5 -0
@@ -143,6 +143,11 @@ enum nix_scheduler { NIX_TXSCH_LVL_CNT = 0x5, }; +/* Min/Max packet sizes, excluding FCS */ +#define NIC_HW_MIN_FRS 40 +#define NIC_HW_MAX_FRS 9212 +#define SDP_HW_MAX_FRS 65535 +/* NIX RX action operation*/ #define NIX_RX_ACTIONOP_DROP (0x0ull)#define NIX_RX_ACTIONOP_UCAST (0x1ull)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +11 -1
@@ -165,7 +165,8 @@ M(NIX_VTAG_CFG, 0x8008, nix_vtag_cfg, nix_vtag_config, msg_rsp) \M (NIX_RSS_FLOWKEY_CFG ,0x8009 , nix_rss_flowkey_cfg, \ nix_rss_flowkey_cfg, msg_rsp) \ M(NIX_SET_MAC_ADDR, 0x800a, nix_set_mac_addr, nix_set_mac_addr, msg_rsp) \ -M (NIX_SET_RX_MODE ,0x800b , nix_set_rx_mode, nix_rx_mode, msg_rsp) +M(NIX_SET_RX_MODE, 0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp) \ +M (NIX_SET_HW_FRS ,0x800c , nix_set_hw_frs, nix_frs_cfg, msg_rsp) /* Messages initiated by AF (range 0xC00 - 0xDFF) */#define MBOX_UP_CGX_MESSAGES \
@@ -527,4 +528,13 @@ struct nix_rx_mode { u16 mode; }; +struct nix_frs_cfg { +struct mbox_msghdr hdr; +u8 update_smq;/* Update SMQ's min/max lens */ +u8 update_minlen;/* Set minlen also */ +u8 sdp_link;/* Set SDP RX link */ +u16 maxlen; +u16 minlen; +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +4 -0
@@ -122,6 +122,8 @@ struct rvu_pfvf {u16 tx_chan_base;u8 rx_chan_cnt;/* total number of RX channels */ u8 tx_chan_cnt;/* total number of TX channels */ +u16 maxlen; +u16 minlen;u8 mac_addr[ETH_ALEN ];/* MAC address of this PF/VF */
@@ -349,6 +351,8 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu, struct msg_rsp *rsp);int rvu_mbox_handler_nix_set_rx_mode (struct rvu *rvu,struct nix_rx_mode *req,struct msg_rsp *rsp); +int rvu_mbox_handler_nix_set_hw_frs (struct rvu *rvu,struct nix_frs_cfg *req, +struct msg_rsp *rsp);/* NPC APIs */ int rvu_npc_init (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +199 -0
225 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 3/21 octeontx2-af: Support to get NIX HW constants from AF
In reply to [email protected]From: Kiran Kumar <[email protected]>
This patch adds reading HW limits like number of Rx/Tx stats, number of queue IRQs supported per NIX LF from AF registers and sync them to PF/VF.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 4 ++++ drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 8 ++++++++ 2 files changed, 12 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +4 -0
@@ -398,6 +398,10 @@ struct nix_lf_alloc_rsp {u8 lso_tsov4_idx;u8 lso_tsov6_idx;u8 mac_addr[ETH_ALEN ]; +u8 lf_rx_stats;/* NIX_AF_CONST1::LF_RX_STATS */ +u8 lf_tx_stats;/* NIX_AF_CONST1::LF_TX_STATS */ +u16 cints;/* NIX_AF_CONST2::CINTS */ +u16 qints;/* NIX_AF_CONST2::QINTS */ };/* NIX AQ enqueue msg */
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +8 -0
@@ -829,6 +829,14 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu, rsp->tx_chan_cnt = pfvf->tx_chan_cnt; rsp->lso_tsov4_idx =NIX_LSO_FORMAT_IDX_TSOV4 ; rsp->lso_tsov6_idx =NIX_LSO_FORMAT_IDX_TSOV6 ; +/* Get HW supported stat count */ + cfg =rvu_read64 (rvu, blkaddr,NIX_AF_CONST1 ); + rsp->lf_rx_stats = ((cfg >>32 ) &0xFF ); + rsp->lf_tx_stats = ((cfg >>24 ) &0xFF ); +/* Get count of CQ IRQs and error IRQs supported per LF */ + cfg =rvu_read64 (rvu, blkaddr,NIX_AF_CONST2 ); + rsp->qints = ((cfg >>12 ) &0xFFF ); + rsp->cints = ((cfg >>24 ) &0xFFF );return rc; }
Signature · 1 line
2.7.4
PATCH v2 4/21 octeontx2-af: Relax resource lock into mutex
In reply to [email protected]From: Stanislaw Kardach <[email protected]>
The resource locks does not need to be a spinlock as they are not used in any interrupt handling routines (only in bottom halves). Therefore relax them into a mutex so that later on we may use them in routines that might sleep.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 18 ++++++++------- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 6 ++--- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 27 +++++++++++----------- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 4 +++- 4 files changed, 30 insertions(+), 25 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +10 -8
@@ -153,17 +153,17 @@ int rvu_get_lf(struct rvu *rvu, struct rvu_block *block, u16 pcifunc, u16 slot)u16 match =0 ;int lf; -spin_lock (&rvu->rsrc_lock); +mutex_lock (&rvu->rsrc_lock);for (lf =0 ; lf < block->lf.max; lf++) {if (block->fn_map[lf] == pcifunc) {if (slot == match) { -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);return lf; } match++; } } -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);return -ENODEV ; }
@@ -597,6 +597,8 @@ static void rvu_free_hw_resources(struct rvu *rvu)dma_unmap_resource (rvu->dev, rvu->msix_base_iova, max_msix *PCI_MSIX_ENTRY_SIZE ,DMA_BIDIRECTIONAL ,0 ); + +mutex_destroy (&rvu->rsrc_lock); }static int rvu_setup_hw_resources (struct rvu *rvu)
@@ -752,7 +754,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)if (!rvu->hwvf)return -ENOMEM ; -spin_lock_init (&rvu->rsrc_lock); +mutex_init (&rvu->rsrc_lock); err =rvu_setup_msix_resources (rvu);if (err)
@@ -926,7 +928,7 @@ static int rvu_detach_rsrcs(struct rvu *rvu, struct rsrc_detach *detach,struct rvu_block *block;int blkid; -spin_lock (&rvu->rsrc_lock); +mutex_lock (&rvu->rsrc_lock);/* Check for partial resource detach */ if (detach && detach->partial)
@@ -956,7 +958,7 @@ static int rvu_detach_rsrcs(struct rvu *rvu, struct rsrc_detach *detach,rvu_detach_block (rvu, pcifunc, block->type); } -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);return 0 ; }
@@ -1119,7 +1121,7 @@ static int rvu_mbox_handler_attach_resources(struct rvu *rvu,if (!attach->modify)rvu_detach_rsrcs (rvu,NULL , pcifunc); -spin_lock (&rvu->rsrc_lock); +mutex_lock (&rvu->rsrc_lock);/* Check if the request can be accommodated */ err =rvu_check_rsrc_availability (rvu, attach, pcifunc);
@@ -1163,7 +1165,7 @@ static int rvu_mbox_handler_attach_resources(struct rvu *rvu, } exit: -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);return err; }
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +3 -3
@@ -64,7 +64,7 @@ struct nix_mcast {struct qmem *mcast_buf;int replay_pkind;int next_free_mce; -spinlock_t mce_lock;/* Serialize MCE updates */ +struct mutex mce_lock;/* Serialize MCE updates */ };struct nix_mce_list {
@@ -74,7 +74,7 @@ struct nix_mce_list { };struct npc_mcam { -spinlock_t lock;/* MCAM entries and counters update lock */ +struct mutex lock;/* MCAM entries and counters update lock */ u8 keysize;/* MCAM keysize 112/224/448 bits */ u8 banks;/* Number of MCAM banks */ u8 banks_per_entry;/* Number of keywords in key */
@@ -174,7 +174,7 @@ struct rvu {struct rvu_hwinfo *hw;struct rvu_pfvf *pf;struct rvu_pfvf *hwvf; -spinlock_t rsrc_lock;/* Serialize resource alloc/free */ +struct mutex rsrc_lock;/* Serialize resource alloc/free */ /* Mbox */ struct otx2_mbox mbox;
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +14 -13
@@ -109,12 +109,12 @@ static bool is_valid_txschq(struct rvu *rvu, int blkaddr,if (schq >= txsch->schq.max)return false; -spin_lock (&rvu->rsrc_lock); +mutex_lock (&rvu->rsrc_lock);if (txsch->pfvf_map[schq] != pcifunc) { -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);return false; } -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);return true; }
@@ -953,7 +953,7 @@ int rvu_mbox_handler_nix_txsch_alloc(struct rvu *rvu,if (!nix_hw)return -EINVAL ; -spin_lock (&rvu->rsrc_lock); +mutex_lock (&rvu->rsrc_lock);for (lvl =0 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) { txsch = &nix_hw->txsch[lvl]; req_schq = req->schq_contig[lvl] + req->schq[lvl];
@@ -1009,7 +1009,7 @@ int rvu_mbox_handler_nix_txsch_alloc(struct rvu *rvu, err: rc =NIX_AF_ERR_TLX_ALLOC_FAIL ; exit: -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);return rc; }
@@ -1034,7 +1034,7 @@ static int nix_txschq_free(struct rvu *rvu, u16 pcifunc)return NIX_AF_ERR_AF_LF_INVALID ;/* Disable TL2/3 queue links before SMQ flush*/ -spin_lock (&rvu->rsrc_lock); +mutex_lock (&rvu->rsrc_lock);for (lvl =NIX_TXSCH_LVL_TL4 ; lvl <NIX_TXSCH_LVL_CNT ; lvl++) {if (lvl !=NIX_TXSCH_LVL_TL2 && lvl !=NIX_TXSCH_LVL_TL4 )continue ;
@@ -1076,7 +1076,7 @@ static int nix_txschq_free(struct rvu *rvu, u16 pcifunc) txsch->pfvf_map[schq] =0 ; } } -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock);/* Sync cached info for this LF in NDC-TX to LLC/DRAM */ rvu_write64 (rvu, blkaddr,NIX_AF_NDC_TX_SYNC ,BIT_ULL (12 ) | nixlf);
@@ -1308,7 +1308,7 @@ static int nix_update_mce_list(struct nix_mce_list *mce_list,return 0 ;/* Add a new one to the list, at the tail */ - mce =kzalloc (sizeof (*mce),GFP_ATOMIC ); + mce =kzalloc (sizeof (*mce),GFP_KERNEL );if (!mce)return -ENOMEM ; mce->idx = idx;
@@ -1354,7 +1354,7 @@ static int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add)return -EINVAL ; } -spin_lock (&mcast->mce_lock); +mutex_lock (&mcast->mce_lock); err =nix_update_mce_list (mce_list, pcifunc, idx, add);if (err)
@@ -1384,7 +1384,7 @@ static int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add) } end: -spin_unlock (&mcast->mce_lock); +mutex_unlock (&mcast->mce_lock);return err; }
@@ -1469,7 +1469,7 @@ static int nix_setup_mcast(struct rvu *rvu, struct nix_hw *nix_hw, int blkaddr)BIT_ULL (63 ) | (mcast->replay_pkind <<24 ) | BIT_ULL(20) | MC_BUF_CNT); -spin_lock_init (&mcast->mce_lock); +mutex_init (&mcast->mce_lock);return nix_setup_bcast_tables (rvu, nix_hw); }
@@ -1869,7 +1869,7 @@ int rvu_mbox_handler_nix_set_hw_frs(struct rvu *rvu, struct nix_frs_cfg *req,/* Update min/maxlen in each of the SMQ attached to this PF/VF */ txsch = &nix_hw->txsch[NIX_TXSCH_LVL_SMQ ]; -spin_lock (&rvu->rsrc_lock); +mutex_lock (&rvu->rsrc_lock);for (schq =0 ; schq < txsch->schq.max; schq++) {if (txsch->pfvf_map[schq] != pcifunc)continue ;
@@ -1879,7 +1879,7 @@ int rvu_mbox_handler_nix_set_hw_frs(struct rvu *rvu, struct nix_frs_cfg *req, cfg = (cfg & ~0x7FULL ) | ((u64 )req->minlen &0x7F );rvu_write64 (rvu, blkaddr,NIX_AF_SMQX_CFG (schq), cfg); } -spin_unlock (&rvu->rsrc_lock); +mutex_unlock (&rvu->rsrc_lock); rx_frscfg:/* Check if config is for SDP link */
@@ -2162,5 +2162,6 @@ void rvu_nix_freemem(struct rvu *rvu) mcast = &nix_hw->mcast;qmem_free (rvu->dev, mcast->mce_ctx);qmem_free (rvu->dev, mcast->mcast_buf); +mutex_destroy (&mcast->mce_lock); } }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +3 -1
@@ -732,7 +732,7 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr) mcam->nixlf_offset = mcam->entries; mcam->pf_offset = mcam->nixlf_offset + nixlf_count; -spin_lock_init (&mcam->lock); +mutex_init (&mcam->lock);return 0 ; }
@@ -811,6 +811,8 @@ int rvu_npc_init(struct rvu *rvu)void rvu_npc_freemem (struct rvu *rvu) {struct npc_pkind *pkind = &rvu->hw->pkind; +struct npc_mcam *mcam = &rvu->hw->mcam;kfree (pkind->rsrc.bmap); +mutex_destroy (&mcam->lock); }
Signature · 1 line
2.7.4
David Miller
maintainerRe: [PATCH v2 04/21] octeontx2-af: Relax resource lock into mutex
From: [email protected]
Date: Thu, 15 Nov 2018 16:29:29 +0530
Quoted 9 lines
From: Stanislaw Kardach <[email protected]>
The resource locks does not need to be a spinlock as they are not used in any interrupt handling routines (only in bottom halves). Therefore relax them into a mutex so that later on we may use them in routines that might sleep.
Signed-off-by Stanislaw Kardach <[email protected]>Signed-off-by Sunil Goutham <[email protected]>
This is confusing because software interrupts are often called bottom halves, and in which sleeping and thus mutexes are not allowed.
Re: [PATCH v2 04/21] octeontx2-af: Relax resource lock into mutex
Quoted 11 lines · David Miller
From: [email protected]
Date: Thu, 15 Nov 2018 16:29:29 +0530Quoted 7 lines
From: Stanislaw Kardach <[email protected]>
The resource locks does not need to be a spinlock as they are not used in any interrupt handling routines (only in bottom halves). Therefore relax them into a mutex so that later on we may use them in routines that might sleep.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Stanislaw Kardach <[email protected]>Signed-off-by Sunil Goutham <[email protected]>This is confusing because software interrupts are often called bottom halves, and in which sleeping and thus mutexes are not allowed.
Mailbox message interrupt handler schedules workqueue and exits. Message handling happens in workqueue context, hence moving from spinlock to mutex.
Hope this clarifies.
Thanks,
Sunil.
David Miller
maintainerRe: [PATCH v2 04/21] octeontx2-af: Relax resource lock into mutex
From: Sunil Kovvuri <[email protected]>
Date: Sat, 17 Nov 2018 21:42:41 +0530
Quoted 15 lines · David Miller
Quoted 14 lines
From: [email protected]
Date: Thu, 15 Nov 2018 16:29:29 +0530Quoted 9 lines
From: Stanislaw Kardach <[email protected]>
The resource locks does not need to be a spinlock as they are not used in any interrupt handling routines (only in bottom halves). Therefore relax them into a mutex so that later on we may use them in routines that might sleep.
Signed-off-by Stanislaw Kardach <[email protected]>Signed-off-by Sunil Goutham <[email protected]>
Quoted 7 lines
Quoted 2 lines
This is confusing because software interrupts are often called bottom halves, and in which sleeping and thus mutexes are not allowed.
Mailbox message interrupt handler schedules workqueue and exits. Message handling happens in workqueue context, hence moving from spinlock to mutex.
Hope this clarifies.
Fix the commit message like this then.
PATCH v2 5/21 octeontx2-af: NPC MCAM entry alloc/free support
In reply to [email protected]From: Sunil Goutham <[email protected]>
This patch adds NPC MCAM entry management and support for allocating and freeing them via mailbox. Both contiguous and non-contiguous allocations are supported. Incase of contiguous, if request cannot be met then max contiguous number of available entries are allocated.
High or low priority index allocation w.r.t a reference MCAM index is also supported.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 49 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 19 +- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 11 + .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 514 ++++++++++++++++++++- 4 files changed, 588 insertions(+), 5 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +49 -0
@@ -149,6 +149,10 @@ M(NPA_HWCTX_DISABLE, 0x403, npa_hwctx_disable, hwctx_disable_req, msg_rsp)\/* TIM mbox IDs (range 0x800 - 0x9FF) */ \/* CPT mbox IDs (range 0xA00 - 0xBFF) */ \/* NPC mbox IDs (range 0x6000 - 0x7FFF) */ \ +M (NPC_MCAM_ALLOC_ENTRY ,0x6000 , npc_mcam_alloc_entry, npc_mcam_alloc_entry_req,\ + npc_mcam_alloc_entry_rsp) \ +M (NPC_MCAM_FREE_ENTRY ,0x6001 , npc_mcam_free_entry, \ + npc_mcam_free_entry_req, msg_rsp) \ /* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \M (NIX_LF_ALLOC ,0x8000 , nix_lf_alloc, \ nix_lf_alloc_req, nix_lf_alloc_rsp) \
@@ -353,6 +357,8 @@ struct hwctx_disable_req {u8 ctype; }; +/* NIX mbox message formats */ +/* NIX mailbox error codes * Range 401 - 500. */
@@ -541,4 +547,47 @@ struct nix_frs_cfg { u16 minlen; }; +/* NPC mbox message structs */ + +#define NPC_MCAM_ENTRY_INVALID 0xFFFF +#define NPC_MCAM_INVALID_MAP 0xFFFF + +/* NPC mailbox error codes +* Range 701 - 800. +*/ +enum npc_af_status { +NPC_MCAM_INVALID_REQ =-701 , +NPC_MCAM_ALLOC_DENIED =-702 , +NPC_MCAM_ALLOC_FAILED =-703 , +NPC_MCAM_PERM_DENIED =-704 , +}; + +struct npc_mcam_alloc_entry_req { +struct mbox_msghdr hdr; +#define NPC_MAX_NONCONTIG_ENTRIES 256 +u8 contig;/* Contiguous entries ? */ +#define NPC_MCAM_ANY_PRIO 0 +#define NPC_MCAM_LOWER_PRIO 1 +#define NPC_MCAM_HIGHER_PRIO 2 +u8 priority;/* Lower or higher w.r.t ref_entry */ +u16 ref_entry; +u16 count;/* Number of entries requested */ +}; + +struct npc_mcam_alloc_entry_rsp { +struct mbox_msghdr hdr; +u16 entry;/* Entry allocated or start index if contiguous. +* Invalid incase of non-contiguous. +*/ +u16 count;/* Number of entries allocated */ +u16 free_count;/* Number of entries available */ +u16 entry_list[NPC_MAX_NONCONTIG_ENTRIES ]; +}; + +struct npc_mcam_free_entry_req { +struct mbox_msghdr hdr; +u16 entry;/* Entry index to be freed */ +u8 all;/* If all entries allocated to this PFVF to be freed */ +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +18 -1
@@ -74,15 +74,25 @@ struct nix_mce_list { };struct npc_mcam { +struct rsrc_bmap counters;struct mutex lock;/* MCAM entries and counters update lock */ +unsigned long *bmap;/* bitmap, 0 => bmap_entries */ +unsigned long *bmap_reverse;/* Reverse bitmap, bmap_entries => 0 */ +u16 bmap_entries;/* Number of unreserved MCAM entries */ +u16 bmap_fcnt;/* MCAM entries free count */ +u16 *entry2pfvf_map; +u16 *cntr2pfvf_map;u8 keysize;/* MCAM keysize 112/224/448 bits */ u8 banks;/* Number of MCAM banks */ u8 banks_per_entry;/* Number of keywords in key */ u16 banksize;/* Number of MCAM entries in each bank */ u16 total_entries;/* Total number of MCAM entries */ -u16 entries;/* Total minus reserved for NIX LFs */ u16 nixlf_offset;/* Offset of nixlf rsvd uncast entries */ u16 pf_offset;/* Offset of PF's rsvd bcast, promisc entries */ +u16 lprio_count; +u16 lprio_start; +u16 hprio_count; +u16 hprio_end; };/* Structure for per RVU func info ie PF/VF */
@@ -315,6 +325,7 @@ int rvu_mbox_handler_npa_lf_free(struct rvu *rvu, struct msg_req *req, struct msg_rsp *rsp);/* NIX APIs */ +bool is_nixlf_attached (struct rvu *rvu,u16 pcifunc);int rvu_nix_init (struct rvu *rvu);void rvu_nix_freemem (struct rvu *rvu);int rvu_get_nixlf_count (struct rvu *rvu);
@@ -369,4 +380,10 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,void rvu_npc_disable_mcam_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_update_flowkey_alg_idx (struct rvu *rvu,u16 pcifunc,int nixlf,int group,int alg_idx,int mcam_index); +int rvu_mbox_handler_npc_mcam_alloc_entry (struct rvu *rvu, +struct npc_mcam_alloc_entry_req *req, +struct npc_mcam_alloc_entry_rsp *rsp); +int rvu_mbox_handler_npc_mcam_free_entry (struct rvu *rvu, +struct npc_mcam_free_entry_req *req, +struct msg_rsp *rsp);#endif /* RVU_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +11 -0
@@ -55,6 +55,17 @@ struct mce {u16 pcifunc; }; +bool is_nixlf_attached (struct rvu *rvu,u16 pcifunc) +{ +struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc); +int blkaddr; + + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NIX , pcifunc); +if (!pfvf->nixlf || blkaddr <0 ) +return false; +return true; +} +int rvu_get_nixlf_count (struct rvu *rvu) {struct rvu_block *block;
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +510 -4
566 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 6/21 octeontx2-af: MCAM entry installation support
In reply to [email protected]From: Sunil Goutham <[email protected]>
Add support for a RVU PF/VF to enable, disable, configure and shuffle MCAM entries via mbox commands. This patch adds mailbox message formats and handling of these commands.
As of now otherthan validating MCAM entry index, info like channel number e.t.c in MCAM config data sent by PF/VF are not validated.
Also a max of 64 MCAM entries can be shuffled with a single mbox command.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 45 ++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 12 ++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 179 ++++++++++++++++++++- 3 files changed, 228 insertions(+), 8 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +45 -0
@@ -153,6 +153,14 @@ M(NPC_MCAM_ALLOC_ENTRY, 0x6000, npc_mcam_alloc_entry, npc_mcam_alloc_entry_req,\ npc_mcam_alloc_entry_rsp) \ M(NPC_MCAM_FREE_ENTRY, 0x6001, npc_mcam_free_entry, \ npc_mcam_free_entry_req, msg_rsp) \ +M(NPC_MCAM_WRITE_ENTRY, 0x6002, npc_mcam_write_entry, \ + npc_mcam_write_entry_req, msg_rsp) \ +M(NPC_MCAM_ENA_ENTRY, 0x6003, npc_mcam_ena_entry, \ + npc_mcam_ena_dis_entry_req, msg_rsp) \ +M(NPC_MCAM_DIS_ENTRY, 0x6004, npc_mcam_dis_entry, \ + npc_mcam_ena_dis_entry_req, msg_rsp) \ +M(NPC_MCAM_SHIFT_ENTRY, 0x6005, npc_mcam_shift_entry, npc_mcam_shift_entry_req,\ + npc_mcam_shift_entry_rsp) \ /* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \ M(NIX_LF_ALLOC, 0x8000, nix_lf_alloc, \ nix_lf_alloc_req, nix_lf_alloc_rsp) \
@@ -590,4 +598,41 @@ struct npc_mcam_free_entry_req { u8 all; /* If all entries allocated to this PFVF to be freed */ }; +struct mcam_entry { +#define NPC_MAX_KWS_IN_KEY 7/* Number of keywords in max keywidth */ +u64 kw[NPC_MAX_KWS_IN_KEY ]; +u64 kw_mask[NPC_MAX_KWS_IN_KEY ]; +u64 action; +u64 vtag_action; +}; + +struct npc_mcam_write_entry_req { +struct mbox_msghdr hdr; +struct mcam_entry entry_data; +u16 entry;/* MCAM entry to write this match key */ +u16 cntr;/* Counter for this MCAM entry */ +u8 intf;/* Rx or Tx interface */ +u8 enable_entry;/* Enable this MCAM entry ? */ +u8 set_cntr;/* Set counter for this entry ? */ +}; + +/* Enable/Disable a given entry */ +struct npc_mcam_ena_dis_entry_req { +struct mbox_msghdr hdr; +u16 entry; +}; + +struct npc_mcam_shift_entry_req { +struct mbox_msghdr hdr; +#define NPC_MCAM_MAX_SHIFTS 64 +u16 curr_entry[NPC_MCAM_MAX_SHIFTS ]; +u16 new_entry[NPC_MCAM_MAX_SHIFTS ]; +u16 shift_count;/* Number of entries to shift */ +}; + +struct npc_mcam_shift_entry_rsp { +struct mbox_msghdr hdr; +u16 failed_entry_idx;/* Index in 'curr_entry', not entry itself */ +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +12 -0
@@ -386,4 +386,16 @@ int rvu_mbox_handler_npc_mcam_alloc_entry(struct rvu *rvu,int rvu_mbox_handler_npc_mcam_free_entry (struct rvu *rvu,struct npc_mcam_free_entry_req *req,struct msg_rsp *rsp); +int rvu_mbox_handler_npc_mcam_write_entry (struct rvu *rvu, +struct npc_mcam_write_entry_req *req, +struct msg_rsp *rsp); +int rvu_mbox_handler_npc_mcam_ena_entry (struct rvu *rvu, +struct npc_mcam_ena_dis_entry_req *req, +struct msg_rsp *rsp); +int rvu_mbox_handler_npc_mcam_dis_entry (struct rvu *rvu, +struct npc_mcam_ena_dis_entry_req *req, +struct msg_rsp *rsp); +int rvu_mbox_handler_npc_mcam_shift_entry (struct rvu *rvu, +struct npc_mcam_shift_entry_req *req, +struct npc_mcam_shift_entry_rsp *rsp);#endif /* RVU_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +171 -8
194 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 7/21 octeontx2-af: Support for NPC MCAM counters
In reply to [email protected]From: Sunil Goutham <[email protected]>
NPC HW has counters which can be mapped to MCAM entries to gather entry match statistics. This patch adds support to allocate, free, clear and retrieve stats of NPC MCAM counters. New mailbox messages have been added for this. Similar to MCAM entries both contiguous and non-contiguous counter allocation is supported.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 36 ++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 10 ++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 144 +++++++++++++++++++++ 3 files changed, 190 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +36 -0
@@ -161,6 +161,16 @@ M(NPC_MCAM_DIS_ENTRY, 0x6004, npc_mcam_dis_entry, \ npc_mcam_ena_dis_entry_req, msg_rsp) \ M(NPC_MCAM_SHIFT_ENTRY, 0x6005, npc_mcam_shift_entry, npc_mcam_shift_entry_req,\ npc_mcam_shift_entry_rsp) \ +M(NPC_MCAM_ALLOC_COUNTER, 0x6006, npc_mcam_alloc_counter, \ + npc_mcam_alloc_counter_req, \ + npc_mcam_alloc_counter_rsp) \ +M(NPC_MCAM_FREE_COUNTER, 0x6007, npc_mcam_free_counter, \ + npc_mcam_oper_counter_req, msg_rsp) \ +M(NPC_MCAM_CLEAR_COUNTER, 0x6009, npc_mcam_clear_counter, \ + npc_mcam_oper_counter_req, msg_rsp) \ +M(NPC_MCAM_COUNTER_STATS, 0x600a, npc_mcam_counter_stats, \ + npc_mcam_oper_counter_req, \ + npc_mcam_oper_counter_rsp) \/* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \M (NIX_LF_ALLOC ,0x8000 , nix_lf_alloc, \ nix_lf_alloc_req, nix_lf_alloc_rsp) \
@@ -635,4 +645,30 @@ struct npc_mcam_shift_entry_rsp { u16 failed_entry_idx; /* Index in 'curr_entry', not entry itself */ }; +struct npc_mcam_alloc_counter_req { +struct mbox_msghdr hdr; +u8 contig;/* Contiguous counters ? */ +#define NPC_MAX_NONCONTIG_COUNTERS 64 +u16 count;/* Number of counters requested */ +}; + +struct npc_mcam_alloc_counter_rsp { +struct mbox_msghdr hdr; +u16 cntr;/* Counter allocated or start index if contiguous. +* Invalid incase of non-contiguous. +*/ +u16 count;/* Number of counters allocated */ +u16 cntr_list[NPC_MAX_NONCONTIG_COUNTERS ]; +}; + +struct npc_mcam_oper_counter_req { +struct mbox_msghdr hdr; +u16 cntr;/* Free a counter or clear/fetch it's stats */ +}; + +struct npc_mcam_oper_counter_rsp { +struct mbox_msghdr hdr; +u64 stat;/* valid only while fetching counter's stats */ +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +10 -0
@@ -398,4 +398,14 @@ int rvu_mbox_handler_npc_mcam_dis_entry(struct rvu *rvu,int rvu_mbox_handler_npc_mcam_shift_entry (struct rvu *rvu,struct npc_mcam_shift_entry_req *req,struct npc_mcam_shift_entry_rsp *rsp); +int rvu_mbox_handler_npc_mcam_alloc_counter (struct rvu *rvu, +struct npc_mcam_alloc_counter_req *req, +struct npc_mcam_alloc_counter_rsp *rsp); +int rvu_mbox_handler_npc_mcam_free_counter (struct rvu *rvu, +struct npc_mcam_oper_counter_req *req,struct msg_rsp *rsp); +int rvu_mbox_handler_npc_mcam_clear_counter (struct rvu *rvu, +struct npc_mcam_oper_counter_req *req,struct msg_rsp *rsp); +int rvu_mbox_handler_npc_mcam_counter_stats (struct rvu *rvu, +struct npc_mcam_oper_counter_req *req, +struct npc_mcam_oper_counter_rsp *rsp);#endif /* RVU_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +144 -0
153 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 8/21 octeontx2-af: Map or unmap NPC MCAM entry and counter
In reply to [email protected]From: Sunil Goutham <[email protected]>
Alloc memory to save MCAM 'entry to counter' mapping and since multiple entries can map to same counter, added counter's reference count tracking.
Do 'entry to counter' mapping when a entry is being installed and mbox msg sender requested to configure a counter as well. Mapping is removed when a entry or counter is being freed or a explicit mbox msg is received to unmap them.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 9 + drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 4 + .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 183 ++++++++++++++++++++- 3 files changed, 192 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +9 -0
@@ -166,6 +166,8 @@ M(NPC_MCAM_ALLOC_COUNTER, 0x6006, npc_mcam_alloc_counter, \ npc_mcam_alloc_counter_rsp) \ M(NPC_MCAM_FREE_COUNTER, 0x6007, npc_mcam_free_counter, \ npc_mcam_oper_counter_req, msg_rsp) \ +M(NPC_MCAM_UNMAP_COUNTER, 0x6008, npc_mcam_unmap_counter, \ + npc_mcam_unmap_counter_req, msg_rsp) \ M(NPC_MCAM_CLEAR_COUNTER, 0x6009, npc_mcam_clear_counter, \ npc_mcam_oper_counter_req, msg_rsp) \ M(NPC_MCAM_COUNTER_STATS, 0x600a, npc_mcam_counter_stats, \
@@ -671,4 +673,11 @@ struct npc_mcam_oper_counter_rsp { u64 stat; /* valid only while fetching counter's stats */ }; +struct npc_mcam_unmap_counter_req { +struct mbox_msghdr hdr; +u16 cntr; +u16 entry;/* Entry and counter to be unmapped */ +u8 all;/* Unmap all entries using this counter ? */ +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +4 -0
@@ -81,7 +81,9 @@ struct npc_mcam {u16 bmap_entries;/* Number of unreserved MCAM entries */ u16 bmap_fcnt;/* MCAM entries free count */ u16 *entry2pfvf_map; +u16 *entry2cntr_map;u16 *cntr2pfvf_map; +u16 *cntr_refcnt;u8 keysize;/* MCAM keysize 112/224/448 bits */ u8 banks;/* Number of MCAM banks */ u8 banks_per_entry;/* Number of keywords in key */
@@ -405,6 +407,8 @@ int rvu_mbox_handler_npc_mcam_free_counter(struct rvu *rvu, struct npc_mcam_oper_counter_req *req, struct msg_rsp *rsp);int rvu_mbox_handler_npc_mcam_clear_counter (struct rvu *rvu,struct npc_mcam_oper_counter_req *req,struct msg_rsp *rsp); +int rvu_mbox_handler_npc_mcam_unmap_counter (struct rvu *rvu, +struct npc_mcam_unmap_counter_req *req,struct msg_rsp *rsp);int rvu_mbox_handler_npc_mcam_counter_stats (struct rvu *rvu,struct npc_mcam_oper_counter_req *req,struct npc_mcam_oper_counter_rsp *rsp);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +179 -4
284 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 9/21 octeontx2-af: Alloc and config NPC MCAM entry at a time
In reply to [email protected]From: Sunil Goutham <[email protected]>
A new mailbox message is added to support allocating a MCAM entry along with a counter and configuring it in one go. This reduces the amount of mailbox communication involved in installing a new MCAM rule.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 19 ++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 3 + .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 72 ++++++++++++++++++++++ 3 files changed, 94 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +19 -0
@@ -173,6 +173,9 @@ M(NPC_MCAM_CLEAR_COUNTER, 0x6009, npc_mcam_clear_counter, \M (NPC_MCAM_COUNTER_STATS ,0x600a , npc_mcam_counter_stats, \ npc_mcam_oper_counter_req, \ npc_mcam_oper_counter_rsp) \ +M (NPC_MCAM_ALLOC_AND_WRITE_ENTRY ,0x600b , npc_mcam_alloc_and_write_entry, \ + npc_mcam_alloc_and_write_entry_req, \ + npc_mcam_alloc_and_write_entry_rsp) \ /* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \M (NIX_LF_ALLOC ,0x8000 , nix_lf_alloc, \ nix_lf_alloc_req, nix_lf_alloc_rsp) \
@@ -680,4 +683,20 @@ struct npc_mcam_unmap_counter_req { u8 all; /* Unmap all entries using this counter ? */ }; +struct npc_mcam_alloc_and_write_entry_req { +struct mbox_msghdr hdr; +struct mcam_entry entry_data; +u16 ref_entry; +u8 priority;/* Lower or higher w.r.t ref_entry */ +u8 intf;/* Rx or Tx interface */ +u8 enable_entry;/* Enable this MCAM entry ? */ +u8 alloc_cntr;/* Allocate counter and map ? */ +}; + +struct npc_mcam_alloc_and_write_entry_rsp { +struct mbox_msghdr hdr; +u16 entry; +u16 cntr; +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +3 -0
@@ -412,4 +412,7 @@ int rvu_mbox_handler_npc_mcam_unmap_counter(struct rvu *rvu,int rvu_mbox_handler_npc_mcam_counter_stats (struct rvu *rvu,struct npc_mcam_oper_counter_req *req,struct npc_mcam_oper_counter_rsp *rsp); +int rvu_mbox_handler_npc_mcam_alloc_and_write_entry (struct rvu *rvu, +struct npc_mcam_alloc_and_write_entry_req *req, +struct npc_mcam_alloc_and_write_entry_rsp *rsp);#endif /* RVU_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +72 -0
75 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 10/21 octeontx2-af: Add MKEX default profile
In reply to [email protected]From: Santosh Shukla <[email protected]>
Added basic default MKEX profile. This profile tells hardware what data to extract from packet and where to place it (bit offset) in final KEY generated for the parsed packet. Based on the bit placement of the packet data, MCAM entries have to programmed for matching.
Also added a msg to retrieve this MKEX profile from PF/VF which inturn can process it to determine how MCAM entry has to be populated.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 19 +++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 + .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 155 +++++++++++++++++---- 3 files changed, 151 insertions(+), 25 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +19 -0
@@ -176,6 +176,8 @@ M(NPC_MCAM_COUNTER_STATS, 0x600a, npc_mcam_counter_stats, \M (NPC_MCAM_ALLOC_AND_WRITE_ENTRY ,0x600b , npc_mcam_alloc_and_write_entry, \ npc_mcam_alloc_and_write_entry_req, \ npc_mcam_alloc_and_write_entry_rsp) \ +M (NPC_GET_KEX_CFG ,0x600c , npc_get_kex_cfg, \ + msg_req, npc_get_kex_cfg_rsp) \ /* NIX mbox IDs (range 0x8000 - 0xFFFF) */ \M (NIX_LF_ALLOC ,0x8000 , nix_lf_alloc, \ nix_lf_alloc_req, nix_lf_alloc_rsp) \
@@ -699,4 +701,21 @@ struct npc_mcam_alloc_and_write_entry_rsp { u16 cntr; }; +struct npc_get_kex_cfg_rsp { +struct mbox_msghdr hdr; +u64 rx_keyx_cfg;/* NPC_AF_INTF(0)_KEX_CFG */ +u64 tx_keyx_cfg;/* NPC_AF_INTF(1)_KEX_CFG */ +#define NPC_MAX_INTF 2 +#define NPC_MAX_LID 8 +#define NPC_MAX_LT 16 +#define NPC_MAX_LD 2 +#define NPC_MAX_LFL 16 +/* NPC_AF_KEX_LDATA(0..1)_FLAGS_CFG */ +u64 kex_ld_flags[NPC_MAX_LD ]; +/* NPC_AF_INTF(0..1)_LID(0..7)_LT(0..15)_LD(0..1)_CFG */ +u64 intf_lid_lt_ld[NPC_MAX_INTF ][NPC_MAX_LID ][NPC_MAX_LT ][NPC_MAX_LD ]; +/* NPC_AF_INTF(0..1)_LDATA(0..1)_FLAGS(0..15)_CFG */ +u64 intf_ld_flags[NPC_MAX_INTF ][NPC_MAX_LD ][NPC_MAX_LFL ]; +}; +#endif /* MBOX_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
@@ -415,4 +415,6 @@ int rvu_mbox_handler_npc_mcam_counter_stats(struct rvu *rvu,int rvu_mbox_handler_npc_mcam_alloc_and_write_entry (struct rvu *rvu,struct npc_mcam_alloc_and_write_entry_req *req,struct npc_mcam_alloc_and_write_entry_rsp *rsp); +int rvu_mbox_handler_npc_get_kex_cfg (struct rvu *rvu,struct msg_req *req, +struct npc_get_kex_cfg_rsp *rsp);#endif /* RVU_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +130 -25
197 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 11/21 octeontx2-af: Support to enable/disable default MCAM entries
In reply to [email protected]From: Sunil Goutham <[email protected]>
For a PF/VF with a NIXLF attached has default/reserved MCAM entries for receiving Ucast/Bcast/Promisc traffic. Ideally traffic should be forwarded to NIXLF only after it's contexts are initialized. This patch keeps these default entries disabled and adds mbox messages for a PF/VF to enable these once NPA/NIXLF initialization is done. Likewise while PF/VF is being teared down, it can send the disable mailbox message to stop receiving traffic.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 4 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 7 ++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 48 ++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 91 +++++++++++++++------- 4 files changed, 122 insertions(+), 28 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +3 -1
@@ -195,7 +195,9 @@ M(NIX_RSS_FLOWKEY_CFG, 0x8009, nix_rss_flowkey_cfg, \ nix_rss_flowkey_cfg, msg_rsp) \ M(NIX_SET_MAC_ADDR, 0x800a, nix_set_mac_addr, nix_set_mac_addr, msg_rsp) \ M(NIX_SET_RX_MODE, 0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp) \ -M(NIX_SET_HW_FRS, 0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp) +M(NIX_SET_HW_FRS, 0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp) \ +M(NIX_LF_START_RX, 0x800d, nix_lf_start_rx, msg_req, msg_rsp) \ +M(NIX_LF_STOP_RX, 0x800e, nix_lf_stop_rx, msg_req, msg_rsp)/* Messages initiated by AF (range 0xC00 - 0xDFF) */ #define MBOX_UP_CGX_MESSAGES \
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +7 -0
@@ -366,6 +366,10 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req, struct msg_rsp *rsp);int rvu_mbox_handler_nix_set_hw_frs (struct rvu *rvu,struct nix_frs_cfg *req,struct msg_rsp *rsp); +int rvu_mbox_handler_nix_lf_start_rx (struct rvu *rvu,struct msg_req *req, +struct msg_rsp *rsp); +int rvu_mbox_handler_nix_lf_stop_rx (struct rvu *rvu,struct msg_req *req, +struct msg_rsp *rsp);/* NPC APIs */ int rvu_npc_init (struct rvu *rvu);
@@ -377,9 +381,12 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,void rvu_npc_install_promisc_entry (struct rvu *rvu,u16 pcifunc,int nixlf,u64 chan,bool allmulti);void rvu_npc_disable_promisc_entry (struct rvu *rvu,u16 pcifunc,int nixlf); +void rvu_npc_enable_promisc_entry (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_install_bcast_match_entry (struct rvu *rvu,u16 pcifunc,int nixlf,u64 chan);void rvu_npc_disable_mcam_entries (struct rvu *rvu,u16 pcifunc,int nixlf); +void rvu_npc_disable_default_entries (struct rvu *rvu,u16 pcifunc,int nixlf); +void rvu_npc_enable_default_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_update_flowkey_alg_idx (struct rvu *rvu,u16 pcifunc,int nixlf,int group,int alg_idx,int mcam_index); int rvu_mbox_handler_npc_mcam_alloc_entry(struct rvu *rvu,
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +48 -0
57 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +64 -27
118 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 12/21 octeontx2-af: Add support for stripping STAG/CTAG
In reply to [email protected]From: Tomasz Duszynski <[email protected]>
This works by shadowing existing UCAST MCAM entry
with a new one additionally matching either NPC_LT_LB_CTAG or NPC_LT_LB_STAG. For this to fully work one needs to send properly configured NIX_VTAG_CFG message afterwards i.e with strip and capture enabled and type set to 0.
On receiving tagged packet NIX will remove outer VLAN and capture TCI in NIX_RX_PARSE_S.
Also simplified RX Vtag configuration flow
With this setting STRIP/CAPTURE VTAG actions separately would be possible. Following combinations are possible: STRIP,
STRIP and CAPTURE, CAPTURE or nothing (0 disables respective actions).
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 6 +- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 6 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 8 +++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 83 +++++++++++++++++----- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 43 ++++++++++- 5 files changed, 125 insertions(+), 21 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +4 -2
@@ -197,7 +197,8 @@ M(NIX_SET_MAC_ADDR, 0x800a, nix_set_mac_addr, nix_set_mac_addr, msg_rsp) \ M(NIX_SET_RX_MODE, 0x800b, nix_set_rx_mode, nix_rx_mode, msg_rsp) \ M(NIX_SET_HW_FRS, 0x800c, nix_set_hw_frs, nix_frs_cfg, msg_rsp) \ M(NIX_LF_START_RX, 0x800d, nix_lf_start_rx, msg_req, msg_rsp) \ -M (NIX_LF_STOP_RX ,0x800e , nix_lf_stop_rx, msg_req, msg_rsp) +M(NIX_LF_STOP_RX, 0x800e, nix_lf_stop_rx, msg_req, msg_rsp) \ +M (NIX_RXVLAN_ALLOC ,0x8012 , nix_rxvlan_alloc, msg_req, msg_rsp) /* Messages initiated by AF (range 0xC00 - 0xDFF) */#define MBOX_UP_CGX_MESSAGES \
@@ -515,6 +516,7 @@ struct nix_txschq_config {struct nix_vtag_config {struct mbox_msghdr hdr; +/* '0' for 4 octet VTAG, '1' for 8 octet VTAG */ u8 vtag_size;/* cfg_type is '0' for tx vlan cfg * cfg_type is '1' for rx vlan cfg
@@ -535,7 +537,7 @@ struct nix_vtag_config {/* valid when cfg_type is '1' */ struct { -/* rx vtag type index */ +/* rx vtag type index, valid values are in 0..7 range */ u8 vtag_type;/* rx vtag strip */ u8 strip_vtag :1 ;
drivers/net/ethernet/marvell/octeontx2/af/npc.h +6 -0
@@ -259,4 +259,10 @@ struct nix_rx_action { #endif }; +/* NIX Receive Vtag Action Structure */ +#define VTAG0_VALID_BIT BIT_ULL(15) +#define VTAG0_TYPE_MASK GENMASK_ULL(14, 12) +#define VTAG0_LID_MASK GENMASK_ULL(10, 8) +#define VTAG0_RELPTR_MASK GENMASK_ULL(7, 0) +#endif /* NPC_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +8 -0
@@ -142,6 +142,11 @@ struct rvu_pfvf {/* Broadcast pkt replication info */ u16 bcast_mce_idx;struct nix_mce_list bcast_mce_list; + +/* VLAN offload */ +struct mcam_entry entry; +int rxvlan_index; +bool rxvlan; };struct nix_txsch {
@@ -356,6 +361,8 @@ int rvu_mbox_handler_nix_stats_rst(struct rvu *rvu, struct msg_req *req,int rvu_mbox_handler_nix_vtag_cfg (struct rvu *rvu,struct nix_vtag_config *req,struct msg_rsp *rsp); +int rvu_mbox_handler_nix_rxvlan_alloc (struct rvu *rvu,struct msg_req *req, +struct msg_rsp *rsp);int rvu_mbox_handler_nix_rss_flowkey_cfg (struct rvu *rvu,struct nix_rss_flowkey_cfg *req,struct msg_rsp *rsp);
@@ -384,6 +391,7 @@ void rvu_npc_disable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);void rvu_npc_enable_promisc_entry (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_install_bcast_match_entry (struct rvu *rvu,u16 pcifunc,int nixlf,u64 chan); +int rvu_npc_update_rxvlan (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_disable_mcam_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_disable_default_entries (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_enable_default_entries (struct rvu *rvu,u16 pcifunc,int nixlf);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +65 -18
117 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +42 -1
82 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 13/21 octeontx2-af: Verify NPA/SSO/NIX PF_FUNC mapping
In reply to [email protected]From: Sunil Goutham <[email protected]>
While mapping a NIX LF to a NPA LF attached PF_FUNC or SSO LF attached PF_FUNC, verify if PF_FUNC is valid and if that PF_FUNC has a LF of that block attached to it or not.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 2 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 38 ++++++++++++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 1 + .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 32 +++++++++++------- 4 files changed, 62 insertions(+), 11 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +2 -0
@@ -405,6 +405,8 @@ enum nix_af_status {NIX_AF_INVAL_TXSCHQ_CFG =-412 ,NIX_AF_SMQ_FLUSH_FAILED =-413 ,NIX_AF_ERR_LF_RESET =-414 , +NIX_AF_INVAL_NPA_PF_FUNC =-419 , + NIX_AF_INVAL_SSO_PF_FUNC = -420, };/* For NIX LF context alloc and init */
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +38 -0
@@ -337,6 +337,28 @@ struct rvu_pfvf *rvu_get_pfvf(struct rvu *rvu, int pcifunc)return &rvu->pf[rvu_get_pf (pcifunc)]; } +static bool is_pf_func_valid (struct rvu *rvu,u16 pcifunc) +{ +int pf, vf, nvfs; +u64 cfg; + + pf =rvu_get_pf (pcifunc); +if (pf >= rvu->hw->total_pfs) +return false; + +if (!(pcifunc &RVU_PFVF_FUNC_MASK )) +return true; + +/* Check if VF is within number of VFs attached to this PF */ + vf = (pcifunc &RVU_PFVF_FUNC_MASK ) -1 ; + cfg =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_CFG (pf)); + nvfs = (cfg >>12 ) &0xFF ; +if (vf >= nvfs) +return false; + +return true; +} +bool is_block_implemented (struct rvu_hwinfo *hw,int blkaddr) {struct rvu_block *block;
@@ -860,6 +882,22 @@ static u16 rvu_get_rsrc_mapcount(struct rvu_pfvf *pfvf, int blktype)return 0 ; } +bool is_pffunc_map_valid (struct rvu *rvu,u16 pcifunc,int blktype) +{ +struct rvu_pfvf *pfvf; + +if (!is_pf_func_valid (rvu, pcifunc)) +return false; + + pfvf =rvu_get_pfvf (rvu, pcifunc); + +/* Check if this PFFUNC has a LF of type blktype attached */ +if (!rvu_get_rsrc_mapcount (pfvf, blktype)) +return false; + +return true; +} +static int rvu_lookup_rsrc (struct rvu *rvu,struct rvu_block *block,int pcifunc,int slot) {
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +1 -0
@@ -255,6 +255,7 @@ int rvu_get_pf(u16 pcifunc);struct rvu_pfvf *rvu_get_pfvf (struct rvu *rvu,int pcifunc);void rvu_get_pf_numvfs (struct rvu *rvu,int pf,int *numvfs,int *hwvf);bool is_block_implemented (struct rvu_hwinfo *hw,int blkaddr); +bool is_pffunc_map_valid (struct rvu *rvu,u16 pcifunc,int blktype);int rvu_get_lf (struct rvu *rvu,struct rvu_block *block,u16 pcifunc,u16 slot);int rvu_lf_reset (struct rvu *rvu,struct rvu_block *block,int lf);int rvu_get_blkaddr (struct rvu *rvu,int blktype,u16 pcifunc);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +21 -11
@@ -694,6 +694,24 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,if (nixlf <0 )return NIX_AF_ERR_AF_LF_INVALID ; +/* Check if requested 'NIXLF <=> NPALF' mapping is valid */ +if (req->npa_func) { +/* If default, use 'this' NIXLF's PFFUNC */ +if (req->npa_func ==RVU_DEFAULT_PF_FUNC ) + req->npa_func = pcifunc; +if (!is_pffunc_map_valid (rvu, req->npa_func,BLKTYPE_NPA )) +return NIX_AF_INVAL_NPA_PF_FUNC ; + } + +/* Check if requested 'NIXLF <=> SSOLF' mapping is valid */ +if (req->sso_func) { +/* If default, use 'this' NIXLF's PFFUNC */ +if (req->sso_func ==RVU_DEFAULT_PF_FUNC ) + req->sso_func = pcifunc; +if (!is_pffunc_map_valid (rvu, req->sso_func,BLKTYPE_SSO )) +return NIX_AF_INVAL_SSO_PF_FUNC ; + } +/* If RSS is being enabled, check if requested config is valid. * RSS table size should be power of two, otherwise * RSS_GRP::OFFSET + adder might go beyond that group or
@@ -798,18 +816,10 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,/* Enable LMTST for this NIX LF */ rvu_write64 (rvu, blkaddr,NIX_AF_LFX_TX_CFG2 (nixlf),BIT_ULL (0 )); -/* Set CQE/WQE size, NPA_PF_FUNC for SQBs and also SSO_PF_FUNC -* If requester has sent a 'RVU_DEFAULT_PF_FUNC' use this NIX LF's -* PCIFUNC itself. -*/ -if (req->npa_func ==RVU_DEFAULT_PF_FUNC ) - cfg = pcifunc; -else +/* Set CQE/WQE size, NPA_PF_FUNC for SQBs and also SSO_PF_FUNC */ +if (req->npa_func) cfg = req->npa_func; - -if (req->sso_func ==RVU_DEFAULT_PF_FUNC ) - cfg |= (u64 )pcifunc <<16 ; -else +if (req->sso_func) cfg |= (u64 )req->sso_func <<16 ; cfg |= (u64 )req->xqe_sz <<33 ;
Signature · 1 line
2.7.4
PATCH v2 14/21 octeontx2-af: Add FLR interrupt handler
In reply to [email protected]From: Geetha sowjanya <[email protected]>
RVU admin function (AF) has all the priviliges to cleanup HW state when VFIO triggers a PCIe function level reset (FLR) due to either reset or a VM crash. FLR for RVU PF1-PFn will trigger an IRQ to AF.
This patch enables all RVU PF's FLR interrupts and registers a handler. Upon receiving an interrupt, a workqueue is scheduled to cleanup all hardware blocks being used by the PF which received the FLR.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 117 +++++++++++++++++++++++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 5 + 2 files changed, 121 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +116 -1
@@ -1601,6 +1601,44 @@ static void rvu_enable_mbox_intr(struct rvu *rvu) INTR_MASK(hw->total_pfs) & ~1ULL); } +static void rvu_flr_handler (struct work_struct *work) +{ + struct rvu_work *flrwork = container_of(work, struct rvu_work, work); +struct rvu *rvu = flrwork->rvu; +u16 pf; + + pf = flrwork - rvu->flr_wrk; + +/* Signal FLR finish */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFTRPEND ,BIT_ULL (pf)); + +/* Enable interrupt */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1S ,BIT_ULL (pf)); +} + +static irqreturn_t rvu_flr_intr_handler (int irq,void *rvu_irq) +{ +struct rvu *rvu = (struct rvu *)rvu_irq; +u64 intr; +u8 pf; + + intr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT ); + +for (pf =0 ; pf < rvu->hw->total_pfs; pf++) { +if (intr & (1ULL << pf)) { +/* PF is already dead do only AF related operations */ +queue_work (rvu->flr_wq, &rvu->flr_wrk[pf].work); +/* clear interrupt */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT , +BIT_ULL (pf)); +/* Disable the interrupt */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1C , +BIT_ULL (pf)); + } + } +return IRQ_HANDLED ; +} +static void rvu_unregister_interrupts (struct rvu *rvu) {int irq;
@@ -1609,6 +1647,10 @@ static void rvu_unregister_interrupts(struct rvu *rvu)rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFAF_MBOX_INT_ENA_W1C ,INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +/* Disable the PF FLR interrupt */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1C , +INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +for (irq =0 ; irq < rvu->num_vec; irq++) {if (rvu->irq_allocated[irq])free_irq (pci_irq_vector (rvu->pdev, irq), rvu);
@@ -1660,6 +1702,27 @@ static int rvu_register_interrupts(struct rvu *rvu)/* Enable mailbox interrupts from all PFs */ rvu_enable_mbox_intr (rvu); +/* Register FLR interrupt handler */ +sprintf (&rvu->irq_name[RVU_AF_INT_VEC_PFFLR *NAME_SIZE ], +"RVUAF FLR" ); + ret =request_irq (pci_irq_vector (rvu->pdev,RVU_AF_INT_VEC_PFFLR ), + rvu_flr_intr_handler,0 , + &rvu->irq_name[RVU_AF_INT_VEC_PFFLR *NAME_SIZE ], + rvu); +if (ret) { +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for FLR\n" ); + goto fail; + } + rvu->irq_allocated[RVU_AF_INT_VEC_PFFLR ] = true; + +/* Enable FLR interrupt for all PFs*/ +rvu_write64 (rvu,BLKADDR_RVUM , +RVU_AF_PFFLR_INT ,INTR_MASK (rvu->hw->total_pfs)); + +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1S , +INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +return 0 ; fail:
@@ -1667,6 +1730,51 @@ static int rvu_register_interrupts(struct rvu *rvu)return ret; } +static void rvu_flr_wq_destroy (struct rvu *rvu) +{ +if (rvu->flr_wq) { +flush_workqueue (rvu->flr_wq); +destroy_workqueue (rvu->flr_wq); + rvu->flr_wq =NULL ; + } +kfree (rvu->flr_wrk); +} + +static int rvu_flr_init (struct rvu *rvu) +{ +u64 cfg; +int pf; + +/* Enable FLR for all PFs*/ +for (pf =1 ; pf < rvu->hw->total_pfs; pf++) { + cfg =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_CFG (pf)); +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_CFG (pf), + cfg |BIT_ULL (22 )); + } + + rvu->flr_wq =alloc_workqueue ("rvu_afpf_flr" , +WQ_UNBOUND |WQ_HIGHPRI |WQ_MEM_RECLAIM , +1 ); +if (!rvu->flr_wq) +return -ENOMEM ; + + rvu->flr_wrk =devm_kcalloc (rvu->dev, rvu->hw->total_pfs, +sizeof (struct rvu_work ),GFP_KERNEL ); +if (!rvu->flr_wrk) { +destroy_workqueue (rvu->flr_wq); +return -ENOMEM ; + } + +for (pf =0 ; pf < rvu->hw->total_pfs; pf++) { + rvu->flr_wrk[pf].rvu = rvu; +INIT_WORK (&rvu->flr_wrk[pf].work, rvu_flr_handler); + } + +mutex_init (&rvu->flr_lock); + +return 0 ; +} +static int rvu_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct device *dev = &pdev->dev;
@@ -1737,11 +1845,17 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_mbox; - err =rvu_register_interrupts (rvu); + err =rvu_flr_init (rvu);if (err) goto err_cgx; + err =rvu_register_interrupts (rvu); +if (err) + goto err_flr; +return 0 ; +err_flr: +rvu_flr_wq_destroy (rvu); err_cgx:rvu_cgx_wq_destroy (rvu); err_mbox:
@@ -1765,6 +1879,7 @@ static void rvu_remove(struct pci_dev *pdev)struct rvu *rvu =pci_get_drvdata (pdev);rvu_unregister_interrupts (rvu); +rvu_flr_wq_destroy (rvu);rvu_cgx_wq_destroy (rvu);rvu_mbox_destroy (rvu);rvu_reset_all_blocks (rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +5 -0
@@ -200,6 +200,11 @@ struct rvu {struct rvu_work *mbox_wrk_up;struct workqueue_struct *mbox_wq; +/* PF FLR */ +struct rvu_work *flr_wrk; +struct workqueue_struct *flr_wq; +struct mutex flr_lock;/* Serialize FLRs */ +/* MSI-X */ u16 num_vec;char *irq_name;
Signature · 1 line
2.7.4
PATCH v2 15/21 octeontx2-af: Teardown NPA, NIX LF upon receiving FLR
In reply to [email protected]From: Geetha sowjanya <[email protected]>
Upon receiving FLR IRQ for a RVU PF, teardown or cleanup resources held by that PF_FUNC. This patch cleans up, NIX LF
- Stop ingress/egress traffic
- Disable NPC MCAM entries being used.
- Free Tx scheduler queues
- Disable RQ/SQ/CQ HW contexts
NPA LF
- Disable Pool/Aura HW contexts
In future teardown of SSO/SSOW/TIM/CPT will be added.
Also added a mailbox message for a RVU PF to request AF, to perform FLR for a RVU VF under it.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 8 +++ drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 82 +++++++++++++++++++++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 + .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 48 +++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npa.c | 17 +++++ 5 files changed, 156 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +8 -0
@@ -124,6 +124,7 @@ M(READY, 0x001, ready, msg_req, ready_msg_rsp) \ M(ATTACH_RESOURCES, 0x002, attach_resources, rsrc_attach, msg_rsp) \ M(DETACH_RESOURCES, 0x003, detach_resources, rsrc_detach, msg_rsp) \ M(MSIX_OFFSET, 0x004, msix_offset, msg_req, msix_offset_rsp) \ +M (VF_FLR ,0x006 , vf_flr, msg_req, msg_rsp) \ /* CGX mbox IDs (range 0x200 - 0x3FF) */ \ M(CGX_START_RXTX, 0x200, cgx_start_rxtx, msg_req, msg_rsp) \M (CGX_STOP_RXTX ,0x201 , cgx_stop_rxtx, msg_req, msg_rsp) \
@@ -229,6 +230,13 @@ struct msg_rsp {struct mbox_msghdr hdr; }; +/* RVU mailbox error codes +* Range 256 - 300. +*/ +enum rvu_af_status { +RVU_INVALID_VF_ID =-256 , +}; +struct ready_msg_rsp {struct mbox_msghdr hdr;u16 sclk_feq;/* SCLK frequency */
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +81 -1
107 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
@@ -325,6 +325,7 @@ int rvu_mbox_handler_cgx_intlbk_disable(struct rvu *rvu, struct msg_req *req,/* NPA APIs */ int rvu_npa_init (struct rvu *rvu);void rvu_npa_freemem (struct rvu *rvu); +void rvu_npa_lf_teardown (struct rvu *rvu,u16 pcifunc,int npalf);int rvu_mbox_handler_npa_aq_enq (struct rvu *rvu,struct npa_aq_enq_req *req,struct npa_aq_enq_rsp *rsp);
@@ -342,6 +343,7 @@ bool is_nixlf_attached(struct rvu *rvu, u16 pcifunc);int rvu_nix_init (struct rvu *rvu);void rvu_nix_freemem (struct rvu *rvu);int rvu_get_nixlf_count (struct rvu *rvu); +void rvu_nix_lf_teardown (struct rvu *rvu,u16 pcifunc,int blkaddr,int npalf);int rvu_mbox_handler_nix_lf_alloc (struct rvu *rvu,struct nix_lf_alloc_req *req,struct nix_lf_alloc_rsp *rsp);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +48 -0
57 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c +17 -0
@@ -470,3 +470,20 @@ void rvu_npa_freemem(struct rvu *rvu) block = &hw->block[blkaddr];rvu_aq_free (rvu, block->aq); } + +void rvu_npa_lf_teardown (struct rvu *rvu,u16 pcifunc,int npalf) +{ +struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc); +struct hwctx_disable_req ctx_req; + +/* Disable all pools */ + ctx_req.hdr.pcifunc = pcifunc; + ctx_req.ctype =NPA_AQ_CTYPE_POOL ; +npa_lf_hwctx_disable (rvu, &ctx_req); + +/* Disable all auras */ + ctx_req.ctype =NPA_AQ_CTYPE_AURA ; +npa_lf_hwctx_disable (rvu, &ctx_req); + +npa_ctx_free (rvu, pfvf); +}
Signature · 1 line
2.7.4
PATCH v2 16/21 octeontx2-af: Mbox communication support btw AF and it's VFs
In reply to [email protected]From: Tomasz Duszynski <[email protected]>
VFs attached to PFs other than AF can not communicate with AF directly. Instead they are supposed to first send message to the PF they are residing on and PF forwards it to the AF. Responses to messages are handled in the reverse order.
On the other hand if VFs are on AF (PF0) itself then direct mailbox communication is possible since there's no other PF in the way.
This patch addresses this particular case and adds support for handling it.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 295 +++++++++++++++------ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 17 +- .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 6 +- 3 files changed, 223 insertions(+), 95 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +208 -87
@@ -31,6 +31,15 @@ static void rvu_clear_msix_offset(struct rvu *rvu, struct rvu_pfvf *pfvf, struct rvu_block *block, int lf);static void __rvu_flr_handler (struct rvu *rvu,u16 pcifunc); +static int rvu_mbox_init (struct rvu *rvu,struct mbox_wq_info *mw, +int type,int num, +void (mbox_handler )(struct work_struct *), +void (mbox_up_handler )(struct work_struct *)); +enum { +TYPE_AFVF , +TYPE_AFPF , +}; +/* Supported devices */ static const struct pci_device_id rvu_id_table[] = { {PCI_DEVICE (PCI_VENDOR_ID_CAVIUM ,PCI_DEVID_OCTEONTX2_RVU_AF ) },
@@ -1341,9 +1350,11 @@ static int rvu_mbox_handler_vf_flr(struct rvu *rvu, struct msg_req *req,return 0 ; } -static int rvu_process_mbox_msg (struct rvu *rvu,int devid, +static int rvu_process_mbox_msg (struct otx2_mbox *mbox,int devid,struct mbox_msghdr *req) { +struct rvu *rvu =pci_get_drvdata (mbox->pdev); +/* Check if valid, if not reply with a invalid msg */ if (req->sig !=OTX2_MBOX_REQ_SIG ) goto bad_message;
@@ -1355,8 +1366,15 @@ static int rvu_process_mbox_msg(struct rvu *rvu, int devid,int err; \ \ rsp = (struct _rsp_type *)otx2_mbox_alloc_msg ( \ - &rvu->mbox, devid, \ + mbox, devid, \sizeof (struct _rsp_type )); \ +/* some handlers should complete even if reply */ \ +/* could not be allocated */ \ +if (!rsp && \ + _id !=MBOX_MSG_DETACH_RESOURCES && \ + _id !=MBOX_MSG_NIX_TXSCH_FREE && \ + _id !=MBOX_MSG_VF_FLR ) \ +return -ENOMEM ; \if (rsp) { \ rsp->hdr.id = _id; \ rsp->hdr.sig =OTX2_MBOX_RSP_SIG ; \
@@ -1374,29 +1392,38 @@ static int rvu_process_mbox_msg(struct rvu *rvu, int devid, } MBOX_MESSAGES#undef M -break ; + bad_message:default : -otx2_reply_invalid_msg (&rvu->mbox, devid, req->pcifunc, - req->id); +otx2_reply_invalid_msg (mbox, devid, req->pcifunc, req->id);return -ENODEV ; } } -static void rvu_mbox_handler (struct work_struct *work) +static void __rvu_mbox_handler (struct rvu_work *mwork,int type) { - struct rvu_work *mwork = container_of(work, struct rvu_work, work);struct rvu *rvu = mwork->rvu; +int offset, err, id, devid;struct otx2_mbox_dev *mdev;struct mbox_hdr *req_hdr;struct mbox_msghdr *msg; +struct mbox_wq_info *mw;struct otx2_mbox *mbox; -int offset, id, err; -u16 pf; - mbox = &rvu->mbox; - pf = mwork - rvu->mbox_wrk; - mdev = &mbox->dev[pf]; +switch (type) { +case TYPE_AFPF : + mw = &rvu->afpf_wq_info; +break ; +case TYPE_AFVF : + mw = &rvu->afvf_wq_info; +break ; +default : +return ; + } + + devid = mwork - mw->mbox_wrk; + mbox = &mw->mbox; + mdev = &mbox->dev[devid];/* Process received mbox messages */ req_hdr = mdev->mbase + mbox->rx_start;
@@ -1408,10 +1435,21 @@ static void rvu_mbox_handler(struct work_struct *work)for (id =0 ; id < req_hdr->num_msgs; id++) { msg = mdev->mbase + offset; -/* Set which PF sent this message based on mbox IRQ */ - msg->pcifunc &= ~(RVU_PFVF_PF_MASK <<RVU_PFVF_PF_SHIFT ); - msg->pcifunc |= (pf <<RVU_PFVF_PF_SHIFT ); - err =rvu_process_mbox_msg (rvu, pf, msg); +/* Set which PF/VF sent this message based on mbox IRQ */ +switch (type) { +case TYPE_AFPF : + msg->pcifunc &= + ~(RVU_PFVF_PF_MASK <<RVU_PFVF_PF_SHIFT ); + msg->pcifunc |= (devid <<RVU_PFVF_PF_SHIFT ); +break ; +case TYPE_AFVF : + msg->pcifunc &= + ~(RVU_PFVF_FUNC_MASK <<RVU_PFVF_FUNC_SHIFT ); + msg->pcifunc |= (devid <<RVU_PFVF_FUNC_SHIFT ) +1 ; +break ; + } + + err =rvu_process_mbox_msg (mbox, devid, msg);if (!err) { offset = mbox->rx_start + msg->next_msgoff;continue ;
@@ -1419,31 +1457,57 @@ static void rvu_mbox_handler(struct work_struct *work)if (msg->pcifunc &RVU_PFVF_FUNC_MASK )dev_warn (rvu->dev,"Error %d when processing message %s (0x%x) from PF%d:VF%d\n" , - err,otx2_mbox_id2name (msg->id), msg->id, pf, + err,otx2_mbox_id2name (msg->id), + msg->id, devid, (msg->pcifunc &RVU_PFVF_FUNC_MASK ) -1 );else dev_warn (rvu->dev,"Error %d when processing message %s (0x%x) from PF%d\n" , - err,otx2_mbox_id2name (msg->id), msg->id, pf); + err,otx2_mbox_id2name (msg->id), + msg->id, devid); } -/* Send mbox responses to PF */ -otx2_mbox_msg_send (mbox, pf); +/* Send mbox responses to VF/PF */ +otx2_mbox_msg_send (mbox, devid); } -static void rvu_mbox_up_handler (struct work_struct *work) +static inline void rvu_afpf_mbox_handler (struct work_struct *work) { struct rvu_work *mwork = container_of(work, struct rvu_work, work); + +__rvu_mbox_handler (mwork,TYPE_AFPF ); +} + +static inline void rvu_afvf_mbox_handler (struct work_struct *work) +{ + struct rvu_work *mwork = container_of(work, struct rvu_work, work); + +__rvu_mbox_handler (mwork,TYPE_AFVF ); +} + +static void __rvu_mbox_up_handler (struct rvu_work *mwork,int type) +{struct rvu *rvu = mwork->rvu;struct otx2_mbox_dev *mdev;struct mbox_hdr *rsp_hdr;struct mbox_msghdr *msg; +struct mbox_wq_info *mw;struct otx2_mbox *mbox; -int offset, id; -u16 pf; +int offset, id, devid; + +switch (type) { +case TYPE_AFPF : + mw = &rvu->afpf_wq_info; +break ; +case TYPE_AFVF : + mw = &rvu->afvf_wq_info; +break ; +default : +return ; + } - mbox = &rvu->mbox_up; - pf = mwork - rvu->mbox_wrk_up; - mdev = &mbox->dev[pf]; + devid = mwork - mw->mbox_wrk_up; + mbox = &mw->mbox_up; + mdev = &mbox->dev[devid]; rsp_hdr = mdev->mbase + mbox->rx_start;if (rsp_hdr->num_msgs ==0 ) {
@@ -1484,128 +1548,182 @@ static void rvu_mbox_up_handler(struct work_struct *work) mdev->msgs_acked++; } -otx2_mbox_reset (mbox,0 ); +otx2_mbox_reset (mbox, devid); } -static int rvu_mbox_init (struct rvu *rvu) +static inline void rvu_afpf_mbox_up_handler (struct work_struct *work) { -struct rvu_hwinfo *hw = rvu->hw; -void __iomem *hwbase =NULL ; + struct rvu_work *mwork = container_of(work, struct rvu_work, work); + +__rvu_mbox_up_handler (mwork,TYPE_AFPF ); +} + +static inline void rvu_afvf_mbox_up_handler (struct work_struct *work) +{ + struct rvu_work *mwork = container_of(work, struct rvu_work, work); + +__rvu_mbox_up_handler (mwork,TYPE_AFVF ); +} + +static int rvu_mbox_init (struct rvu *rvu,struct mbox_wq_info *mw, +int type,int num, +void (mbox_handler )(struct work_struct *), +void (mbox_up_handler )(struct work_struct *)) +{ +void __iomem *hwbase =NULL , *reg_base; +int err, i, dir, dir_up;struct rvu_work *mwork; +const char *name;u64 bar4_addr; -int err, pf; - rvu->mbox_wq =alloc_workqueue ("rvu_afpf_mailbox" , -WQ_UNBOUND |WQ_HIGHPRI |WQ_MEM_RECLAIM , - hw->total_pfs); -if (!rvu->mbox_wq) +switch (type) { +case TYPE_AFPF : + name ="rvu_afpf_mailbox" ; + bar4_addr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PF_BAR4_ADDR ); + dir =MBOX_DIR_AFPF ; + dir_up =MBOX_DIR_AFPF_UP ; + reg_base = rvu->afreg_base; +break ; +case TYPE_AFVF : + name ="rvu_afvf_mailbox" ; + bar4_addr =rvupf_read64 (rvu,RVU_PF_VF_BAR4_ADDR ); + dir =MBOX_DIR_PFVF ; + dir_up =MBOX_DIR_PFVF_UP ; + reg_base = rvu->pfreg_base; +break ; +default : +return -EINVAL ; + } + + mw->mbox_wq =alloc_workqueue (name, +WQ_UNBOUND |WQ_HIGHPRI |WQ_MEM_RECLAIM , + num); +if (!mw->mbox_wq)return -ENOMEM ; - rvu->mbox_wrk =devm_kcalloc (rvu->dev, hw->total_pfs, -sizeof (struct rvu_work ),GFP_KERNEL ); -if (!rvu->mbox_wrk) { + mw->mbox_wrk =devm_kcalloc (rvu->dev, num, +sizeof (struct rvu_work ),GFP_KERNEL ); +if (!mw->mbox_wrk) { err = -ENOMEM ; goto exit; } - rvu->mbox_wrk_up =devm_kcalloc (rvu->dev, hw->total_pfs, -sizeof (struct rvu_work ),GFP_KERNEL ); -if (!rvu->mbox_wrk_up) { + mw->mbox_wrk_up =devm_kcalloc (rvu->dev, num, +sizeof (struct rvu_work ),GFP_KERNEL ); +if (!mw->mbox_wrk_up) { err = -ENOMEM ; goto exit; } -/* Map mbox region shared with PFs */ - bar4_addr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PF_BAR4_ADDR );/* Mailbox is a reserved memory (in RAM) region shared between * RVU devices, shouldn't be mapped as device memory to allow * unaligned accesses. */ - hwbase =ioremap_wc (bar4_addr,MBOX_SIZE * hw->total_pfs); + hwbase =ioremap_wc (bar4_addr,MBOX_SIZE * num);if (!hwbase) {dev_err (rvu->dev,"Unable to map mailbox region\n" ); err = -ENOMEM ; goto exit; } - err =otx2_mbox_init (&rvu->mbox, hwbase, rvu->pdev, rvu->afreg_base, -MBOX_DIR_AFPF , hw->total_pfs); + err =otx2_mbox_init (&mw->mbox, hwbase, rvu->pdev, reg_base, dir, num);if (err) goto exit; - err =otx2_mbox_init (&rvu->mbox_up, hwbase, rvu->pdev, rvu->afreg_base, -MBOX_DIR_AFPF_UP , hw->total_pfs); + err =otx2_mbox_init (&mw->mbox_up, hwbase, rvu->pdev, + reg_base, dir_up, num);if (err) goto exit; -for (pf =0 ; pf < hw->total_pfs; pf++) { - mwork = &rvu->mbox_wrk[pf]; +for (i =0 ; i < num; i++) { + mwork = &mw->mbox_wrk[i]; mwork->rvu = rvu; -INIT_WORK (&mwork->work, rvu_mbox_handler); - } +INIT_WORK (&mwork->work, mbox_handler); -for (pf =0 ; pf < hw->total_pfs; pf++) { - mwork = &rvu->mbox_wrk_up[pf]; + mwork = &mw->mbox_wrk_up[i]; mwork->rvu = rvu; -INIT_WORK (&mwork->work, rvu_mbox_up_handler); +INIT_WORK (&mwork->work, mbox_up_handler); }return 0 ; exit:if (hwbase)iounmap ((void __iomem *)hwbase); -destroy_workqueue (rvu->mbox_wq); +destroy_workqueue (mw->mbox_wq);return err; } -static void rvu_mbox_destroy (struct rvu *rvu) +static void rvu_mbox_destroy (struct mbox_wq_info *mw) { -if (rvu->mbox_wq) { -flush_workqueue (rvu->mbox_wq); -destroy_workqueue (rvu->mbox_wq); - rvu->mbox_wq =NULL ; +if (mw->mbox_wq) { +flush_workqueue (mw->mbox_wq); +destroy_workqueue (mw->mbox_wq); + mw->mbox_wq =NULL ; } -if (rvu->mbox.hwbase) -iounmap ((void __iomem *)rvu->mbox.hwbase); +if (mw->mbox.hwbase) +iounmap ((void __iomem *)mw->mbox.hwbase); -otx2_mbox_destroy (&rvu->mbox); -otx2_mbox_destroy (&rvu->mbox_up); +otx2_mbox_destroy (&mw->mbox); +otx2_mbox_destroy (&mw->mbox_up); } -static irqreturn_t rvu_mbox_intr_handler (int irq,void *rvu_irq) +static void rvu_queue_work (struct mbox_wq_info *mw,int first, +int mdevs,u64 intr) { -struct rvu *rvu = (struct rvu *)rvu_irq;struct otx2_mbox_dev *mdev;struct otx2_mbox *mbox;struct mbox_hdr *hdr; +int i; + +for (i = first; i < mdevs; i++) { +/* start from 0 */ +if (!(intr &BIT_ULL (i - first))) +continue ; + + mbox = &mw->mbox; + mdev = &mbox->dev[i]; + hdr = mdev->mbase + mbox->rx_start; +if (hdr->num_msgs) +queue_work (mw->mbox_wq, &mw->mbox_wrk[i].work); + + mbox = &mw->mbox_up; + mdev = &mbox->dev[i]; + hdr = mdev->mbase + mbox->rx_start; +if (hdr->num_msgs) +queue_work (mw->mbox_wq, &mw->mbox_wrk_up[i].work); + } +} + +static irqreturn_t rvu_mbox_intr_handler (int irq,void *rvu_irq) +{ +struct rvu *rvu = (struct rvu *)rvu_irq; +int vfs =pci_num_vf (rvu->pdev);u64 intr; -u8 pf; intr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PFAF_MBOX_INT );/* Clear interrupts */ rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFAF_MBOX_INT , intr);/* Sync with mbox memory region */ -smp_wmb (); +rmb (); -for (pf =0 ; pf < rvu->hw->total_pfs; pf++) { -if (intr & (1ULL << pf)) { - mbox = &rvu->mbox; - mdev = &mbox->dev[pf]; - hdr = mdev->mbase + mbox->rx_start; -if (hdr->num_msgs) -queue_work (rvu->mbox_wq, - &rvu->mbox_wrk[pf].work); - mbox = &rvu->mbox_up; - mdev = &mbox->dev[pf]; - hdr = mdev->mbase + mbox->rx_start; -if (hdr->num_msgs) -queue_work (rvu->mbox_wq, - &rvu->mbox_wrk_up[pf].work); - } +rvu_queue_work (&rvu->afpf_wq_info,0 , rvu->hw->total_pfs, intr); + +/* Handle VF interrupts */ +if (vfs >64 ) { + intr =rvupf_read64 (rvu,RVU_PF_VFPF_MBOX_INTX (1 )); +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INTX (1 ), intr); + +rvu_queue_work (&rvu->afvf_wq_info,64 , vfs, intr); + vfs -=64 ; } + intr =rvupf_read64 (rvu,RVU_PF_VFPF_MBOX_INTX (0 )); +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INTX (0 ), intr); + +rvu_queue_work (&rvu->afvf_wq_info,0 , vfs, intr); +return IRQ_HANDLED ; }
@@ -1917,7 +2035,10 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_release_regions; - err =rvu_mbox_init (rvu); +/* Init mailbox btw AF and PFs */ + err =rvu_mbox_init (rvu, &rvu->afpf_wq_info,TYPE_AFPF , + rvu->hw->total_pfs, rvu_afpf_mbox_handler, + rvu_afpf_mbox_up_handler);if (err) goto err_hwsetup;
@@ -1939,7 +2060,7 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_cgx:rvu_cgx_wq_destroy (rvu); err_mbox: -rvu_mbox_destroy (rvu); +rvu_mbox_destroy (&rvu->afpf_wq_info); err_hwsetup:rvu_reset_all_blocks (rvu);rvu_free_hw_resources (rvu);
@@ -1961,7 +2082,7 @@ static void rvu_remove(struct pci_dev *pdev)rvu_unregister_interrupts (rvu);rvu_flr_wq_destroy (rvu);rvu_cgx_wq_destroy (rvu); -rvu_mbox_destroy (rvu); +rvu_mbox_destroy (&rvu->afpf_wq_info);rvu_reset_all_blocks (rvu);rvu_free_hw_resources (rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +12 -5
@@ -183,6 +183,16 @@ struct rvu_hwinfo {struct npc_mcam mcam; }; +struct mbox_wq_info { +struct otx2_mbox mbox; +struct rvu_work *mbox_wrk; + +struct otx2_mbox mbox_up; +struct rvu_work *mbox_wrk_up; + +struct workqueue_struct *mbox_wq; +}; +struct rvu {void __iomem *afreg_base;void __iomem *pfreg_base;
@@ -194,11 +204,8 @@ struct rvu {struct mutex rsrc_lock;/* Serialize resource alloc/free */ /* Mbox */ -struct otx2_mbox mbox; -struct rvu_work *mbox_wrk; -struct otx2_mbox mbox_up; -struct rvu_work *mbox_wrk_up; -struct workqueue_struct *mbox_wq; +struct mbox_wq_info afpf_wq_info; +struct mbox_wq_info afvf_wq_info;/* PF FLR */ struct rvu_work *flr_wrk;
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +3 -3
@@ -27,7 +27,7 @@ static struct _req_type __maybe_unused \struct _req_type *req; \ \ req = (struct _req_type *)otx2_mbox_alloc_msg_rsp ( \ - &rvu->mbox_up, devid,sizeof (struct _req_type ), \ + &rvu->afpf_wq_info.mbox_up, devid,sizeof (struct _req_type ), \sizeof (struct _rsp_type )); \if (!req) \return NULL ; \
@@ -181,8 +181,8 @@ static void cgx_notify_pfs(struct cgx_link_event *event, struct rvu *rvu)if (!msg)continue ; msg->link_info = *linfo; -otx2_mbox_msg_send (&rvu->mbox_up, pfid); - err =otx2_mbox_wait_for_rsp (&rvu->mbox_up, pfid); +otx2_mbox_msg_send (&rvu->afpf_wq_info.mbox_up, pfid); + err =otx2_mbox_wait_for_rsp (&rvu->afpf_wq_info.mbox_up, pfid);if (err)dev_warn (rvu->dev,"notification to pf %d failed\n" , pfid);
Signature · 1 line
2.7.4
PATCH v2 17/21 octeontx2-af: Enable sriov on AF to create VFs
In reply to [email protected]From: Tomasz Duszynski <[email protected]>
Enable all AF VFs during probe. Since AF's VFs work in pairs (eg: Pkts sent on VF0 are received by VF1 and viceversa), enable only even number of VFs out of totalVFs, which should again be less than number of loopback (LBK) channels.
Also enable VF's mailbox interrupts.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 185 +++++++++++++++++++++++- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 3 +- 2 files changed, 185 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +183 -2
@@ -1698,7 +1698,7 @@ static void rvu_queue_work(struct mbox_wq_info *mw, int first,static irqreturn_t rvu_mbox_intr_handler (int irq,void *rvu_irq) {struct rvu *rvu = (struct rvu *)rvu_irq; -int vfs =pci_num_vf (rvu->pdev); +int vfs = rvu->vfs;u64 intr; intr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PFAF_MBOX_INT );
@@ -1858,9 +1858,25 @@ static void rvu_unregister_interrupts(struct rvu *rvu) rvu->num_vec =0 ; } +static int rvu_afvf_msix_vectors_num_ok (struct rvu *rvu) +{ +struct rvu_pfvf *pfvf = &rvu->pf[0 ]; +int offset; + + pfvf = &rvu->pf[0 ]; + offset =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_INT_CFG (0 )) &0x3ff ; + +/* Make sure there are enough MSIX vectors configured so that +* VF interrupts can be handled. Offset equal to zero means +* that PF vectors are not configured and overlapping AF vectors. +*/ +return (pfvf->msix.max >=RVU_AF_INT_VEC_CNT +RVU_PF_INT_VEC_CNT ) && + offset; +} +static int rvu_register_interrupts (struct rvu *rvu) { -int ret; +int ret, offset; rvu->num_vec =pci_msix_vec_count (rvu->pdev);
@@ -1921,6 +1937,40 @@ static int rvu_register_interrupts(struct rvu *rvu)rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1S ,INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +if (!rvu_afvf_msix_vectors_num_ok (rvu)) +return 0 ; + +/* Get PF MSIX vectors offset. */ + offset =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_INT_CFG (0 )) &0x3ff ; + +/* Register MBOX0 interrupt. */ + offset +=RVU_PF_INT_VEC_VFPF_MBOX0 ; +sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF Mbox0" ); + ret =request_irq (pci_irq_vector (rvu->pdev, offset), + rvu_mbox_intr_handler,0 , + &rvu->irq_name[offset *NAME_SIZE ], + rvu); +if (ret) +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for Mbox0\n" ); + + rvu->irq_allocated[offset] = true; + +/* Register MBOX1 interrupt. MBOX1 IRQ number follows MBOX0 so +* simply increment current offset by 1. +*/ + offset +=1 ; +sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF Mbox1" ); + ret =request_irq (pci_irq_vector (rvu->pdev, offset), + rvu_mbox_intr_handler,0 , + &rvu->irq_name[offset *NAME_SIZE ], + rvu); +if (ret) +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for Mbox1\n" ); + + rvu->irq_allocated[offset] = true; +return 0 ; fail:
@@ -1973,6 +2023,129 @@ static int rvu_flr_init(struct rvu *rvu)return 0 ; } +static void rvu_disable_afvf_mbox_intr (struct rvu *rvu) +{ +int vfs = rvu->vfs; + +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1CX (0 ),INTR_MASK (vfs)); +if (vfs >64 ) +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1CX (1 ), +INTR_MASK (vfs -64 )); +} + +static void rvu_enable_afvf_mbox_intr (struct rvu *rvu) +{ +int vfs = rvu->vfs; + +/* Clear any pending interrupts and enable AF VF interrupts for +* the first 64 VFs. +*/ +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INTX (0 ),INTR_MASK (vfs)); +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1SX (0 ),INTR_MASK (vfs)); + +/* Same for remaining VFs, if any. */ +if (vfs <=64 ) +return ; + +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INTX (1 ),INTR_MASK (vfs -64 )); +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1SX (1 ), +INTR_MASK (vfs -64 )); +} + +#define PCI_DEVID_OCTEONTX2_LBK 0xA061 + +static int lbk_get_num_chans (void ) +{ +struct pci_dev *pdev; +void __iomem *base; +int ret = -EIO ; + + pdev =pci_get_device (PCI_VENDOR_ID_CAVIUM ,PCI_DEVID_OCTEONTX2_LBK , +NULL ); +if (!pdev) + goto err; + + base =pci_ioremap_bar (pdev,0 ); +if (!base) + goto err_put; + +/* Read number of available LBK channels from LBK(0)_CONST register. */ + ret = (readq (base +0x10 ) >>32 ) &0xffff ; +iounmap (base); +err_put: +pci_dev_put (pdev); +err: +return ret; +} + +static int rvu_enable_sriov (struct rvu *rvu) +{ +struct pci_dev *pdev = rvu->pdev; +int err, chans, vfs; + +if (!rvu_afvf_msix_vectors_num_ok (rvu)) { +dev_warn (&pdev->dev, +"Skipping SRIOV enablement since not enough IRQs are available\n" ); +return 0 ; + } + + chans =lbk_get_num_chans (); +if (chans <0 ) +return chans; + + vfs =pci_sriov_get_totalvfs (pdev); + +/* Limit VFs in case we have more VFs than LBK channels available. */ +if (vfs > chans) + vfs = chans; + +/* AF's VFs work in pairs and talk over consecutive loopback channels. +* Thus we want to enable maximum even number of VFs. In case +* odd number of VFs are available then the last VF on the list +* remains disabled. +*/ +if (vfs &0x1 ) { +dev_warn (&pdev->dev, +"Number of VFs should be even. Enabling %d out of %d.\n" , + vfs -1 , vfs); + vfs--; + } + +if (!vfs) +return 0 ; + +/* Save VFs number for reference in VF interrupts handlers. +* Since interrupts might start arriving during SRIOV enablement +* ordinary API cannot be used to get number of enabled VFs. +*/ + rvu->vfs = vfs; + + err =rvu_mbox_init (rvu, &rvu->afvf_wq_info,TYPE_AFVF , vfs, + rvu_afvf_mbox_handler, rvu_afvf_mbox_up_handler); +if (err) +return err; + +rvu_enable_afvf_mbox_intr (rvu); +/* Make sure IRQs are enabled before SRIOV. */ +mb (); + + err =pci_enable_sriov (pdev, vfs); +if (err) { +rvu_disable_afvf_mbox_intr (rvu); +rvu_mbox_destroy (&rvu->afvf_wq_info); +return err; + } + +return 0 ; +} + +static void rvu_disable_sriov (struct rvu *rvu) +{ +rvu_disable_afvf_mbox_intr (rvu); +rvu_mbox_destroy (&rvu->afvf_wq_info); +pci_disable_sriov (rvu->pdev); +} +static int rvu_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct device *dev = &pdev->dev;
@@ -2054,7 +2227,14 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_flr; +/* Enable AF's VFs (if any) */ + err =rvu_enable_sriov (rvu); +if (err) + goto err_irq; +return 0 ; +err_irq: +rvu_unregister_interrupts (rvu); err_flr:rvu_flr_wq_destroy (rvu); err_cgx:
@@ -2083,6 +2263,7 @@ static void rvu_remove(struct pci_dev *pdev)rvu_flr_wq_destroy (rvu);rvu_cgx_wq_destroy (rvu);rvu_mbox_destroy (&rvu->afpf_wq_info); +rvu_disable_sriov (rvu);rvu_reset_all_blocks (rvu);rvu_free_hw_resources (rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -1
@@ -201,7 +201,8 @@ struct rvu {struct rvu_hwinfo *hw;struct rvu_pfvf *pf;struct rvu_pfvf *hwvf; -struct mutex rsrc_lock;/* Serialize resource alloc/free */ +struct mutex rsrc_lock;/* Serialize resource alloc/free */ +int vfs;/* Number of VFs attached to RVU */ /* Mbox */ struct mbox_wq_info afpf_wq_info;
Signature · 1 line
2.7.4
PATCH v2 18/21 octeontx2-af: Configure AF VFs to talk over LBK channels
In reply to [email protected]From: Tomasz Duszynski <[email protected]>
Configure AF VFs such that they are able to talk over consecutive loopback channels.
If 8 VFs are attached to AF then communication will work as below:
TX RX
lbk0 -> lbk1
lbk1 -> lbk0
lbk2 -> lbk3
lbk3 -> lbk2
lbk4 -> lbk5
lbk5 -> lbk4
lbk6 -> lbk7
lbk7 -> lbk6
--- drivers/net/ethernet/marvell/octeontx2/af/common.h | 2 ++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 5 +++++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 25 +++++++++++++++++++--- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 12 +++++++---- 4 files changed, 37 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/common.h +2 -0
@@ -174,7 +174,9 @@ enum nix_scheduler {#define MAX_LMAC_PKIND 12#define NIX_LINK_CGX_LMAC (a, b) (0 + 4 * (a) + (b)) +#define NIX_LINK_LBK (a) (12 + (a))#define NIX_CHAN_CGX_LMAC_CHX (a, b, c) (0x800 + 0x100 * (a) + 0x10 * (b) + (c)) +#define NIX_CHAN_LBK_CHX (a, b) (0 + 0x100 * (a) + (b))/* NIX LSO format indices. * As of now TSO is the only one using, so statically assigning indices.
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +5 -0
@@ -258,6 +258,11 @@ static inline u64 rvupf_read64(struct rvu *rvu, u64 offset)/* Function Prototypes * RVU */ +static inline int is_afvf (u16 pcifunc) +{ +return !(pcifunc & ~RVU_PFVF_FUNC_MASK ); +} +int rvu_alloc_bitmap (struct rsrc_bmap *rsrc);int rvu_alloc_rsrc (struct rsrc_bmap *rsrc);void rvu_free_rsrc (struct rsrc_bmap *rsrc,int id);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +22 -3
@@ -144,7 +144,7 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf) {struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc);u8 cgx_id, lmac_id; -int pkind, pf; +int pkind, pf, vf;int err; pf =rvu_get_pf (pcifunc);
@@ -170,6 +170,14 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf)rvu_npc_set_pkind (rvu, pkind, pfvf);break ;case NIX_INTF_TYPE_LBK : + vf = (pcifunc &RVU_PFVF_FUNC_MASK ) -1 ; + pfvf->rx_chan_base =NIX_CHAN_LBK_CHX (0 , vf); + pfvf->tx_chan_base = vf &0x1 ?NIX_CHAN_LBK_CHX (0 , vf -1 ) : +NIX_CHAN_LBK_CHX (0 , vf +1 ); + pfvf->rx_chan_cnt =1 ; + pfvf->tx_chan_cnt =1 ; +rvu_npc_install_promisc_entry (rvu, pcifunc, nixlf, + pfvf->rx_chan_base, false);break ; }
@@ -684,7 +692,7 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,struct nix_lf_alloc_req *req, struct nix_lf_alloc_rsp *rsp) { - int nixlf, qints, hwctx_size, err, rc = 0; + int nixlf, qints, hwctx_size, intf, err, rc = 0;struct rvu_hwinfo *hw = rvu->hw;u16 pcifunc = req->hdr.pcifunc;struct rvu_block *block;
@@ -839,7 +847,8 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu,/* Config Rx pkt length, csum checks and apad enable / disable */ rvu_write64 (rvu, blkaddr,NIX_AF_LFX_RX_CFG (nixlf), req->rx_cfg); - err =nix_interface_init (rvu, pcifunc,NIX_INTF_TYPE_CGX , nixlf); + intf =is_afvf (pcifunc) ?NIX_INTF_TYPE_LBK :NIX_INTF_TYPE_CGX ; + err =nix_interface_init (rvu, pcifunc, intf, nixlf);if (err) goto free_mem;
@@ -1354,6 +1363,10 @@ static int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add)struct rvu_pfvf *pfvf;int blkaddr; +/* Broadcast pkt replication is not needed for AF's VFs, hence skip */ +if (is_afvf (pcifunc)) +return 0 ; + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NIX , pcifunc);if (blkaddr <0 )return 0 ;
@@ -1966,6 +1979,12 @@ int rvu_mbox_handler_nix_rxvlan_alloc(struct rvu *rvu, struct msg_req *req,int blkaddr, nixlf, err;struct rvu_pfvf *pfvf; +/* LBK VFs do not have separate MCAM UCAST entry hence +* skip allocating rxvlan for them +*/ +if (is_afvf (pcifunc)) +return 0 ; + pfvf =rvu_get_pfvf (rvu, pcifunc);if (pfvf->rxvlan)return 0 ;
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +8 -4
@@ -314,6 +314,10 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,int blkaddr, index, kwi;u64 mac =0 ; +/* AF's VFs work in promiscuous mode */ +if (is_afvf (pcifunc)) +return ; + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 );if (blkaddr <0 )return ;
@@ -368,12 +372,12 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc,struct nix_rx_action action = { };int blkaddr, index, kwi; - blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 ); -if (blkaddr <0 ) +/* Only PF or AF VF can add a promiscuous entry */ +if ((pcifunc &RVU_PFVF_FUNC_MASK ) && !is_afvf (pcifunc))return ; -/* Only PF or AF VF can add a promiscuous entry */ -if (pcifunc &RVU_PFVF_FUNC_MASK ) + blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 ); +if (blkaddr <0 )return ; index = npc_get_nixlf_mcam_index(mcam, pcifunc,
Signature · 1 line
2.7.4
PATCH v2 19/21 octeontx2-af: Add FLR handling support for AF's VFs
In reply to [email protected]From: Sunil Goutham <[email protected]>
Added support to handle FLR for AF's VFs (i.e LBK VFs). Just the FLR interrupt enable/disable, handler registration etc, actual HW resource cleanup or LFs teardown logic is already there.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 129 ++++++++++++++++++++---- 1 file changed, 110 insertions(+), 19 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +110 -19
@@ -1788,6 +1788,23 @@ static void __rvu_flr_handler(struct rvu *rvu, u16 pcifunc)mutex_unlock (&rvu->flr_lock); } +static void rvu_afvf_flr_handler (struct rvu *rvu,int vf) +{ +int reg =0 ; + +/* pcifunc = 0(PF0) | (vf + 1) */ +__rvu_flr_handler (rvu, vf +1 ); + +if (vf >=64 ) { + reg =1 ; + vf = vf -64 ; + } + +/* Signal FLR finish and enable IRQ */ +rvupf_write64 (rvu,RVU_PF_VFTRPENDX (reg),BIT_ULL (vf)); +rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1SX (reg),BIT_ULL (vf)); +} +static void rvu_flr_handler (struct work_struct *work) { struct rvu_work *flrwork = container_of(work, struct rvu_work, work);
@@ -1797,6 +1814,10 @@ static void rvu_flr_handler(struct work_struct *work)int pf; pf = flrwork - rvu->flr_wrk; +if (pf >= rvu->hw->total_pfs) { +rvu_afvf_flr_handler (rvu, pf - rvu->hw->total_pfs); +return ; + } cfg =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_CFG (pf)); numvfs = (cfg >>12 ) &0xFF ;
@@ -1814,6 +1835,29 @@ static void rvu_flr_handler(struct work_struct *work)rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1S ,BIT_ULL (pf)); } +static void rvu_afvf_queue_flr_work (struct rvu *rvu,int start_vf,int numvfs) +{ +int dev, vf, reg =0 ; +u64 intr; + +if (start_vf >=64 ) + reg =1 ; + + intr =rvupf_read64 (rvu,RVU_PF_VFFLR_INTX (reg)); +if (!intr) +return ; + +for (vf =0 ; vf < numvfs; vf++) { +if (!(intr &BIT_ULL (vf))) +continue ; + dev = vf + start_vf + rvu->hw->total_pfs; +queue_work (rvu->flr_wq, &rvu->flr_wrk[dev].work); +/* Clear and disable the interrupt */ +rvupf_write64 (rvu,RVU_PF_VFFLR_INTX (reg),BIT_ULL (vf)); +rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1CX (reg),BIT_ULL (vf)); + } +} +static irqreturn_t rvu_flr_intr_handler (int irq,void *rvu_irq) {struct rvu *rvu = (struct rvu *)rvu_irq;
@@ -1821,6 +1865,8 @@ static irqreturn_t rvu_flr_intr_handler(int irq, void *rvu_irq)u8 pf; intr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT ); +if (!intr) + goto afvf_flr;for (pf =0 ; pf < rvu->hw->total_pfs; pf++) {if (intr & (1ULL << pf)) {
@@ -1834,6 +1880,12 @@ static irqreturn_t rvu_flr_intr_handler(int irq, void *rvu_irq) BIT_ULL(pf)); } } + +afvf_flr: +rvu_afvf_queue_flr_work (rvu,0 ,64 ); +if (rvu->vfs >64 ) +rvu_afvf_queue_flr_work (rvu,64 , rvu->vfs -64 ); +return IRQ_HANDLED ; }
@@ -1876,7 +1928,7 @@ static int rvu_afvf_msix_vectors_num_ok(struct rvu *rvu)static int rvu_register_interrupts (struct rvu *rvu) { -int ret, offset; +int ret, offset, pf_vec_start; rvu->num_vec =pci_msix_vec_count (rvu->pdev);
@@ -1941,10 +1993,11 @@ static int rvu_register_interrupts(struct rvu *rvu)return 0 ;/* Get PF MSIX vectors offset. */ - offset =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_INT_CFG (0 )) &0x3ff ; + pf_vec_start =rvu_read64 (rvu,BLKADDR_RVUM , +RVU_PRIV_PFX_INT_CFG (0 )) &0x3ff ;/* Register MBOX0 interrupt. */ - offset +=RVU_PF_INT_VEC_VFPF_MBOX0 ; + offset = pf_vec_start +RVU_PF_INT_VEC_VFPF_MBOX0 ;sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF Mbox0" ); ret = request_irq(pci_irq_vector(rvu->pdev, offset), rvu_mbox_intr_handler, 0,
@@ -1959,7 +2012,7 @@ static int rvu_register_interrupts(struct rvu *rvu)/* Register MBOX1 interrupt. MBOX1 IRQ number follows MBOX0 so * simply increment current offset by 1. */ - offset +=1 ; + offset = pf_vec_start +RVU_PF_INT_VEC_VFPF_MBOX1 ;sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF Mbox1" ); ret = request_irq(pci_irq_vector(rvu->pdev, offset), rvu_mbox_intr_handler, 0,
@@ -1971,10 +2024,35 @@ static int rvu_register_interrupts(struct rvu *rvu) rvu->irq_allocated[offset] = true; +/* Register FLR interrupt handler for AF's VFs */ + offset = pf_vec_start +RVU_PF_INT_VEC_VFFLR0 ; +sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF FLR0" ); + ret =request_irq (pci_irq_vector (rvu->pdev, offset), + rvu_flr_intr_handler,0 , + &rvu->irq_name[offset *NAME_SIZE ], rvu); +if (ret) { +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for RVUAFVF FLR0\n" ); + goto fail; + } + rvu->irq_allocated[offset] = true; + + offset = pf_vec_start +RVU_PF_INT_VEC_VFFLR1 ; +sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF FLR1" ); + ret =request_irq (pci_irq_vector (rvu->pdev, offset), + rvu_flr_intr_handler,0 , + &rvu->irq_name[offset *NAME_SIZE ], rvu); +if (ret) { +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for RVUAFVF FLR1\n" ); + goto fail; + } + rvu->irq_allocated[offset] = true; +return 0 ; fail: -pci_free_irq_vectors (rvu->pdev); +rvu_unregister_interrupts (rvu);return ret; }
@@ -1985,16 +2063,16 @@ static void rvu_flr_wq_destroy(struct rvu *rvu)destroy_workqueue (rvu->flr_wq); rvu->flr_wq =NULL ; } -kfree (rvu->flr_wrk); }static int rvu_flr_init (struct rvu *rvu) { +int dev, num_devs;u64 cfg;int pf;/* Enable FLR for all PFs*/ -for (pf =1 ; pf < rvu->hw->total_pfs; pf++) { +for (pf =0 ; pf < rvu->hw->total_pfs; pf++) { cfg =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_CFG (pf));rvu_write64 (rvu,BLKADDR_RVUM ,RVU_PRIV_PFX_CFG (pf), cfg |BIT_ULL (22 ));
@@ -2006,16 +2084,17 @@ static int rvu_flr_init(struct rvu *rvu)if (!rvu->flr_wq)return -ENOMEM ; - rvu->flr_wrk =devm_kcalloc (rvu->dev, rvu->hw->total_pfs, + num_devs = rvu->hw->total_pfs +pci_sriov_get_totalvfs (rvu->pdev); + rvu->flr_wrk =devm_kcalloc (rvu->dev, num_devs,sizeof (struct rvu_work ),GFP_KERNEL );if (!rvu->flr_wrk) {destroy_workqueue (rvu->flr_wq);return -ENOMEM ; } -for (pf =0 ; pf < rvu->hw->total_pfs; pf++) { - rvu->flr_wrk[pf].rvu = rvu; -INIT_WORK (&rvu->flr_wrk[pf].work, rvu_flr_handler); +for (dev =0 ; dev < num_devs; dev++) { + rvu->flr_wrk[dev].rvu = rvu; +INIT_WORK (&rvu->flr_wrk[dev].work, rvu_flr_handler); }mutex_init (&rvu->flr_lock);
@@ -2023,26 +2102,35 @@ static int rvu_flr_init(struct rvu *rvu)return 0 ; } -static void rvu_disable_afvf_mbox_intr (struct rvu *rvu) +static void rvu_disable_afvf_intr (struct rvu *rvu) {int vfs = rvu->vfs;rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1CX (0 ),INTR_MASK (vfs)); -if (vfs >64 ) -rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1CX (1 ), -INTR_MASK (vfs -64 )); +rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1CX (0 ),INTR_MASK (vfs)); +if (vfs <=64 ) +return ; + +rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1CX (1 ), +INTR_MASK (vfs -64 )); +rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1CX (1 ),INTR_MASK (vfs -64 )); } -static void rvu_enable_afvf_mbox_intr (struct rvu *rvu) +static void rvu_enable_afvf_intr (struct rvu *rvu) {int vfs = rvu->vfs;/* Clear any pending interrupts and enable AF VF interrupts for * the first 64 VFs. */ +/* Mbox */ rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INTX (0 ),INTR_MASK (vfs));rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1SX (0 ),INTR_MASK (vfs)); +/* FLR */ +rvupf_write64 (rvu,RVU_PF_VFFLR_INTX (0 ),INTR_MASK (vfs)); +rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1SX (0 ),INTR_MASK (vfs)); +/* Same for remaining VFs, if any. */ if (vfs <=64 )return ;
@@ -2050,6 +2138,9 @@ static void rvu_enable_afvf_mbox_intr(struct rvu *rvu)rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INTX (1 ),INTR_MASK (vfs -64 ));rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1SX (1 ),INTR_MASK (vfs -64 )); + +rvupf_write64 (rvu,RVU_PF_VFFLR_INTX (1 ),INTR_MASK (vfs -64 )); +rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1SX (1 ),INTR_MASK (vfs -64 )); }#define PCI_DEVID_OCTEONTX2_LBK 0xA061
@@ -2125,13 +2216,13 @@ static int rvu_enable_sriov(struct rvu *rvu)if (err)return err; -rvu_enable_afvf_mbox_intr (rvu); +rvu_enable_afvf_intr (rvu);/* Make sure IRQs are enabled before SRIOV. */ mb (); err =pci_enable_sriov (pdev, vfs);if (err) { -rvu_disable_afvf_mbox_intr (rvu); +rvu_disable_afvf_intr (rvu);rvu_mbox_destroy (&rvu->afvf_wq_info);return err; }
@@ -2141,7 +2232,7 @@ static int rvu_enable_sriov(struct rvu *rvu)static void rvu_disable_sriov (struct rvu *rvu) { -rvu_disable_afvf_mbox_intr (rvu); +rvu_disable_afvf_intr (rvu);rvu_mbox_destroy (&rvu->afvf_wq_info);pci_disable_sriov (rvu->pdev); }
Signature · 1 line
2.7.4
PATCH v2 20/21 octeontx2-af: Add interrupt handlers for Master Enable event
In reply to [email protected]From: Linu Cherian <[email protected]>
- Add interrupt handlers for Master Enable events from PFs and Master Enable events from VFs of AF
- Master Enable is required for the MSIX delivery to work
- Master Enable bit trap handler doesn't have to do any anything other than clearing the TRPEND bit, since the enable/disable requirements are already taken care using mbox requests/flr handler.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 113 ++++++++++++++++++++++++ 1 file changed, 113 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +113 -0
@@ -1889,6 +1889,67 @@ static irqreturn_t rvu_flr_intr_handler(int irq, void *rvu_irq)return IRQ_HANDLED ; } +static void rvu_me_handle_vfset (struct rvu *rvu,int idx,u64 intr) +{ +int vf; + +/* Nothing to be done here other than clearing the +* TRPEND bit. +*/ +for (vf =0 ; vf <64 ; vf++) { +if (intr & (1ULL << vf)) { +/* clear the trpend due to ME(master enable) */ +rvupf_write64 (rvu,RVU_PF_VFTRPENDX (idx),BIT_ULL (vf)); +/* clear interrupt */ +rvupf_write64 (rvu,RVU_PF_VFME_INTX (idx),BIT_ULL (vf)); + } + } +} + +/* Handles ME interrupts from VFs of AF */ +static irqreturn_t rvu_me_vf_intr_handler (int irq,void *rvu_irq) +{ +struct rvu *rvu = (struct rvu *)rvu_irq; +int vfset; +u64 intr; + + intr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PFME_INT ); + +for (vfset =0 ; vfset <=1 ; vfset++) { + intr =rvupf_read64 (rvu,RVU_PF_VFME_INTX (vfset)); +if (intr) +rvu_me_handle_vfset (rvu, vfset, intr); + } + +return IRQ_HANDLED ; +} + +/* Handles ME interrupts from PFs */ +static irqreturn_t rvu_me_pf_intr_handler (int irq,void *rvu_irq) +{ +struct rvu *rvu = (struct rvu *)rvu_irq; +u64 intr; +u8 pf; + + intr =rvu_read64 (rvu,BLKADDR_RVUM ,RVU_AF_PFME_INT ); + +/* Nothing to be done here other than clearing the +* TRPEND bit. +*/ +for (pf =0 ; pf < rvu->hw->total_pfs; pf++) { +if (intr & (1ULL << pf)) { +/* clear the trpend due to ME(master enable) */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFTRPEND , +BIT_ULL (pf)); +/* clear interrupt */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFME_INT , +BIT_ULL (pf)); + } + } + +return IRQ_HANDLED ; +} +static void rvu_unregister_interrupts (struct rvu *rvu) {int irq;
@@ -1901,6 +1962,10 @@ static void rvu_unregister_interrupts(struct rvu *rvu)rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1C ,INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +/* Disable the PF ME interrupt */ +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFME_INT_ENA_W1C , +INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +for (irq =0 ; irq < rvu->num_vec; irq++) {if (rvu->irq_allocated[irq])free_irq (pci_irq_vector (rvu->pdev, irq), rvu);
@@ -1989,6 +2054,26 @@ static int rvu_register_interrupts(struct rvu *rvu)rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFFLR_INT_ENA_W1S ,INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +/* Register ME interrupt handler */ +sprintf (&rvu->irq_name[RVU_AF_INT_VEC_PFME *NAME_SIZE ], +"RVUAF ME" ); + ret =request_irq (pci_irq_vector (rvu->pdev,RVU_AF_INT_VEC_PFME ), + rvu_me_pf_intr_handler,0 , + &rvu->irq_name[RVU_AF_INT_VEC_PFME *NAME_SIZE ], + rvu); +if (ret) { +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for ME\n" ); + } + rvu->irq_allocated[RVU_AF_INT_VEC_PFME ] = true; + +/* Enable ME interrupt for all PFs*/ +rvu_write64 (rvu,BLKADDR_RVUM , +RVU_AF_PFME_INT ,INTR_MASK (rvu->hw->total_pfs)); + +rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_PFME_INT_ENA_W1S , +INTR_MASK (rvu->hw->total_pfs) & ~1ULL ); +if (!rvu_afvf_msix_vectors_num_ok (rvu))return 0 ;
@@ -2049,6 +2134,30 @@ static int rvu_register_interrupts(struct rvu *rvu) } rvu->irq_allocated[offset] = true; +/* Register ME interrupt handler for AF's VFs */ + offset = pf_vec_start +RVU_PF_INT_VEC_VFME0 ; +sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF ME0" ); + ret =request_irq (pci_irq_vector (rvu->pdev, offset), + rvu_me_vf_intr_handler,0 , + &rvu->irq_name[offset *NAME_SIZE ], rvu); +if (ret) { +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for RVUAFVF ME0\n" ); + goto fail; + } + rvu->irq_allocated[offset] = true; + + offset = pf_vec_start +RVU_PF_INT_VEC_VFME1 ; +sprintf (&rvu->irq_name[offset *NAME_SIZE ],"RVUAFVF ME1" ); + ret =request_irq (pci_irq_vector (rvu->pdev, offset), + rvu_me_vf_intr_handler,0 , + &rvu->irq_name[offset *NAME_SIZE ], rvu); +if (ret) { +dev_err (rvu->dev, +"RVUAF: IRQ registration failed for RVUAFVF ME1\n" ); + goto fail; + } + rvu->irq_allocated[offset] = true;return 0 ; fail:
@@ -2108,12 +2217,14 @@ static void rvu_disable_afvf_intr(struct rvu *rvu)rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1CX (0 ),INTR_MASK (vfs));rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1CX (0 ),INTR_MASK (vfs)); +rvupf_write64 (rvu,RVU_PF_VFME_INT_ENA_W1CX (0 ),INTR_MASK (vfs));if (vfs <=64 )return ;rvupf_write64 (rvu,RVU_PF_VFPF_MBOX_INT_ENA_W1CX (1 ),INTR_MASK (vfs -64 ));rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1CX (1 ),INTR_MASK (vfs -64 )); +rvupf_write64 (rvu,RVU_PF_VFME_INT_ENA_W1CX (1 ),INTR_MASK (vfs -64 )); }static void rvu_enable_afvf_intr (struct rvu *rvu)
@@ -2130,6 +2241,7 @@ static void rvu_enable_afvf_intr(struct rvu *rvu)/* FLR */ rvupf_write64 (rvu,RVU_PF_VFFLR_INTX (0 ),INTR_MASK (vfs));rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1SX (0 ),INTR_MASK (vfs)); +rvupf_write64 (rvu,RVU_PF_VFME_INT_ENA_W1SX (0 ),INTR_MASK (vfs));/* Same for remaining VFs, if any. */ if (vfs <=64 )
@@ -2141,6 +2253,7 @@ static void rvu_enable_afvf_intr(struct rvu *rvu)rvupf_write64 (rvu,RVU_PF_VFFLR_INTX (1 ),INTR_MASK (vfs -64 ));rvupf_write64 (rvu,RVU_PF_VFFLR_INT_ENA_W1SX (1 ),INTR_MASK (vfs -64 )); +rvupf_write64 (rvu,RVU_PF_VFME_INT_ENA_W1SX (1 ),INTR_MASK (vfs -64 )); }#define PCI_DEVID_OCTEONTX2_LBK 0xA061
Signature · 1 line
2.7.4
PATCH v2 21/21 octeontx2-af: Workarounds for HW errata
In reply to [email protected]From: Sunil Goutham <[email protected]>
Errata 35038
Software sets NIX_AF_RX_SW_SYNC[ENA] to sync (flush) in-flight packets the RX data path before configuration changes (e.g. disabling one or more RQs). Hardware clears [ENA] to indicate sync is done
An issue exists whereby NIX may clear NIX_AF_RX_SW_SYNC [ENA] too early.
Errata 35057
NIX may corrupt internal state when conditional clocks turn off. So turnon all clocks by default.
Errata 35786
Parse nibble enable NPC configuration for KEY generation has to be identical for both Rx and Tx interfaces.
Also corrected endianness configuration for NIX i.e NIX_AF_CFG[AF_BE] is bit8 and not bit1.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 12 ++++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 18 ++++++++++++++++-- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 12 +++++++++--- 3 files changed, 37 insertions(+), 5 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +12 -0
@@ -11,6 +11,7 @@#ifndef RVU_H #define RVU_H +#include <linux/pci.h> #include "rvu_struct.h" #include "common.h" #include "mbox.h"
@@ -18,6 +19,9 @@/* PCI device IDs */ #define PCI_DEVID_OCTEONTX2_RVU_AF 0xA065 +/* Subsystem Device ID */ +#define PCI_SUBSYS_DEVID_96XX 0xB200 +/* PCI BAR nos */ #define PCI_AF_REG_BAR_NUM 0#define PCI_PF_REG_BAR_NUM 2
@@ -255,6 +259,14 @@ static inline u64 rvupf_read64(struct rvu *rvu, u64 offset)return readq (rvu->pfreg_base + offset); } +static inline bool is_rvu_9xxx_A0 (struct rvu *rvu) +{ +struct pci_dev *pdev = rvu->pdev; + +return (pdev->revision ==0x00 ) && + (pdev->subsystem_device ==PCI_SUBSYS_DEVID_96XX ); +} +/* Function Prototypes * RVU */
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +16 -2
@@ -114,6 +114,12 @@ static void nix_rx_sync(struct rvu *rvu, int blkaddr) err =rvu_poll_reg (rvu, blkaddr,NIX_AF_RX_SW_SYNC ,BIT_ULL (0 ), true);if (err)dev_err (rvu->dev,"NIX RX software sync failed\n" ); + +/* As per a HW errata in 9xxx A0 silicon, HW may clear SW_SYNC[ENA] +* bit too early. Hence wait for 50us more. +*/ +if (is_rvu_9xxx_A0 (rvu)) +usleep_range (50 ,60 ); } static bool is_valid_txschq(struct rvu *rvu, int blkaddr,
@@ -2135,10 +2141,10 @@ static int nix_aq_init(struct rvu *rvu, struct rvu_block *block)/* Set admin queue endianness */ cfg =rvu_read64 (rvu, block->addr,NIX_AF_CFG );#ifdef __BIG_ENDIAN - cfg |=BIT_ULL (1 ); + cfg |=BIT_ULL (8 );rvu_write64 (rvu, block->addr,NIX_AF_CFG , cfg);#else - cfg &= ~BIT_ULL (1 ); + cfg &= ~BIT_ULL (8 );rvu_write64 (rvu, block->addr,NIX_AF_CFG , cfg);#endif
@@ -2175,6 +2181,14 @@ int rvu_nix_init(struct rvu *rvu)return 0 ; block = &hw->block[blkaddr]; +/* As per a HW errata in 9xxx A0 silicon, NIX may corrupt +* internal state when conditional clocks are turned off. +* Hence enable them. +*/ +if (is_rvu_9xxx_A0 (rvu)) +rvu_write64 (rvu, blkaddr,NIX_AF_CFG , +rvu_read64 (rvu, blkaddr,NIX_AF_CFG ) |0x5EULL ); +/* Calibrate X2P bus to check if CGX/LBK links are fine */ err =nix_calibrate_x2p (rvu, blkaddr);if (err)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +9 -3
@@ -970,7 +970,7 @@ int rvu_npc_init(struct rvu *rvu)struct npc_pkind *pkind = &rvu->hw->pkind;u64 keyz =NPC_MCAM_KEY_X2 ;int blkaddr, entry, bank, err; -u64 cfg; +u64 cfg, nibble_ena; blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 );if (blkaddr <0 ) {
@@ -1019,10 +1019,16 @@ int rvu_npc_init(struct rvu *rvu)/* Set RX and TX side MCAM search key size. * LA..LD (ltype only) + Channel */ + nibble_ena =0x49247 ;rvu_write64 (rvu, blkaddr,NPC_AF_INTFX_KEX_CFG (NIX_INTF_RX ), - ((keyz &0x3 ) <<32 ) |0x49247 ); + ((keyz &0x3 ) <<32 ) | nibble_ena); +/* Due to an errata (35786) in A0 pass silicon, parse nibble enable +* configuration has to be identical for both Rx and Tx interfaces. +*/ +if (!is_rvu_9xxx_A0 (rvu)) + nibble_ena = (1ULL <<19 ) -1 ;rvu_write64 (rvu, blkaddr,NPC_AF_INTFX_KEX_CFG (NIX_INTF_TX ), - ((keyz &0x3 ) <<32 ) | ((1ULL <<19 ) -1 )); + ((keyz &0x3 ) <<32 ) | nibble_ena); err =npc_mcam_rsrcs_init (rvu, blkaddr);if (err)
Signature · 1 line
2.7.4