Message ID | 20231122183435.2510656-3-srasheed@marvell.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 0a5f8534e3986b636570f4d6d32e22af7d868d45 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Get max rx packet length and solve | expand |
On Wed, Nov 22, 2023 at 10:34:35AM -0800, Shinas Rasheed wrote: > 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 <srasheed@marvell.com> ... > diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c > index 2da00a701df2..423eec5ff3ad 100644 > --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c > +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c > @@ -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; 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? > + } > 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, > -- > 2.25.1 >
Hi Simon, > -----Original Message----- > From: Simon Horman <horms@kernel.org> > Sent: Friday, November 24, 2023 10:38 PM > To: Shinas Rasheed <srasheed@marvell.com> > Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Haseeb Gani > <hgani@marvell.com>; Vimlesh Kumar <vimleshk@marvell.com>; > egallen@redhat.com; mschmidt@redhat.com; pabeni@redhat.com; > kuba@kernel.org; davem@davemloft.net; wizhao@redhat.com; > konguyen@redhat.com; jesse.brandeburg@intel.com; Suman Ghosh > <sumang@marvell.com>; Veerasenareddy Burru <vburru@marvell.com>; > Sathesh B Edara <sedara@marvell.com>; Eric Dumazet > <edumazet@google.com> > Subject: [EXT] Re: [PATCH net-next v2 2/2] octeon_ep: get max rx packet > length from firmware > > diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c > b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c > > index 2da00a701df2..423eec5ff3ad 100644 > > --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c > > +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c > > @@ -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? 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.
diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_config.h b/drivers/net/ethernet/marvell/octeon_ep/octep_config.h index 91cfa19c65b9..4c937ba5589f 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_config.h +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_config.h @@ -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 diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c b/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c index 2eeeaa7188b1..5fa596c674da 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c @@ -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) { diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h b/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h index 02b8fcf890d0..a2463b460ad9 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h @@ -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. * diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 2da00a701df2..423eec5ff3ad 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -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,
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 <srasheed@marvell.com> --- V2: - Removed OCTEP_MAX_MTU macro as it is redundant. V1: https://lore.kernel.org/all/20231121191224.2489474-1-srasheed@marvell.com/ .../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(-)