diff options
author | Bruce Allan <bruce.w.allan@intel.com> | 2009-06-02 07:28:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-06-03 05:46:33 -0400 |
commit | 2adc55c959940fc680074392eddbd5585a76f3d9 (patch) | |
tree | bf5050070f1f0ef3dd6d1f951d0a50c7ac8aa161 /drivers/net | |
parent | 3ec2a2b80f3eb53851fe4cef9e65b5d33376ef89 (diff) |
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 <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/e1000e/82571.c | 11 | ||||
-rw-r--r-- | drivers/net/e1000e/e1000.h | 4 | ||||
-rw-r--r-- | drivers/net/e1000e/es2lan.c | 1 | ||||
-rw-r--r-- | drivers/net/e1000e/ich8lan.c | 8 | ||||
-rw-r--r-- | drivers/net/e1000e/netdev.c | 27 |
5 files changed, 31 insertions, 20 deletions
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c index 6c01a2072c87..8203964373ce 100644 --- a/drivers/net/e1000e/82571.c +++ b/drivers/net/e1000e/82571.c | |||
@@ -341,8 +341,10 @@ static s32 e1000_get_variants_82571(struct e1000_adapter *adapter) | |||
341 | if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1, | 341 | if (e1000_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1, |
342 | &eeprom_data) < 0) | 342 | &eeprom_data) < 0) |
343 | break; | 343 | break; |
344 | if (eeprom_data & NVM_WORD1A_ASPM_MASK) | 344 | if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) { |
345 | adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES; | 345 | adapter->flags |= FLAG_HAS_JUMBO_FRAMES; |
346 | adapter->max_hw_frame_size = DEFAULT_JUMBO; | ||
347 | } | ||
346 | } | 348 | } |
347 | break; | 349 | break; |
348 | default: | 350 | default: |
@@ -1672,6 +1674,7 @@ struct e1000_info e1000_82571_info = { | |||
1672 | | FLAG_TARC_SPEED_MODE_BIT /* errata */ | 1674 | | FLAG_TARC_SPEED_MODE_BIT /* errata */ |
1673 | | FLAG_APME_CHECK_PORT_B, | 1675 | | FLAG_APME_CHECK_PORT_B, |
1674 | .pba = 38, | 1676 | .pba = 38, |
1677 | .max_hw_frame_size = DEFAULT_JUMBO, | ||
1675 | .get_variants = e1000_get_variants_82571, | 1678 | .get_variants = e1000_get_variants_82571, |
1676 | .mac_ops = &e82571_mac_ops, | 1679 | .mac_ops = &e82571_mac_ops, |
1677 | .phy_ops = &e82_phy_ops_igp, | 1680 | .phy_ops = &e82_phy_ops_igp, |
@@ -1688,6 +1691,7 @@ struct e1000_info e1000_82572_info = { | |||
1688 | | FLAG_HAS_CTRLEXT_ON_LOAD | 1691 | | FLAG_HAS_CTRLEXT_ON_LOAD |
1689 | | FLAG_TARC_SPEED_MODE_BIT, /* errata */ | 1692 | | FLAG_TARC_SPEED_MODE_BIT, /* errata */ |
1690 | .pba = 38, | 1693 | .pba = 38, |
1694 | .max_hw_frame_size = DEFAULT_JUMBO, | ||
1691 | .get_variants = e1000_get_variants_82571, | 1695 | .get_variants = e1000_get_variants_82571, |
1692 | .mac_ops = &e82571_mac_ops, | 1696 | .mac_ops = &e82571_mac_ops, |
1693 | .phy_ops = &e82_phy_ops_igp, | 1697 | .phy_ops = &e82_phy_ops_igp, |
@@ -1706,6 +1710,7 @@ struct e1000_info e1000_82573_info = { | |||
1706 | | FLAG_HAS_ERT | 1710 | | FLAG_HAS_ERT |
1707 | | FLAG_HAS_SWSM_ON_LOAD, | 1711 | | FLAG_HAS_SWSM_ON_LOAD, |
1708 | .pba = 20, | 1712 | .pba = 20, |
1713 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, | ||
1709 | .get_variants = e1000_get_variants_82571, | 1714 | .get_variants = e1000_get_variants_82571, |
1710 | .mac_ops = &e82571_mac_ops, | 1715 | .mac_ops = &e82571_mac_ops, |
1711 | .phy_ops = &e82_phy_ops_m88, | 1716 | .phy_ops = &e82_phy_ops_m88, |
@@ -1724,6 +1729,7 @@ struct e1000_info e1000_82574_info = { | |||
1724 | | FLAG_HAS_AMT | 1729 | | FLAG_HAS_AMT |
1725 | | FLAG_HAS_CTRLEXT_ON_LOAD, | 1730 | | FLAG_HAS_CTRLEXT_ON_LOAD, |
1726 | .pba = 20, | 1731 | .pba = 20, |
1732 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, | ||
1727 | .get_variants = e1000_get_variants_82571, | 1733 | .get_variants = e1000_get_variants_82571, |
1728 | .mac_ops = &e82571_mac_ops, | 1734 | .mac_ops = &e82571_mac_ops, |
1729 | .phy_ops = &e82_phy_ops_bm, | 1735 | .phy_ops = &e82_phy_ops_bm, |
@@ -1740,6 +1746,7 @@ struct e1000_info e1000_82583_info = { | |||
1740 | | FLAG_HAS_AMT | 1746 | | FLAG_HAS_AMT |
1741 | | FLAG_HAS_CTRLEXT_ON_LOAD, | 1747 | | FLAG_HAS_CTRLEXT_ON_LOAD, |
1742 | .pba = 20, | 1748 | .pba = 20, |
1749 | .max_hw_frame_size = DEFAULT_JUMBO, | ||
1743 | .get_variants = e1000_get_variants_82571, | 1750 | .get_variants = e1000_get_variants_82571, |
1744 | .mac_ops = &e82571_mac_ops, | 1751 | .mac_ops = &e82571_mac_ops, |
1745 | .phy_ops = &e82_phy_ops_bm, | 1752 | .phy_ops = &e82_phy_ops_bm, |
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h index f37360aa12a8..b9dc612082e0 100644 --- a/drivers/net/e1000e/e1000.h +++ b/drivers/net/e1000e/e1000.h | |||
@@ -96,6 +96,8 @@ struct e1000_info; | |||
96 | /* Number of packet split data buffers (not including the header buffer) */ | 96 | /* Number of packet split data buffers (not including the header buffer) */ |
97 | #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1) | 97 | #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1) |
98 | 98 | ||
99 | #define DEFAULT_JUMBO 9234 | ||
100 | |||
99 | enum e1000_boards { | 101 | enum e1000_boards { |
100 | board_82571, | 102 | board_82571, |
101 | board_82572, | 103 | board_82572, |
@@ -293,6 +295,7 @@ struct e1000_adapter { | |||
293 | u32 eeprom_wol; | 295 | u32 eeprom_wol; |
294 | u32 wol; | 296 | u32 wol; |
295 | u32 pba; | 297 | u32 pba; |
298 | u32 max_hw_frame_size; | ||
296 | 299 | ||
297 | bool fc_autoneg; | 300 | bool fc_autoneg; |
298 | 301 | ||
@@ -309,6 +312,7 @@ struct e1000_info { | |||
309 | unsigned int flags; | 312 | unsigned int flags; |
310 | unsigned int flags2; | 313 | unsigned int flags2; |
311 | u32 pba; | 314 | u32 pba; |
315 | u32 max_hw_frame_size; | ||
312 | s32 (*get_variants)(struct e1000_adapter *); | 316 | s32 (*get_variants)(struct e1000_adapter *); |
313 | struct e1000_mac_operations *mac_ops; | 317 | struct e1000_mac_operations *mac_ops; |
314 | struct e1000_phy_operations *phy_ops; | 318 | struct e1000_phy_operations *phy_ops; |
diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c index 8964838c686b..6cc3bdf4acdb 100644 --- a/drivers/net/e1000e/es2lan.c +++ b/drivers/net/e1000e/es2lan.c | |||
@@ -1422,6 +1422,7 @@ struct e1000_info e1000_es2_info = { | |||
1422 | | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ | 1422 | | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ |
1423 | | FLAG_TIPG_MEDIUM_FOR_80003ESLAN, | 1423 | | FLAG_TIPG_MEDIUM_FOR_80003ESLAN, |
1424 | .pba = 38, | 1424 | .pba = 38, |
1425 | .max_hw_frame_size = DEFAULT_JUMBO, | ||
1425 | .get_variants = e1000_get_variants_80003es2lan, | 1426 | .get_variants = e1000_get_variants_80003es2lan, |
1426 | .mac_ops = &es2_mac_ops, | 1427 | .mac_ops = &es2_mac_ops, |
1427 | .phy_ops = &es2_phy_ops, | 1428 | .phy_ops = &es2_phy_ops, |
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c index 6d1aab6316ba..b63d9878b0ac 100644 --- a/drivers/net/e1000e/ich8lan.c +++ b/drivers/net/e1000e/ich8lan.c | |||
@@ -382,6 +382,11 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) | |||
382 | if (rc) | 382 | if (rc) |
383 | return rc; | 383 | return rc; |
384 | 384 | ||
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 | |||
385 | if ((adapter->hw.mac.type == e1000_ich8lan) && | 390 | if ((adapter->hw.mac.type == e1000_ich8lan) && |
386 | (adapter->hw.phy.type == e1000_phy_igp_3)) | 391 | (adapter->hw.phy.type == e1000_phy_igp_3)) |
387 | adapter->flags |= FLAG_LSC_GIG_SPEED_DROP; | 392 | adapter->flags |= FLAG_LSC_GIG_SPEED_DROP; |
@@ -2595,6 +2600,7 @@ struct e1000_info e1000_ich8_info = { | |||
2595 | | FLAG_HAS_FLASH | 2600 | | FLAG_HAS_FLASH |
2596 | | FLAG_APME_IN_WUC, | 2601 | | FLAG_APME_IN_WUC, |
2597 | .pba = 8, | 2602 | .pba = 8, |
2603 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, | ||
2598 | .get_variants = e1000_get_variants_ich8lan, | 2604 | .get_variants = e1000_get_variants_ich8lan, |
2599 | .mac_ops = &ich8_mac_ops, | 2605 | .mac_ops = &ich8_mac_ops, |
2600 | .phy_ops = &ich8_phy_ops, | 2606 | .phy_ops = &ich8_phy_ops, |
@@ -2613,6 +2619,7 @@ struct e1000_info e1000_ich9_info = { | |||
2613 | | FLAG_HAS_FLASH | 2619 | | FLAG_HAS_FLASH |
2614 | | FLAG_APME_IN_WUC, | 2620 | | FLAG_APME_IN_WUC, |
2615 | .pba = 10, | 2621 | .pba = 10, |
2622 | .max_hw_frame_size = DEFAULT_JUMBO, | ||
2616 | .get_variants = e1000_get_variants_ich8lan, | 2623 | .get_variants = e1000_get_variants_ich8lan, |
2617 | .mac_ops = &ich8_mac_ops, | 2624 | .mac_ops = &ich8_mac_ops, |
2618 | .phy_ops = &ich8_phy_ops, | 2625 | .phy_ops = &ich8_phy_ops, |
@@ -2631,6 +2638,7 @@ struct e1000_info e1000_ich10_info = { | |||
2631 | | FLAG_HAS_FLASH | 2638 | | FLAG_HAS_FLASH |
2632 | | FLAG_APME_IN_WUC, | 2639 | | FLAG_APME_IN_WUC, |
2633 | .pba = 10, | 2640 | .pba = 10, |
2641 | .max_hw_frame_size = DEFAULT_JUMBO, | ||
2634 | .get_variants = e1000_get_variants_ich8lan, | 2642 | .get_variants = e1000_get_variants_ich8lan, |
2635 | .mac_ops = &ich8_mac_ops, | 2643 | .mac_ops = &ich8_mac_ops, |
2636 | .phy_ops = &ich8_phy_ops, | 2644 | .phy_ops = &ich8_phy_ops, |
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index b7a46c513783..4072fbb6493d 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c | |||
@@ -4212,27 +4212,17 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
4212 | struct e1000_adapter *adapter = netdev_priv(netdev); | 4212 | struct e1000_adapter *adapter = netdev_priv(netdev); |
4213 | int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; | 4213 | int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; |
4214 | 4214 | ||
4215 | if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) || | 4215 | /* Jumbo frame support */ |
4216 | (max_frame > MAX_JUMBO_FRAME_SIZE)) { | 4216 | if ((max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) && |
4217 | e_err("Invalid MTU setting\n"); | 4217 | !(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) { |
4218 | e_err("Jumbo Frames not supported.\n"); | ||
4218 | return -EINVAL; | 4219 | return -EINVAL; |
4219 | } | 4220 | } |
4220 | 4221 | ||
4221 | /* Jumbo frame size limits */ | 4222 | /* Supported frame sizes */ |
4222 | if (max_frame > ETH_FRAME_LEN + ETH_FCS_LEN) { | 4223 | if ((new_mtu < ETH_ZLEN + ETH_FCS_LEN + VLAN_HLEN) || |
4223 | if (!(adapter->flags & FLAG_HAS_JUMBO_FRAMES)) { | 4224 | (max_frame > adapter->max_hw_frame_size)) { |
4224 | e_err("Jumbo Frames not supported.\n"); | 4225 | e_err("Unsupported MTU setting\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"); | ||
4236 | return -EINVAL; | 4226 | return -EINVAL; |
4237 | } | 4227 | } |
4238 | 4228 | ||
@@ -4848,6 +4838,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, | |||
4848 | adapter->flags2 = ei->flags2; | 4838 | adapter->flags2 = ei->flags2; |
4849 | adapter->hw.adapter = adapter; | 4839 | adapter->hw.adapter = adapter; |
4850 | adapter->hw.mac.type = ei->mac; | 4840 | adapter->hw.mac.type = ei->mac; |
4841 | adapter->max_hw_frame_size = ei->max_hw_frame_size; | ||
4851 | adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; | 4842 | adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; |
4852 | 4843 | ||
4853 | mmio_start = pci_resource_start(pdev, 0); | 4844 | mmio_start = pci_resource_start(pdev, 0); |