Skip to content

Commit

Permalink
octeon_ep: get max rx packet length from firmware
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Shinas Rasheed authored and David S. Miller committed Nov 24, 2023
1 parent e40f4c4 commit 0a5f853
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 0 additions & 2 deletions drivers/net/ethernet/marvell/octeon_ep/octep_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 10 additions & 0 deletions drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
10 changes: 9 additions & 1 deletion drivers/net/ethernet/marvell/octeon_ep/octep_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0a5f853

Please sign in to comment.