net: hinic: Set max_mtu/min_mtu directly to simplify the code.
Set max_mtu/min_mtu directly to avoid making the validity judgment when set mtu, because the judgment is made in net/core: dev_validate_mtu, so to simplify the code. Signed-off-by: caihuoqing <cai.huoqing@linux.dev> Link: https://lore.kernel.org/r/20221024103349.4494-1-cai.huoqing@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
a264228c8b
commit
022f19cf36
3 changed files with 7 additions and 17 deletions
|
@ -22,6 +22,10 @@
|
||||||
|
|
||||||
#define LP_PKT_CNT 64
|
#define LP_PKT_CNT 64
|
||||||
|
|
||||||
|
#define HINIC_MAX_JUMBO_FRAME_SIZE 15872
|
||||||
|
#define HINIC_MAX_MTU_SIZE (HINIC_MAX_JUMBO_FRAME_SIZE - ETH_HLEN - ETH_FCS_LEN)
|
||||||
|
#define HINIC_MIN_MTU_SIZE 256
|
||||||
|
|
||||||
enum hinic_flags {
|
enum hinic_flags {
|
||||||
HINIC_LINK_UP = BIT(0),
|
HINIC_LINK_UP = BIT(0),
|
||||||
HINIC_INTF_UP = BIT(1),
|
HINIC_INTF_UP = BIT(1),
|
||||||
|
|
|
@ -1187,7 +1187,8 @@ static int nic_dev_init(struct pci_dev *pdev)
|
||||||
else
|
else
|
||||||
netdev->netdev_ops = &hinicvf_netdev_ops;
|
netdev->netdev_ops = &hinicvf_netdev_ops;
|
||||||
|
|
||||||
netdev->max_mtu = ETH_MAX_MTU;
|
netdev->max_mtu = HINIC_MAX_MTU_SIZE;
|
||||||
|
netdev->min_mtu = HINIC_MIN_MTU_SIZE;
|
||||||
|
|
||||||
nic_dev = netdev_priv(netdev);
|
nic_dev = netdev_priv(netdev);
|
||||||
nic_dev->netdev = netdev;
|
nic_dev->netdev = netdev;
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
#include "hinic_port.h"
|
#include "hinic_port.h"
|
||||||
#include "hinic_dev.h"
|
#include "hinic_dev.h"
|
||||||
|
|
||||||
#define HINIC_MIN_MTU_SIZE 256
|
|
||||||
#define HINIC_MAX_JUMBO_FRAME_SIZE 15872
|
|
||||||
|
|
||||||
enum mac_op {
|
enum mac_op {
|
||||||
MAC_DEL,
|
MAC_DEL,
|
||||||
MAC_SET,
|
MAC_SET,
|
||||||
|
@ -147,24 +144,12 @@ int hinic_port_get_mac(struct hinic_dev *nic_dev, u8 *addr)
|
||||||
**/
|
**/
|
||||||
int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu)
|
int hinic_port_set_mtu(struct hinic_dev *nic_dev, int new_mtu)
|
||||||
{
|
{
|
||||||
struct net_device *netdev = nic_dev->netdev;
|
|
||||||
struct hinic_hwdev *hwdev = nic_dev->hwdev;
|
struct hinic_hwdev *hwdev = nic_dev->hwdev;
|
||||||
struct hinic_port_mtu_cmd port_mtu_cmd;
|
struct hinic_port_mtu_cmd port_mtu_cmd;
|
||||||
struct hinic_hwif *hwif = hwdev->hwif;
|
struct hinic_hwif *hwif = hwdev->hwif;
|
||||||
u16 out_size = sizeof(port_mtu_cmd);
|
u16 out_size = sizeof(port_mtu_cmd);
|
||||||
struct pci_dev *pdev = hwif->pdev;
|
struct pci_dev *pdev = hwif->pdev;
|
||||||
int err, max_frame;
|
int err;
|
||||||
|
|
||||||
if (new_mtu < HINIC_MIN_MTU_SIZE) {
|
|
||||||
netif_err(nic_dev, drv, netdev, "mtu < MIN MTU size");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
|
|
||||||
if (max_frame > HINIC_MAX_JUMBO_FRAME_SIZE) {
|
|
||||||
netif_err(nic_dev, drv, netdev, "mtu > MAX MTU size");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
port_mtu_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
|
port_mtu_cmd.func_idx = HINIC_HWIF_FUNC_IDX(hwif);
|
||||||
port_mtu_cmd.mtu = new_mtu;
|
port_mtu_cmd.mtu = new_mtu;
|
||||||
|
|
Loading…
Add table
Reference in a new issue