Commit 81dc0741 authored by Mengyuan Lou's avatar Mengyuan Lou Committed by David S. Miller

net: wangxun: Implement the ndo change mtu interface

Add ngbe and txgbe ndo_change_mtu support.
Signed-off-by: default avatarMengyuan Lou <mengyuanlou@net-swift.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c36a77c3
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -1261,7 +1262,7 @@ static void wx_set_rx_buffer_len(struct wx *wx) ...@@ -1261,7 +1262,7 @@ static void wx_set_rx_buffer_len(struct wx *wx)
struct net_device *netdev = wx->netdev; struct net_device *netdev = wx->netdev;
u32 mhadd, max_frame; u32 mhadd, max_frame;
max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
/* adjust max frame to be at least the size of a standard frame */ /* adjust max frame to be at least the size of a standard frame */
if (max_frame < (ETH_FRAME_LEN + ETH_FCS_LEN)) if (max_frame < (ETH_FRAME_LEN + ETH_FCS_LEN))
max_frame = (ETH_FRAME_LEN + ETH_FCS_LEN); max_frame = (ETH_FRAME_LEN + ETH_FCS_LEN);
...@@ -1271,6 +1272,24 @@ static void wx_set_rx_buffer_len(struct wx *wx) ...@@ -1271,6 +1272,24 @@ static void wx_set_rx_buffer_len(struct wx *wx)
wr32(wx, WX_PSR_MAX_SZ, max_frame); wr32(wx, WX_PSR_MAX_SZ, max_frame);
} }
/**
* wx_change_mtu - Change the Maximum Transfer Unit
* @netdev: network interface device structure
* @new_mtu: new value for maximum frame size
*
* Returns 0 on success, negative on failure
**/
int wx_change_mtu(struct net_device *netdev, int new_mtu)
{
struct wx *wx = netdev_priv(netdev);
netdev->mtu = new_mtu;
wx_set_rx_buffer_len(wx);
return 0;
}
EXPORT_SYMBOL(wx_change_mtu);
/* Disable the specified rx queue */ /* Disable the specified rx queue */
void wx_disable_rx_queue(struct wx *wx, struct wx_ring *ring) void wx_disable_rx_queue(struct wx *wx, struct wx_ring *ring)
{ {
......
...@@ -23,6 +23,7 @@ void wx_flush_sw_mac_table(struct wx *wx); ...@@ -23,6 +23,7 @@ void wx_flush_sw_mac_table(struct wx *wx);
int wx_set_mac(struct net_device *netdev, void *p); int wx_set_mac(struct net_device *netdev, void *p);
void wx_disable_rx(struct wx *wx); void wx_disable_rx(struct wx *wx);
void wx_set_rx_mode(struct net_device *netdev); void wx_set_rx_mode(struct net_device *netdev);
int wx_change_mtu(struct net_device *netdev, int new_mtu);
void wx_disable_rx_queue(struct wx *wx, struct wx_ring *ring); void wx_disable_rx_queue(struct wx *wx, struct wx_ring *ring);
void wx_configure(struct wx *wx); void wx_configure(struct wx *wx);
int wx_disable_pcie_master(struct wx *wx); int wx_disable_pcie_master(struct wx *wx);
......
...@@ -300,6 +300,8 @@ ...@@ -300,6 +300,8 @@
#define WX_MAX_RXD 8192 #define WX_MAX_RXD 8192
#define WX_MAX_TXD 8192 #define WX_MAX_TXD 8192
#define WX_MAX_JUMBO_FRAME_SIZE 9432 /* max payload 9414 */
/* Supported Rx Buffer Sizes */ /* Supported Rx Buffer Sizes */
#define WX_RXBUFFER_256 256 /* Used for skb receive header */ #define WX_RXBUFFER_256 256 /* Used for skb receive header */
#define WX_RXBUFFER_2K 2048 #define WX_RXBUFFER_2K 2048
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <net/ip.h> #include <net/ip.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/if_vlan.h>
#include "../libwx/wx_type.h" #include "../libwx/wx_type.h"
#include "../libwx/wx_hw.h" #include "../libwx/wx_hw.h"
...@@ -469,6 +470,7 @@ static void ngbe_shutdown(struct pci_dev *pdev) ...@@ -469,6 +470,7 @@ static void ngbe_shutdown(struct pci_dev *pdev)
static const struct net_device_ops ngbe_netdev_ops = { static const struct net_device_ops ngbe_netdev_ops = {
.ndo_open = ngbe_open, .ndo_open = ngbe_open,
.ndo_stop = ngbe_close, .ndo_stop = ngbe_close,
.ndo_change_mtu = wx_change_mtu,
.ndo_start_xmit = wx_xmit_frame, .ndo_start_xmit = wx_xmit_frame,
.ndo_set_rx_mode = wx_set_rx_mode, .ndo_set_rx_mode = wx_set_rx_mode,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
...@@ -560,7 +562,8 @@ static int ngbe_probe(struct pci_dev *pdev, ...@@ -560,7 +562,8 @@ static int ngbe_probe(struct pci_dev *pdev,
netdev->priv_flags |= IFF_SUPP_NOFCS; netdev->priv_flags |= IFF_SUPP_NOFCS;
netdev->min_mtu = ETH_MIN_MTU; netdev->min_mtu = ETH_MIN_MTU;
netdev->max_mtu = NGBE_MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN); netdev->max_mtu = WX_MAX_JUMBO_FRAME_SIZE -
(ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
wx->bd_number = func_nums; wx->bd_number = func_nums;
/* setup the private structure */ /* setup the private structure */
......
...@@ -137,7 +137,6 @@ enum NGBE_MSCA_CMD_value { ...@@ -137,7 +137,6 @@ enum NGBE_MSCA_CMD_value {
#define NGBE_RX_PB_SIZE 42 #define NGBE_RX_PB_SIZE 42
#define NGBE_MC_TBL_SIZE 128 #define NGBE_MC_TBL_SIZE 128
#define NGBE_TDB_PB_SZ (20 * 1024) /* 160KB Packet Buffer */ #define NGBE_TDB_PB_SZ (20 * 1024) /* 160KB Packet Buffer */
#define NGBE_MAX_JUMBO_FRAME_SIZE 9432 /* max payload 9414 */
/* TX/RX descriptor defines */ /* TX/RX descriptor defines */
#define NGBE_DEFAULT_TXD 512 /* default ring size */ #define NGBE_DEFAULT_TXD 512 /* default ring size */
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <net/ip.h> #include <net/ip.h>
#include <linux/if_vlan.h>
#include "../libwx/wx_type.h" #include "../libwx/wx_type.h"
#include "../libwx/wx_lib.h" #include "../libwx/wx_lib.h"
...@@ -486,6 +487,7 @@ static void txgbe_shutdown(struct pci_dev *pdev) ...@@ -486,6 +487,7 @@ static void txgbe_shutdown(struct pci_dev *pdev)
static const struct net_device_ops txgbe_netdev_ops = { static const struct net_device_ops txgbe_netdev_ops = {
.ndo_open = txgbe_open, .ndo_open = txgbe_open,
.ndo_stop = txgbe_close, .ndo_stop = txgbe_close,
.ndo_change_mtu = wx_change_mtu,
.ndo_start_xmit = wx_xmit_frame, .ndo_start_xmit = wx_xmit_frame,
.ndo_set_rx_mode = wx_set_rx_mode, .ndo_set_rx_mode = wx_set_rx_mode,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
...@@ -603,7 +605,8 @@ static int txgbe_probe(struct pci_dev *pdev, ...@@ -603,7 +605,8 @@ static int txgbe_probe(struct pci_dev *pdev,
netdev->priv_flags |= IFF_SUPP_NOFCS; netdev->priv_flags |= IFF_SUPP_NOFCS;
netdev->min_mtu = ETH_MIN_MTU; netdev->min_mtu = ETH_MIN_MTU;
netdev->max_mtu = TXGBE_MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN); netdev->max_mtu = WX_MAX_JUMBO_FRAME_SIZE -
(ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
/* make sure the EEPROM is good */ /* make sure the EEPROM is good */
err = txgbe_validate_eeprom_checksum(wx, NULL); err = txgbe_validate_eeprom_checksum(wx, NULL);
......
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
#define TXGBE_SP_MC_TBL_SIZE 128 #define TXGBE_SP_MC_TBL_SIZE 128
#define TXGBE_SP_RX_PB_SIZE 512 #define TXGBE_SP_RX_PB_SIZE 512
#define TXGBE_SP_TDB_PB_SZ (160 * 1024) /* 160KB Packet Buffer */ #define TXGBE_SP_TDB_PB_SZ (160 * 1024) /* 160KB Packet Buffer */
#define TXGBE_MAX_JUMBO_FRAME_SIZE 9432 /* max payload 9414 */
/* TX/RX descriptor defines */ /* TX/RX descriptor defines */
#define TXGBE_DEFAULT_TXD 512 #define TXGBE_DEFAULT_TXD 512
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment