octeon_ep: get max rx packet length from firmware
Subsystems (3)
PATCH 1/1 octeon_ep: get max rx packet length from firmware
Fill max rx packet length value from firmware.
--- .../marvell/octeon_ep/octep_ctrl_net.c | 18 ++++++++++++++++++ .../marvell/octeon_ep/octep_ctrl_net.h | 9 +++++++++ .../ethernet/marvell/octeon_ep/octep_main.c | 10 +++++++++- 3 files changed, 36 insertions(+), 1 deletion(-)
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 = {0 }; +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 +9 -0
@@ -282,6 +282,15 @@ 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); +/** Get max MTU from firmware. +* +* @param oct: non-null pointer to struct octep_device. +* @param 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); +/** Set mtu in firmware. * * @param oct: non-null pointer to struct octep_device.
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +9 -1
@@ -1276,6 +1276,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);
@@ -1346,8 +1347,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
Quoted 1 line · Shinas Rasheed
Fill max rx packet length value from firmware.
Hi Shinas, thanks for the patch.
Please provide why, and make sure you're talking to the linux kernel developer audience who don't know anything about your hardware. We're interested to know why this patch is useful to the kernel and why it might need to be applied.
Quoted 13 lines
Signed-off-by Shinas Rasheed <[email protected]>--- .../marvell/octeon_ep/octep_ctrl_net.c | 18 ++++++++++++++++++ .../marvell/octeon_ep/octep_ctrl_net.h | 9 +++++++++ .../ethernet/marvell/octeon_ep/octep_main.c | 10 +++++++++- 3 files changed, 36 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +0
-0
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c int octep_ctrl_net_set_mac_addr(struct octep_device *oct, int vfid, u8 *addr, · line 203
Quoted 6 lines
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +3
-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 = {0 };
I think preferred style is now d = { }; since that doesn't mess up if the first member of the struct is an enum.
Quoted 23 lines
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +15
-0+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 +0
-0
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr); · line 291
Quoted 10 lines
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h +7
-0@@ -282,6 +282,15 @@ 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); +/** Get max MTU from firmware. +* +* @param oct: non-null pointer to struct octep_device. +* @param vfid: Index of virtual function. +* +* return value: mtu on success, -errno on failure. +*/
The above block is definitely not correctly formatted kdoc (if that's what you wanted), and you can probably get feedback about it from scripts/kernel-doc -v drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h
I see you have some correctly formatted doc in octep_tx.c
Quoted 22 lines
drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h +2
-0+int octep_ctrl_net_get_mtu (struct octep_device *oct,int vfid); +/** Set mtu in firmware. * * @param oct: non-null pointer to struct octep_device. drivers/net/ethernet/marvell/octeon_ep/octep_main.c +2
-0@@ -1276,6 +1276,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);@@ -1346,8 +1347,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; +
drivers/net/ethernet/marvell/octeon_ep/octep_main.c static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 1359
Quoted 10 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +7
-1+ 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 ;
Not part of this patch, but was there a point to setting the mtu here without telling the netdev? most of the time it seems sufficient to just set max and min since the kernel default is already 1500 (which your internal define also duplicates)
Mostly the code seems fine.
Quoted 20 lines
-----Original Message-----
From: Jesse Brandeburg <[email protected]>
Sent: Wednesday, November 22, 2023 2:34 AM
To: Shinas Rasheed <[email protected]>; [email protected]; [email protected]
Cc: Haseeb Gani <[email protected]>; Vimlesh Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Veerasenareddy Burru <[email protected]>; Sathesh B Edara <[email protected]>; Eric Dumazet <[email protected]>
Subject: [EXT] Re: [PATCH net-next v1]octeon_ep: get max rx packet length from firmwareExternal Email
----------------------------------------------------------------------
On 11/21/2023 11:12 AM, Shinas Rasheed wrote:
Quoted 8 lines
Quoted 1 line
Fill max rx packet length value from firmware.
Hi Shinas, thanks for the patch.
Please provide why, and make sure you're talking to the linux kernel developer audience who don't know anything about your hardware. We're interested to know why this patch is useful to the kernel and why it might need to be applied.
Sure will update that in the changelog in the next version.
Quoted 8 lines
Quoted 7 lines
+/** Get max MTU from firmware.
+ *
+ * @param oct: non-null pointer to structoctep_device.
+ * @param vfid: Index of virtual function.
+ *
+ * return value: mtu on success, -errno on failure.
+ */
Quoted 6 lines
The above block is definitely not correctly formatted kdoc (if that's what you wanted), and you can probably get feedback about it from
scripts/kernel-doc-vdrivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.hI see you have some correctly formatted doc in
octep_tx.c
I'll see to it to properly format it.
Quoted 26 lines
Review
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
3cee69b3ac38..f9c539178114100644drivers/net/ethernet/marvell/octeon_ep/octep_main.c +0
-0@@ -1276,6 +1276,7 @@ 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,
Quoted 8 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +1
-0{struct octep_device *octep_dev =NULL ;struct net_device *netdev; +int max_rx_pktlen;int err; err =pci_enable_device (pdev);@@ -1346,8 +1347,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 11 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 1359
Quoted 6 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +3
-1+ 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 ;Not part of this patch, but was there a point to setting the mtu here without telling the netdev? most of the time it seems sufficient to just set max and min since the kernel default is already 1500 (which your internal define also duplicates)
I suppose that piece of code is redundant, but serves to atleast say that the default expected is 1500 for the device.
Quoted 75 lines
Signed-off-by Shinas Rasheed <[email protected]>---
.../marvell/octeon_ep/octep_ctrl_net.c | 18 ++++++++++++++++++ .../marvell/octeon_ep/octep_ctrl_net.h | 9 +++++++++ .../ethernet/marvell/octeon_ep/octep_main.c | 10 +++++++++- 3 files changed, 36 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +17
-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 = {0 }; +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 +9
-0@@ -282,6 +282,15 @@ int octep_ctrl_net_get_mac_addr(struct octep_device *oct, int vfid, u8 *addr); int octep_ctrl_net_set_mac_addr(structoctep_device *oct,int vfid,u8 *addr,bool wait_for_response); +/** Get max MTU from firmware. +* +* @param oct: non-null pointer to struct octep_device. +* @param 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); +/** Set mtu in firmware. * * @param oct: non-null pointer to struct
octep_device.drivers/net/ethernet/marvell/octeon_ep/octep_main.c +1
-0@@ -1276,6 +1276,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);@@ -1346,8 +1347,15 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->hw_features = NETIF_F_SG;
drivers/net/ethernet/marvell/octeon_ep/octep_main.c static int octep_probe(struct pci_dev *pdev, · line 1359
Quoted 10 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +7
-0netdev->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; + }
[Suman] Do we need to check if max_rx_pktlen <= OCTEP_MAX_MTU as well? If not, then this macro is not required further after the change?
Quoted 10 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +1
-1netdev->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,
--
2.25.1
Hi Suman
Quoted 17 lines
-----Original Message-----
From: Suman Ghosh <[email protected]>
Sent: Wednesday, November 22, 2023 10:13 AM
To: Shinas Rasheed <[email protected]>; [email protected]; [email protected]
Cc: Haseeb Gani <[email protected]>; Vimlesh Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Shinas Rasheed <[email protected]>; Veerasenareddy Burru <[email protected]>; Sathesh B Edara <[email protected]>; Eric Dumazet <[email protected]>
Subject: RE: [EXT] [PATCH net-next v1]octeon_ep: get max rx packet length from firmwareQuoted 3 lines
(quoted diff) +0
-0@@ -1346,8 +1347,15 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
Quoted 13 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 1356
Quoted 11 lines
drivers/net/ethernet/marvell/octeon_ep/octep_main.c +7
-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 ); +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; + }[Suman] Do we need to check if
max_rx_pktlen<=OCTEP_MAX_MTUas well? If not, then this macro is not required further after the change?
I suppose we should check this.