add PF-VF mailbox support
Subsystems (3)
v5 cover add PF-VF mailbox support
This patchset aims to add PF-VF mailbox support, its related version support, and relevant control net support for immediate functionalities such as firmware notifications to VF.
Changes:
V5:
- Refactored patches to cut out redundant changes in 1/4 patch.
V4: https://lore.kernel.org/all/[email protected]/
- Included tag [1/4] in subject of first patch of series which was lost in V3
V3: https://lore.kernel.org/all/[email protected]/
- Corrected error cleanup logic for PF-VF mbox setup
- Removed double inclusion of types.h header file in octep_pfvf_mbox.c
V2: https://lore.kernel.org/all/[email protected]/
- Removed unused variable in PATCH 1/4
V1: https://lore.kernel.org/all/[email protected]/
Shinas Rasheed (4):
octeon_ep: add PF-VF mailbox communication
octeon_ep: PF-VF mailbox version support
octeon_ep: control net framework to support VF offloads
octeon_ep: support firmware notifications for VFs
.../net/ethernet/marvell/octeon_ep/Makefile | 2 +- .../marvell/octeon_ep/octep_cn9k_pf.c | 59 ++- .../marvell/octeon_ep/octep_cnxk_pf.c | 49 +- .../marvell/octeon_ep/octep_ctrl_mbox.h | 4 +- .../marvell/octeon_ep/octep_ctrl_net.c | 6 + .../ethernet/marvell/octeon_ep/octep_main.c | 84 +++- .../ethernet/marvell/octeon_ep/octep_main.h | 46 +- .../marvell/octeon_ep/octep_pfvf_mbox.c | 450 ++++++++++++++++++ .../marvell/octeon_ep/octep_pfvf_mbox.h | 167 +++++++ .../marvell/octeon_ep/octep_regs_cn9k_pf.h | 9 + .../marvell/octeon_ep/octep_regs_cnxk_pf.h | 13 + .../net/ethernet/marvell/octeon_ep/octep_tx.h | 24 +- 12 files changed, 864 insertions(+), 49 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c create mode 100644 drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h
Signature · 1 line
2.25.1
PATCH v5 1/4 octeon_ep: add PF-VF mailbox communication
Implement mailbox communication between PF and VFs. PF-VF mailbox is used for all control commands from VF to PF and asynchronous notification messages from PF to VF.
---
V5:
- Reordered patch to exclude redundant code refactored in later patch
V4: https://lore.kernel.org/all/[email protected]/
- Include [1/4] in the subject for this patch, which was lost in V3
V3: https://lore.kernel.org/all/[email protected]/
- Corrected error cleanup logic for PF-VF mbox setup
- Removed double inclusion of types.h header file in octep_pfvf_mbox.c
V2: https://lore.kernel.org/all/[email protected]/
- Remove unused variable
V1: https://lore.kernel.org/all/[email protected]/
.../net/ethernet/marvell/octeon_ep/Makefile | 2 +- .../marvell/octeon_ep/octep_cn9k_pf.c | 59 ++- .../marvell/octeon_ep/octep_cnxk_pf.c | 46 ++- .../marvell/octeon_ep/octep_ctrl_mbox.h | 4 +- .../ethernet/marvell/octeon_ep/octep_main.c | 83 ++++- .../ethernet/marvell/octeon_ep/octep_main.h | 45 ++- .../marvell/octeon_ep/octep_pfvf_mbox.c | 335 ++++++++++++++++++ .../marvell/octeon_ep/octep_pfvf_mbox.h | 142 ++++++++ .../marvell/octeon_ep/octep_regs_cn9k_pf.h | 9 + .../marvell/octeon_ep/octep_regs_cnxk_pf.h | 13 + .../net/ethernet/marvell/octeon_ep/octep_tx.h | 24 +- 11 files changed, 713 insertions(+), 49 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c create mode 100644 drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h
drivers/net/ethernet/marvell/octeon_ep/Makefile +1 -1
@@ -7,4 +7,4 @@ obj-$(CONFIG_OCTEON_EP) += octeon_ep.o octeon_ep-y := octep_main.o octep_cn9k_pf.o octep_tx.o octep_rx.o \ octep_ethtool.o octep_ctrl_mbox.o octep_ctrl_net.o \ - octep_cnxk_pf.o + octep_pfvf_mbox.o octep_cnxk_pf.o
drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c +52 -7
92 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c +39 -7
79 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_mbox.h +3 -1
@@ -16,10 +16,12 @@* |reserved (4 bytes) | * |-------------------------------------------| * |host version (8 bytes) | +* | low 32 bits | * |host status (8 bytes) | * |host reserved (104 bytes) | * |-------------------------------------------| -* |fw version (8 bytes) | +* |fw version's (8 bytes) | +* | min=high 32 bits, max=low 32 bits | * |fw status (8 bytes) | * |fw reserved (104 bytes) | * |===========================================|
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +81 -2
136 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_main.h +26 -19
72 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c new file +335 -0
335 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h new file +142 -0
142 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cn9k_pf.h +9 -0
@@ -208,6 +208,9 @@#define CN93_SDP_R_MBOX_PF_VF_INT_START 0x10220#define CN93_SDP_R_MBOX_VF_PF_DATA_START 0x10230 +#define CN93_SDP_MBOX_VF_PF_DATA_START 0x24000 +#define CN93_SDP_MBOX_PF_VF_DATA_START 0x22000 +#define CN93_SDP_R_MBOX_PF_VF_DATA (ring) \ (CN93_SDP_R_MBOX_PF_VF_DATA_START + ((ring) * CN93_RING_OFFSET))
@@ -217,6 +220,12 @@#define CN93_SDP_R_MBOX_VF_PF_DATA (ring) \ (CN93_SDP_R_MBOX_VF_PF_DATA_START + ((ring) * CN93_RING_OFFSET)) +#define CN93_SDP_MBOX_VF_PF_DATA (ring) \ + (CN93_SDP_MBOX_VF_PF_DATA_START + ((ring) * CN93_EPVF_RING_OFFSET)) + +#define CN93_SDP_MBOX_PF_VF_DATA (ring) \ + (CN93_SDP_MBOX_PF_VF_DATA_START + ((ring) * CN93_EPVF_RING_OFFSET)) +/* ##################### Interrupt Registers ########################## */ #define CN93_SDP_R_ERR_TYPE_START 0x10400
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cnxk_pf.h +13 -0
@@ -183,6 +183,7 @@#define CNXK_SDP_R_OUT_INT_MDRT_CTL1_START 0x103A0#define CNXK_SDP_R_OUT_INT_MDRT_DBG_START 0x103C0 +#define CNXK_SDP_R_MBOX_ISM_START 0x10500#define CNXK_SDP_R_OUT_CNTS_ISM_START 0x10510#define CNXK_SDP_R_IN_CNTS_ISM_START 0x10520
@@ -204,6 +205,9 @@#define CNXK_SDP_R_OUT_INT_MDRT_DBG (ring) \ (CNXK_SDP_R_OUT_INT_MDRT_DBG_START + ((ring) * CNXK_RING_OFFSET)) +#define CNXK_SDP_R_MBOX_ISM (ring) \ + (CNXK_SDP_R_MBOX_ISM_START + ((ring) * CNXK_RING_OFFSET)) +#define CNXK_SDP_R_OUT_CNTS_ISM (ring) \ (CNXK_SDP_R_OUT_CNTS_ISM_START + ((ring) * CNXK_RING_OFFSET))
@@ -222,6 +226,9 @@#define CNXK_SDP_R_MBOX_PF_VF_INT_START 0x10220#define CNXK_SDP_R_MBOX_VF_PF_DATA_START 0x10230 +#define CNXK_SDP_MBOX_VF_PF_DATA_START 0x24000 +#define CNXK_SDP_MBOX_PF_VF_DATA_START 0x22000 +#define CNXK_SDP_R_MBOX_PF_VF_DATA (ring) \ (CNXK_SDP_R_MBOX_PF_VF_DATA_START + ((ring) * CNXK_RING_OFFSET))
@@ -231,6 +238,12 @@#define CNXK_SDP_R_MBOX_VF_PF_DATA (ring) \ (CNXK_SDP_R_MBOX_VF_PF_DATA_START + ((ring) * CNXK_RING_OFFSET)) +#define CNXK_SDP_MBOX_VF_PF_DATA (ring) \ + (CNXK_SDP_MBOX_VF_PF_DATA_START + ((ring) * CNXK_EPVF_RING_OFFSET)) + +#define CNXK_SDP_MBOX_PF_VF_DATA (ring) \ + (CNXK_SDP_MBOX_PF_VF_DATA_START + ((ring) * CNXK_EPVF_RING_OFFSET)) +/* ##################### Interrupt Registers ########################## */ #define CNXK_SDP_R_ERR_TYPE_START 0x10400
drivers/net/ethernet/marvell/octeon_ep/octep_tx.h +12 -12
@@ -61,6 +61,18 @@ struct octep_tx_buffer {/* Hardware interface Tx statistics */ struct octep_iface_tx_stats { +/* Total frames sent on the interface */ +u64 pkts; + +/* Total octets sent on the interface */ +u64 octs; + +/* Packets sent to a broadcast DMAC */ +u64 bcst; + +/* Packets sent to the multicast DMAC */ +u64 mcst; +/* Packets dropped due to excessive collisions */ u64 xscol;
@@ -77,12 +89,6 @@ struct octep_iface_tx_stats {*/ u64 scol; -/* Total octets sent on the interface */ -u64 octs; - -/* Total frames sent on the interface */ -u64 pkts; -/* Packets sent with an octet count < 64 */ u64 hist_lt64;
@@ -107,12 +113,6 @@ struct octep_iface_tx_stats {/* Packets sent with an octet count of > 1518 */ u64 hist_gt1518; -/* Packets sent to a broadcast DMAC */ -u64 bcst; - -/* Packets sent to the multicast DMAC */ -u64 mcst; -/* Packets sent that experienced a transmit underflow and were * truncated */
Signature · 1 line
2.25.1
PATCH v5 2/4 octeon_ep: PF-VF mailbox version support
In reply to Shinas RasheedAdd PF-VF mailbox initial version support
---
V5:
- Refactored patch to leave out changes moved to first patch itself
V4: https://lore.kernel.org/all/[email protected]/
- No changes
V3: https://lore.kernel.org/all/[email protected]/
- No changes
V2: https://lore.kernel.org/all/[email protected]/
- No changes
V1: https://lore.kernel.org/all/[email protected]/
.../net/ethernet/marvell/octeon_ep/octep_main.h | 1 + .../ethernet/marvell/octeon_ep/octep_pfvf_mbox.c | 15 ++++++++++++--- .../ethernet/marvell/octeon_ep/octep_pfvf_mbox.h | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_main.h +1 -0
@@ -220,6 +220,7 @@ struct octep_iface_link_info {/* The Octeon VF device specific info data structure.*/ struct octep_pfvf_info {u8 mac_addr[ETH_ALEN ]; +u32 mbox_version; };/* The Octeon device specific private data structure.
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c +12 -3
@@ -27,10 +27,18 @@ static void octep_pfvf_validate_version(struct octep_device *oct, u32 vf_id, {u32 vf_version = (u32 )cmd.s_version.version; -if (vf_version <=OCTEP_PFVF_MBOX_VERSION_V1 ) - rsp->s_version.type =OCTEP_PFVF_MBOX_TYPE_RSP_ACK ; +dev_dbg (&oct->pdev->dev,"VF id:%d VF version:%d PF version:%d\n" , + vf_id, vf_version,OCTEP_PFVF_MBOX_VERSION_CURRENT ); +if (vf_version <OCTEP_PFVF_MBOX_VERSION_CURRENT ) + rsp->s_version.version = vf_version;else - rsp->s_version.type =OCTEP_PFVF_MBOX_TYPE_RSP_NACK ; + rsp->s_version.version =OCTEP_PFVF_MBOX_VERSION_CURRENT ; + + oct->vf_info[vf_id].mbox_version = rsp->s_version.version; +dev_dbg (&oct->pdev->dev,"VF id:%d negotiated VF version:%d\n" , + vf_id, oct->vf_info[vf_id].mbox_version); + + rsp->s_version.type =OCTEP_PFVF_MBOX_TYPE_RSP_ACK ; } static void octep_pfvf_get_link_status(struct octep_device *oct, u32 vf_id,
@@ -166,6 +174,7 @@ int octep_setup_pfvf_mbox(struct octep_device *oct) goto free_mbox;memset (oct->mbox[ring],0 ,sizeof (struct octep_mbox )); +memset (&oct->vf_info[i],0 ,sizeof (struct octep_pfvf_info ));mutex_init (&oct->mbox[ring]->lock);INIT_WORK (&oct->mbox[ring]->wk.work, octep_pfvf_mbox_work); oct->mbox[ring]->wk.ctxptr = oct->mbox[ring];
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h +4 -0
@@ -13,11 +13,15 @@#define OCTEON_SDP_16K_HW_FRS 16380UL#define OCTEON_SDP_64K_HW_FRS 65531UL +/* When a new command is implemented,PF Mbox version should be bumped. +*/ enum octep_pfvf_mbox_version {OCTEP_PFVF_MBOX_VERSION_V0 ,OCTEP_PFVF_MBOX_VERSION_V1 , }; +#define OCTEP_PFVF_MBOX_VERSION_CURRENT OCTEP_PFVF_MBOX_VERSION_V1 +enum octep_pfvf_mbox_opcode {OCTEP_PFVF_MBOX_CMD_VERSION ,OCTEP_PFVF_MBOX_CMD_SET_MTU ,
Signature · 1 line
2.25.1
PATCH v5 3/4 octeon_ep: control net framework to support VF offloads
In reply to Shinas RasheedInquire firmware on supported offloads, as well as convey offloads enabled dynamically to firmware for the VFs. Implement control net API to support the same.
---
V5:
- No changes
V4: https://lore.kernel.org/all/[email protected]/
- No changes
V3: https://lore.kernel.org/all/[email protected]/
- No changes
V2: https://lore.kernel.org/all/[email protected]/
- No changes
V1: https://lore.kernel.org/all/[email protected]/
.../marvell/octeon_ep/octep_pfvf_mbox.c | 47 +++++++++++++++++++ .../marvell/octeon_ep/octep_pfvf_mbox.h | 21 ++++++++- 2 files changed, 67 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c +47 -0
@@ -158,6 +158,47 @@ static void octep_pfvf_dev_remove(struct octep_device *oct, u32 vf_id, rsp->s.type =OCTEP_PFVF_MBOX_TYPE_RSP_ACK ; } +static void octep_pfvf_get_fw_info (struct octep_device *oct,u32 vf_id, +union octep_pfvf_mbox_word cmd, +union octep_pfvf_mbox_word *rsp) +{ +struct octep_fw_info fw_info; +int err; + + err =octep_ctrl_net_get_info (oct, vf_id, &fw_info); +if (err) { + rsp->s_fw_info.type =OCTEP_PFVF_MBOX_TYPE_RSP_NACK ; +dev_err (&oct->pdev->dev,"Get VF info failed via host control Mbox\n" ); +return ; + } + + rsp->s_fw_info.pkind = fw_info.pkind; + rsp->s_fw_info.fsz = fw_info.fsz; + rsp->s_fw_info.rx_ol_flags = fw_info.rx_ol_flags; + rsp->s_fw_info.tx_ol_flags = fw_info.tx_ol_flags; + + rsp->s_fw_info.type =OCTEP_PFVF_MBOX_TYPE_RSP_ACK ; +} + +static void octep_pfvf_set_offloads (struct octep_device *oct,u32 vf_id, +union octep_pfvf_mbox_word cmd, +union octep_pfvf_mbox_word *rsp) +{ +struct octep_ctrl_net_offloads offloads = { + .rx_offloads = cmd.s_offloads.rx_ol_flags, + .tx_offloads = cmd.s_offloads.tx_ol_flags + }; +int err; + + err =octep_ctrl_net_set_offloads (oct, vf_id, &offloads, true); +if (err) { + rsp->s_offloads.type =OCTEP_PFVF_MBOX_TYPE_RSP_NACK ; +dev_err (&oct->pdev->dev,"Set VF offloads failed via host control Mbox\n" ); +return ; + } + rsp->s_offloads.type =OCTEP_PFVF_MBOX_TYPE_RSP_ACK ; +} +int octep_setup_pfvf_mbox (struct octep_device *oct) {int i =0 , num_vfs =0 , rings_per_vf =0 ;
@@ -334,6 +375,12 @@ void octep_pfvf_mbox_work(struct work_struct *work)case OCTEP_PFVF_MBOX_CMD_DEV_REMOVE :octep_pfvf_dev_remove (oct, vf_id, cmd, &rsp);break ; +case OCTEP_PFVF_MBOX_CMD_GET_FW_INFO : +octep_pfvf_get_fw_info (oct, vf_id, cmd, &rsp); +break ; +case OCTEP_PFVF_MBOX_CMD_SET_OFFLOADS : +octep_pfvf_set_offloads (oct, vf_id, cmd, &rsp); +break ;default :dev_err (&oct->pdev->dev,"PF-VF mailbox: invalid opcode %d\n" , cmd.s.opcode); rsp.s.type =OCTEP_PFVF_MBOX_TYPE_RSP_NACK ;
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h +20 -1
@@ -18,9 +18,10 @@enum octep_pfvf_mbox_version {OCTEP_PFVF_MBOX_VERSION_V0 ,OCTEP_PFVF_MBOX_VERSION_V1 , +OCTEP_PFVF_MBOX_VERSION_V2 , }; -#define OCTEP_PFVF_MBOX_VERSION_CURRENT OCTEP_PFVF_MBOX_VERSION_V1 +#define OCTEP_PFVF_MBOX_VERSION_CURRENT OCTEP_PFVF_MBOX_VERSION_V2enum octep_pfvf_mbox_opcode {OCTEP_PFVF_MBOX_CMD_VERSION ,
@@ -34,6 +35,8 @@ enum octep_pfvf_mbox_opcode {OCTEP_PFVF_MBOX_CMD_GET_LINK_STATUS ,OCTEP_PFVF_MBOX_CMD_GET_MTU ,OCTEP_PFVF_MBOX_CMD_DEV_REMOVE , +OCTEP_PFVF_MBOX_CMD_GET_FW_INFO , +OCTEP_PFVF_MBOX_CMD_SET_OFFLOADS , OCTEP_PFVF_MBOX_CMD_MAX, };
@@ -138,6 +141,22 @@ union octep_pfvf_mbox_word { u64 status:1; u64 rsvd:53; } s_link_status; +struct { +u64 opcode:8 ; +u64 type:2 ; +u64 pkind:8 ; +u64 fsz:8 ; +u64 rx_ol_flags:16 ; +u64 tx_ol_flags:16 ; +u64 rsvd:6 ; + } s_fw_info; +struct { +u64 opcode:8 ; +u64 type:2 ; +u64 rsvd:22 ; +u64 rx_ol_flags:16 ; +u64 tx_ol_flags:16 ; + } s_offloads; } __packed;void octep_pfvf_mbox_work (struct work_struct *work);
Signature · 1 line
2.25.1
PATCH v5 4/4 octeon_ep: support firmware notifications for VFs
In reply to Shinas RasheedNotifications from firmware to vf has to pass through PF control mbox and via PF-VF mailboxes. The notifications have to be parsed out from the control mbox and passed to the PF-VF mailbox in order to reach the corresponding VF. Version compatibility should also be checked before messages are passed to the mailboxes.
---
V5:
- No changes
V4: https://lore.kernel.org/all/[email protected]/
- No changes
V3: https://lore.kernel.org/all/[email protected]/
- No changes
V2: https://lore.kernel.org/all/[email protected]/
- No changes
V1: https://lore.kernel.org/all/[email protected]/
.../marvell/octeon_ep/octep_ctrl_net.c | 6 ++ .../marvell/octeon_ep/octep_pfvf_mbox.c | 58 +++++++++++++++++++ .../marvell/octeon_ep/octep_pfvf_mbox.h | 2 + 3 files changed, 66 insertions(+)
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +6 -0
@@ -13,6 +13,7 @@#include "octep_config.h" #include "octep_main.h" #include "octep_ctrl_net.h" +#include "octep_pfvf_mbox.h" /* Control plane version */ #define OCTEP_CP_VERSION_CURRENT OCTEP_CP_VERSION(1, 0, 0)
@@ -329,6 +330,11 @@ static int process_mbox_notify(struct octep_device *oct, octep_ctrl_net_f2h_cmd_versions[cmd] < OCTEP_CP_VERSION_CURRENT)return -EOPNOTSUPP ; +if (msg->hdr.s.is_vf) { +octep_pfvf_notify (oct, msg); +return 0 ; + } +switch (cmd) {case OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS :if (netif_running (netdev)) {
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c +58 -0
76 lines not on this page · raw message
drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h +2 -0
@@ -37,6 +37,7 @@ enum octep_pfvf_mbox_opcode {OCTEP_PFVF_MBOX_CMD_DEV_REMOVE ,OCTEP_PFVF_MBOX_CMD_GET_FW_INFO ,OCTEP_PFVF_MBOX_CMD_SET_OFFLOADS , +OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS , OCTEP_PFVF_MBOX_CMD_MAX, };
@@ -162,4 +163,5 @@ union octep_pfvf_mbox_word {void octep_pfvf_mbox_work (struct work_struct *work);int octep_setup_pfvf_mbox (struct octep_device *oct);void octep_delete_pfvf_mbox (struct octep_device *oct); +void octep_pfvf_notify (struct octep_device *oct,struct octep_ctrl_mbox_msg *msg);#endif
Signature · 1 line
2.25.1