Get max rx packet length and solve
Subsystems (3)
v2 cover Get max rx packet length and solve
Patchsets which resolve observed style issues in control net source files, and also implements get mtu control net api to fetch max mtu value from firmware
Changes:
V2:
- Introduced a patch to resolve style issues as mentioned in V1
- Removed OCTEP_MAX_MTU macro, as it is redundant.
V1: https://lore.kernel.org/all/[email protected]/
Shinas Rasheed (2):
octeon_ep: Solve style issues in control net files
octeon_ep: get max rx packet length from firmware
.../ethernet/marvell/octeon_ep/octep_config.h | 2 - .../marvell/octeon_ep/octep_ctrl_net.c | 42 ++++-- .../marvell/octeon_ep/octep_ctrl_net.h | 125 +++++++++++------- .../ethernet/marvell/octeon_ep/octep_main.c | 10 +- 4 files changed, 113 insertions(+), 66 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/2 octeon_ep: Solve style issues in control net files
Solve observed style issues for kernel documentation and structure declarations in control net API definitions.
---
V2:
- Introduced the patch due to kernel doc style and structure initialisation comments obtained in V1 of patch 2
.../marvell/octeon_ep/octep_ctrl_net.c | 24 ++-- .../marvell/octeon_ep/octep_ctrl_net.h | 115 ++++++++++-------- 2 files changed, 76 insertions(+), 63 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +12 -12
@@ -122,7 +122,7 @@ int octep_ctrl_net_init(struct octep_device *oct)int octep_ctrl_net_get_link_status (struct octep_device *oct,int vfid) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;int err;
@@ -139,7 +139,7 @@ int octep_ctrl_net_get_link_status(struct octep_device *oct, int vfid)int octep_ctrl_net_set_link_status (struct octep_device *oct,int vfid,bool up,bool wait_for_response) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;init_send_req (&d.msg, req, state_sz, vfid);
@@ -154,7 +154,7 @@ int octep_ctrl_net_set_link_status(struct octep_device *oct, int vfid, bool up,int octep_ctrl_net_set_rx_state (struct octep_device *oct,int vfid,bool up,bool wait_for_response) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;init_send_req (&d.msg, req, state_sz, vfid);
@@ -168,7 +168,7 @@ int octep_ctrl_net_set_rx_state(struct octep_device *oct, int vfid, bool up,int octep_ctrl_net_get_mac_addr (struct octep_device *oct,int vfid,u8 *addr) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;int err;
@@ -187,7 +187,7 @@ int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr)int octep_ctrl_net_set_mac_addr (struct octep_device *oct,int vfid,u8 *addr,bool wait_for_response) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;init_send_req (&d.msg, req, mac_sz, vfid);
@@ -201,7 +201,7 @@ int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,int octep_ctrl_net_set_mtu (struct octep_device *oct,int vfid,int mtu,bool wait_for_response) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;init_send_req (&d.msg, req, mtu_sz, vfid);
@@ -216,7 +216,7 @@ int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,struct octep_iface_rx_stats *rx_stats, struct octep_iface_tx_stats *tx_stats) { - struct octep_ctrl_net_wait_data d = {0}; + struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;struct octep_ctrl_net_h2f_resp *resp;int err;
@@ -236,7 +236,7 @@ int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,int octep_ctrl_net_get_link_info (struct octep_device *oct,int vfid,struct octep_iface_link_info *link_info) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;struct octep_ctrl_net_h2f_resp *resp;int err;
@@ -262,7 +262,7 @@ int octep_ctrl_net_set_link_info(struct octep_device *oct, int vfid, struct octep_iface_link_info *link_info, bool wait_for_response) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_req *req = &d.data.req;init_send_req (&d.msg, req, link_info_sz, vfid);
@@ -331,8 +331,8 @@ static int process_mbox_notify(struct octep_device *oct,void octep_ctrl_net_recv_fw_messages (struct octep_device *oct) {static u16 msg_sz =sizeof (union octep_ctrl_net_max_data ); -union octep_ctrl_net_max_data data = {0 }; -struct octep_ctrl_mbox_msg msg = {0 }; +union octep_ctrl_net_max_data data = {}; +struct octep_ctrl_mbox_msg msg = {};int ret; msg.hdr.s.sz = msg_sz;
@@ -356,7 +356,7 @@ void octep_ctrl_net_recv_fw_messages(struct octep_device *oct)int octep_ctrl_net_get_info (struct octep_device *oct,int vfid,struct octep_fw_info *info) { -struct octep_ctrl_net_wait_data d = {0 }; +struct octep_ctrl_net_wait_data d = {};struct octep_ctrl_net_h2f_resp *resp;struct octep_ctrl_net_h2f_req *req;int err;
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h +64 -51
200 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 2/2 octeon_ep: get max rx packet length from firmware
In reply to Shinas RasheedMax receive packet length can vary across SoCs, so this needs to be queried from respective firmware and filled by driver. A control net get mtu api should be implemented to do the same.
---
V2:
- Removed OCTEP_MAX_MTU macro as it is redundant.
V1: https://lore.kernel.org/all/[email protected]/
.../ethernet/marvell/octeon_ep/octep_config.h | 2 -- .../marvell/octeon_ep/octep_ctrl_net.c | 18 ++++++++++++++++++ .../marvell/octeon_ep/octep_ctrl_net.h | 10 ++++++++++ .../ethernet/marvell/octeon_ep/octep_main.c | 10 +++++++++- 4 files changed, 37 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeon_ep/octep_config.h +0 -2
@@ -45,8 +45,6 @@/* Minimum MTU supported by Octeon network interface */ #define OCTEP_MIN_MTU ETH_MIN_MTU -/* Maximum MTU supported by Octeon interface*/ -#define OCTEP_MAX_MTU (10000 - (ETH_HLEN + ETH_FCS_LEN))/* Default MTU */ #define OCTEP_DEFAULT_MTU 1500
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +18 -0
@@ -198,6 +198,24 @@ int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr,return octep_send_mbox_req (oct, &d, wait_for_response); } +int octep_ctrl_net_get_mtu (struct octep_device *oct,int vfid) +{ +struct octep_ctrl_net_wait_data d = {}; +struct octep_ctrl_net_h2f_req *req; +int err; + + req = &d.data.req; +init_send_req (&d.msg, req, mtu_sz, vfid); + req->hdr.s.cmd =OCTEP_CTRL_NET_H2F_CMD_MTU ; + req->mtu.cmd =OCTEP_CTRL_NET_CMD_GET ; + + err =octep_send_mbox_req (oct, &d, true); +if (err <0 ) +return err; + +return d.data.resp.mtu.val; +} +int octep_ctrl_net_set_mtu (struct octep_device *oct,int vfid,int mtu,bool wait_for_response) {
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h +10 -0
@@ -287,6 +287,16 @@ int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr);int octep_ctrl_net_set_mac_addr (struct octep_device *oct,int vfid,u8 *addr,bool wait_for_response); +/** +* octep_ctrl_net_get_mtu() - Get max MTU from firmware. +* +* @oct: non-null pointer to struct octep_device. +* @vfid: Index of virtual function. +* +* return value: mtu on success, -errno on failure. +*/ +int octep_ctrl_net_get_mtu (struct octep_device *oct,int vfid); +/** * octep_ctrl_net_set_mtu() - Set mtu in firmware. *
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +9 -1
@@ -1307,6 +1307,7 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) {struct octep_device *octep_dev =NULL ;struct net_device *netdev; +int max_rx_pktlen;int err; err =pci_enable_device (pdev);
@@ -1377,8 +1378,15 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->hw_features =NETIF_F_SG ; netdev->features |= netdev->hw_features; + + max_rx_pktlen =octep_ctrl_net_get_mtu (octep_dev,OCTEP_CTRL_NET_INVALID_VFID ); +if (max_rx_pktlen <0 ) { +dev_err (&octep_dev->pdev->dev, +"Failed to get max receive packet size; err = %d\n" , max_rx_pktlen); + goto register_dev_err; + } netdev->min_mtu =OCTEP_MIN_MTU ; - netdev->max_mtu =OCTEP_MAX_MTU ; + netdev->max_mtu = max_rx_pktlen - (ETH_HLEN +ETH_FCS_LEN ); netdev->mtu =OCTEP_DEFAULT_MTU ; err = octep_ctrl_net_get_mac_addr(octep_dev, OCTEP_CTRL_NET_INVALID_VFID,
Signature · 1 line
2.25.1
Simon Horman
reviewerRe: [PATCH net-next v2 2/2] octeon_ep: get max rx packet length from firmware
Quoted 6 lines · Shinas Rasheed
Max receive packet length can vary across SoCs, so this needs to be queried from respective firmware and filled by driver. A control net get mtu api should be implemented to do the same.
Signed-off-by Shinas Rasheed <[email protected]>
...
Quoted 13 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +1
-0@@ -1307,6 +1307,7 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) {struct octep_device *octep_dev =NULL ;struct net_device *netdev; +int max_rx_pktlen;int err; err =pci_enable_device (pdev);
drivers/net/ethernet/marvell/octeon_ep/octep_main.c static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 1386
Quoted 9 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +6
-0@@ -1377,8 +1378,15 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->hw_features =NETIF_F_SG ; netdev->features |= netdev->hw_features; + + max_rx_pktlen =octep_ctrl_net_get_mtu (octep_dev,OCTEP_CTRL_NET_INVALID_VFID ); +if (max_rx_pktlen <0 ) { +dev_err (&octep_dev->pdev->dev, +"Failed to get max receive packet size; err = %d\n" , max_rx_pktlen); + goto register_dev_err;
Hi Shinas,
This jump will cause this function to return err. But err is 0 here. Perhaps it should be set to a negative error value instead?
Quoted 10 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +2
-1+ } netdev->min_mtu =OCTEP_MIN_MTU ; - netdev->max_mtu =OCTEP_MAX_MTU ; + netdev->max_mtu = max_rx_pktlen - (ETH_HLEN +ETH_FCS_LEN ); netdev->mtu =OCTEP_DEFAULT_MTU ; err = octep_ctrl_net_get_mac_addr(octep_dev, OCTEP_CTRL_NET_INVALID_VFID,Signature · 1 line
2.25.1
RE: [EXT] Re: [PATCH net-next v2 2/2] octeon_ep: get max rx packet length from firmware
Hi Simon,
Quoted 31 lines
-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Friday, November 24, 2023 10:38 PM
To: Shinas Rasheed <[email protected]>
Cc: [email protected]; [email protected]; Haseeb Gani <[email protected]>; Vimlesh Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Suman Ghosh <[email protected]>; Veerasenareddy Burru <[email protected]>; Sathesh B Edara <[email protected]>; Eric Dumazet <[email protected]>
Subject: [EXT] Re: [PATCH net-next v2 2/2]octeon_ep: get max rx packet length from firmwareReview
Quoted 1 line
(quoted diff) +0
-0
b/drivers/net/ethernet/marvell/octeon_ep/octep_main.cdrivers/net/ethernet/marvell/octeon_ep/octep_main.c static int octep_probe(struct pci_dev *pdev,
Quoted 4 lines
index
2da00a701df2..423eec5ff3ad100644drivers/net/ethernet/marvell/octeon_ep/octep_main.c +0
-0@@ -1377,8 +1378,15 @@ static int octep_probe(struct pci_dev *pdev,const struct
pci_device_id*ent)drivers/net/ethernet/marvell/octeon_ep/octep_main.c static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
Quoted 5 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +2
-0netdev->hw_features =NETIF_F_SG ; netdev->features |= netdev->hw_features; + + max_rx_pktlen = octep_ctrl_net_get_mtu(octep_dev,
OCTEP_CTRL_NET_INVALID_VFID);drivers/net/ethernet/marvell/octeon_ep/octep_main.c static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
Quoted 3 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +3
-0+if (max_rx_pktlen <0 ) { + dev_err(&octep_dev->pdev->dev, + "Failed to get max receive packet size; err = %d\n",
max_rx_pktlen);
Quoted 6 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 1386
Quoted 1 line
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +1
-0+ goto register_dev_err;Hi Shinas,
This jump will cause this function to return err. But err is 0 here. Perhaps it should be set to a negative error value instead?
Yes I think that was a slight erroneous oversight. I see that this patch has been accepted. I shall commit a fix for the same after review in the net branch doing the same.
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 10 lines · On Wed, 22 Nov 2023 10:34:33 -0800 you wrote:
Patchsets which resolve observed style issues in control net source files, and also implements get mtu control net api to fetch max mtu value from firmware
Changes:
V2:
- Introduced a patch to resolve style issues as mentioned in V1
- RemovedOCTEP_MAX_MTUmacro, as it is redundant.[...]
Here is the summary with links:
- [net-next,v2,1/2] octeon_ep: Solve style issues in control net files
https://git.kernel.org/netdev/net-next/c/e40f4c4e50fc - [net-next,v2,2/2] octeon_ep: get max rx packet length from firmware https://git.kernel.org/netdev/net-next/c/0a5f8534e398
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html