Skip to content

Commit 2adc55c

Browse files
bwallandavem330
authored andcommitted
e1000e: specify max supported frame size in adapter struct
By putting the maximum frame size supported by the hardware into the adapter structure, the change_mtu entry point function can be cleaned up of checks for all the different max frame sizes supported by Signed-off-by: David S. Miller <[email protected]>
1 parent 3ec2a2b commit 2adc55c

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

drivers/net/e1000e/82571.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter)
341341
if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1,
342342
&eeprom_data) < 0)
343343
break;
344-
if (eeprom_data & NVM_WORD1A_ASPM_MASK)
345-
adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
344+
if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) {
345+
adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
346+
adapter->max_hw_frame_size = DEFAULT_JUMBO;
347+
}
346348
}
347349
break;
348350
default:
@@ -1672,6 +1674,7 @@ struct e1000_info e1000_82571_info = {
16721674
| FLAG_TARC_SPEED_MODE_BIT /* errata */
16731675
| FLAG_APME_CHECK_PORT_B,
16741676
.pba = 38,
1677+
.max_hw_frame_size = DEFAULT_JUMBO,
16751678
.get_variants = e1000_get_variants_82571,
16761679
.mac_ops = &e82571_mac_ops,
16771680
.phy_ops = &e82_phy_ops_igp,
@@ -1688,6 +1691,7 @@ struct e1000_info e1000_82572_info = {
16881691
| FLAG_HAS_CTRLEXT_ON_LOAD
16891692
| FLAG_TARC_SPEED_MODE_BIT, /* errata */
16901693
.pba = 38,
1694+
.max_hw_frame_size = DEFAULT_JUMBO,
16911695
.get_variants = e1000_get_variants_82571,
16921696
.mac_ops = &e82571_mac_ops,
16931697
.phy_ops = &e82_phy_ops_igp,
@@ -1706,6 +1710,7 @@ struct e1000_info e1000_82573_info = {
17061710
| FLAG_HAS_ERT
17071711
| FLAG_HAS_SWSM_ON_LOAD,
17081712
.pba = 20,
1713+
.max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
17091714
.get_variants = e1000_get_variants_82571,
17101715
.mac_ops = &e82571_mac_ops,
17111716
.phy_ops = &e82_phy_ops_m88,
@@ -1724,6 +1729,7 @@ struct e1000_info e1000_82574_info = {
17241729
| FLAG_HAS_AMT
17251730
| FLAG_HAS_CTRLEXT_ON_LOAD,
17261731
.pba = 20,
1732+
.max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
17271733
.get_variants = e1000_get_variants_82571,
17281734
.mac_ops = &e82571_mac_ops,
17291735
.phy_ops = &e82_phy_ops_bm,
@@ -1740,6 +1746,7 @@ struct e1000_info e1000_82583_info = {
17401746
| FLAG_HAS_AMT
17411747
| FLAG_HAS_CTRLEXT_ON_LOAD,
17421748
.pba = 20,
1749+
.max_hw_frame_size = DEFAULT_JUMBO,
17431750
.get_variants = e1000_get_variants_82571,
17441751
.mac_ops = &e82571_mac_ops,
17451752
.phy_ops = &e82_phy_ops_bm,

drivers/net/e1000e/e1000.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ struct e1000_info;
9696
/* Number of packet split data buffers (not including the header buffer) */
9797
#define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
9898

99+
#define DEFAULT_JUMBO 9234
100+
99101
enum e1000_boards {
100102
board_82571,
101103
board_82572,
@@ -293,6 +295,7 @@ struct e1000_adapter {
293295
u32 eeprom_wol;
294296
u32 wol;
295297
u32 pba;
298+
u32 max_hw_frame_size;
296299

297300
bool fc_autoneg;
298301

@@ -309,6 +312,7 @@ struct e1000_info {
309312
unsigned int flags;
310313
unsigned int flags2;
311314
u32 pba;
315+
u32 max_hw_frame_size;
312316
s32 (*get_variants)(struct e1000_adapter *);
313317
struct e1000_mac_operations *mac_ops;
314318
struct e1000_phy_operations *phy_ops;

drivers/net/e1000e/es2lan.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ struct e1000_info e1000_es2_info = {
14221422
| FLAG_DISABLE_FC_PAUSE_TIME /* errata */
14231423
| FLAG_TIPG_MEDIUM_FOR_80003ESLAN,
14241424
.pba = 38,
1425+
.max_hw_frame_size = DEFAULT_JUMBO,
14251426
.get_variants = e1000_get_variants_80003es2lan,
14261427
.mac_ops = &es2_mac_ops,
14271428
.phy_ops = &es2_phy_ops,

drivers/net/e1000e/ich8lan.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
382382
if (rc)
383383
return rc;
384384

385+
if (adapter->hw.phy.type == e1000_phy_ife) {
386+
adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
387+
adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
388+
}
389+
385390
if ((adapter->hw.mac.type == e1000_ich8lan) &&
386391
(adapter->hw.phy.type == e1000_phy_igp_3))
387392
adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
@@ -2595,6 +2600,7 @@ struct e1000_info e1000_ich8_info = {
25952600
| FLAG_HAS_FLASH
25962601
| FLAG_APME_IN_WUC,
25972602
.pba = 8,
2603+
.max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
25982604
.get_variants = e1000_get_variants_ich8lan,
25992605
.mac_ops = &ich8_mac_ops,
26002606
.phy_ops = &ich8_phy_ops,
@@ -2613,6 +2619,7 @@ struct e1000_info e1000_ich9_info = {
26132619
| FLAG_HAS_FLASH
26142620
| FLAG_APME_IN_WUC,
26152621
.pba = 10,
2622+
.max_hw_frame_size = DEFAULT_JUMBO,
26162623
.get_variants = e1000_get_variants_ich8lan,
26172624
.mac_ops = &ich8_mac_ops,
26182625
.phy_ops = &ich8_phy_ops,
@@ -2631,6 +2638,7 @@ struct e1000_info e1000_ich10_info = {
26312638
| FLAG_HAS_FLASH
26322639
| FLAG_APME_IN_WUC,
26332640
.pba = 10,
2641+
.max_hw_frame_size = DEFAULT_JUMBO,
26342642
.get_variants = e1000_get_variants_ich8lan,
26352643
.mac_ops = &ich8_mac_ops,
26362644
.phy_ops = &ich8_phy_ops,

drivers/net/e1000e/netdev.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4212,27 +4212,17 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
42124212
struct e1000_adapter *adapter = netdev_priv(netdev);
42134213
int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
42144214

4215-
if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) ||
4216-
(max_frame > MAX_JUMBO_FRAME_SIZE)) {
4217-
e_err("Invalid MTU setting\n");
4215+
/* Jumbo frame support */
4216+
if ((max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) &&
4217+
!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
4218+
e_err("Jumbo Frames not supported.\n");
42184219
return -EINVAL;
42194220
}
42204221

4221-
/* Jumbo frame size limits */
4222-
if (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) {
4223-
if (!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) {
4224-
e_err("Jumbo Frames not supported.\n");
4225-
return -EINVAL;
4226-
}
4227-
if (adapter->hw.phy.type == e1000_phy_ife) {
4228-
e_err("Jumbo Frames not supported.\n");
4229-
return -EINVAL;
4230-
}
4231-
}
4232-
4233-
#define MAX_STD_JUMBO_FRAME_SIZE 9234
4234-
if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
4235-
e_err("MTU > 9216 not supported.\n");
4222+
/* Supported frame sizes */
4223+
if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) ||
4224+
(max_frame > adapter->max_hw_frame_size)) {
4225+
e_err("Unsupported MTU setting\n");
42364226
return -EINVAL;
42374227
}
42384228

@@ -4848,6 +4838,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
48484838
adapter->flags2 = ei->flags2;
48494839
adapter->hw.adapter = adapter;
48504840
adapter->hw.mac.type = ei->mac;
4841+
adapter->max_hw_frame_size = ei->max_hw_frame_size;
48514842
adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
48524843

48534844
mmio_start = pci_resource_start(pdev, 0);

0 commit comments

Comments
 (0)