aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2008-06-23 07:36:56 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-04 08:46:54 -0400
commit532f4aee934cf26f1905fae101ac9f0ba3087f21 (patch)
treee90f06c06dd86f6168961e09f21655a51d08ed25 /drivers
parentda02b23192e8c1dc6830fc38840ea1c5e416a43c (diff)
ipg: run-time configurable jumbo frame support
Make jumbo frame support configurable via ifconfig mtu option as suggested by Stephen Hemminger. Cc: Stephen Hemminger <stephen.hemminger@vyatta.com> Tested-by: Andrew Savchenko <Bircoph@list.ru> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ipg.c42
-rw-r--r--drivers/net/ipg.h85
2 files changed, 32 insertions, 95 deletions
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 57395b9587dc..7373dafbb3f7 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -42,7 +42,6 @@
42#define ipg_r16(reg) ioread16(ioaddr + (reg)) 42#define ipg_r16(reg) ioread16(ioaddr + (reg))
43#define ipg_r8(reg) ioread8(ioaddr + (reg)) 43#define ipg_r8(reg) ioread8(ioaddr + (reg))
44 44
45#define JUMBO_FRAME_4k_ONLY
46enum { 45enum {
47 netdev_io_size = 128 46 netdev_io_size = 128
48}; 47};
@@ -55,6 +54,14 @@ MODULE_DESCRIPTION("IC Plus IP1000 Gigabit Ethernet Adapter Linux Driver");
55MODULE_LICENSE("GPL"); 54MODULE_LICENSE("GPL");
56 55
57/* 56/*
57 * Defaults
58 */
59#define IPG_MAX_RXFRAME_SIZE 0x0600
60#define IPG_RXFRAG_SIZE 0x0600
61#define IPG_RXSUPPORT_SIZE 0x0600
62#define IPG_IS_JUMBO false
63
64/*
58 * Variable record -- index by leading revision/length 65 * Variable record -- index by leading revision/length
59 * Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN 66 * Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN
60 */ 67 */
@@ -1805,9 +1812,6 @@ static int ipg_nic_open(struct net_device *dev)
1805 sp->jumbo.current_size = 0; 1812 sp->jumbo.current_size = 0;
1806 sp->jumbo.skb = NULL; 1813 sp->jumbo.skb = NULL;
1807 1814
1808 if (IPG_TXFRAG_SIZE)
1809 dev->mtu = IPG_TXFRAG_SIZE;
1810
1811 /* Enable transmit and receive operation of the IPG. */ 1815 /* Enable transmit and receive operation of the IPG. */
1812 ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_RX_ENABLE | IPG_MC_TX_ENABLE) & 1816 ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_RX_ENABLE | IPG_MC_TX_ENABLE) &
1813 IPG_MC_RSVD_MASK, MAC_CTRL); 1817 IPG_MC_RSVD_MASK, MAC_CTRL);
@@ -2116,6 +2120,7 @@ static int ipg_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2116static int ipg_nic_change_mtu(struct net_device *dev, int new_mtu) 2120static int ipg_nic_change_mtu(struct net_device *dev, int new_mtu)
2117{ 2121{
2118 struct ipg_nic_private *sp = netdev_priv(dev); 2122 struct ipg_nic_private *sp = netdev_priv(dev);
2123 int err;
2119 2124
2120 /* Function to accomodate changes to Maximum Transfer Unit 2125 /* Function to accomodate changes to Maximum Transfer Unit
2121 * (or MTU) of IPG NIC. Cannot use default function since 2126 * (or MTU) of IPG NIC. Cannot use default function since
@@ -2124,16 +2129,33 @@ static int ipg_nic_change_mtu(struct net_device *dev, int new_mtu)
2124 2129
2125 IPG_DEBUG_MSG("_nic_change_mtu\n"); 2130 IPG_DEBUG_MSG("_nic_change_mtu\n");
2126 2131
2127 /* Check that the new MTU value is between 68 (14 byte header, 46 2132 /*
2128 * byte payload, 4 byte FCS) and IPG_MAX_RXFRAME_SIZE, which 2133 * Check that the new MTU value is between 68 (14 byte header, 46 byte
2129 * corresponds to the MAXFRAMESIZE register in the IPG. 2134 * payload, 4 byte FCS) and 10 KB, which is the largest supported MTU.
2130 */ 2135 */
2131 if ((new_mtu < 68) || (new_mtu > sp->max_rxframe_size)) 2136 if (new_mtu < 68 || new_mtu > 10240)
2132 return -EINVAL; 2137 return -EINVAL;
2133 2138
2139 err = ipg_nic_stop(dev);
2140 if (err)
2141 return err;
2142
2134 dev->mtu = new_mtu; 2143 dev->mtu = new_mtu;
2135 2144
2136 return 0; 2145 sp->max_rxframe_size = new_mtu;
2146
2147 sp->rxfrag_size = new_mtu;
2148 if (sp->rxfrag_size > 4088)
2149 sp->rxfrag_size = 4088;
2150
2151 sp->rxsupport_size = sp->max_rxframe_size;
2152
2153 if (new_mtu > 0x0600)
2154 sp->is_jumbo = true;
2155 else
2156 sp->is_jumbo = false;
2157
2158 return ipg_nic_open(dev);
2137} 2159}
2138 2160
2139static int ipg_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2161static int ipg_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -2238,7 +2260,7 @@ static int __devinit ipg_probe(struct pci_dev *pdev,
2238 spin_lock_init(&sp->lock); 2260 spin_lock_init(&sp->lock);
2239 mutex_init(&sp->mii_mutex); 2261 mutex_init(&sp->mii_mutex);
2240 2262
2241 sp->is_jumbo = IPG_JUMBO; 2263 sp->is_jumbo = IPG_IS_JUMBO;
2242 sp->rxfrag_size = IPG_RXFRAG_SIZE; 2264 sp->rxfrag_size = IPG_RXFRAG_SIZE;
2243 sp->rxsupport_size = IPG_RXSUPPORT_SIZE; 2265 sp->rxsupport_size = IPG_RXSUPPORT_SIZE;
2244 sp->max_rxframe_size = IPG_MAX_RXFRAME_SIZE; 2266 sp->max_rxframe_size = IPG_MAX_RXFRAME_SIZE;
diff --git a/drivers/net/ipg.h b/drivers/net/ipg.h
index c84902d845fc..e0e718ab4c2e 100644
--- a/drivers/net/ipg.h
+++ b/drivers/net/ipg.h
@@ -536,91 +536,6 @@ enum ipg_regs {
536 */ 536 */
537#define IPG_FRAMESBETWEENTXDMACOMPLETES 0x1 537#define IPG_FRAMESBETWEENTXDMACOMPLETES 0x1
538 538
539#ifdef JUMBO_FRAME
540# define IPG_JUMBO true
541#else
542# define IPG_JUMBO false
543#endif
544
545#ifdef JUMBO_FRAME
546
547# ifdef JUMBO_FRAME_SIZE_2K
548# define JUMBO_FRAME_SIZE 2048
549# define __IPG_RXFRAG_SIZE 2048
550# else
551# ifdef JUMBO_FRAME_SIZE_3K
552# define JUMBO_FRAME_SIZE 3072
553# define __IPG_RXFRAG_SIZE 3072
554# else
555# ifdef JUMBO_FRAME_SIZE_4K
556# define JUMBO_FRAME_SIZE 4096
557# define __IPG_RXFRAG_SIZE 4088
558# else
559# ifdef JUMBO_FRAME_SIZE_5K
560# define JUMBO_FRAME_SIZE 5120
561# define __IPG_RXFRAG_SIZE 4088
562# else
563# ifdef JUMBO_FRAME_SIZE_6K
564# define JUMBO_FRAME_SIZE 6144
565# define __IPG_RXFRAG_SIZE 4088
566# else
567# ifdef JUMBO_FRAME_SIZE_7K
568# define JUMBO_FRAME_SIZE 7168
569# define __IPG_RXFRAG_SIZE 4088
570# else
571# ifdef JUMBO_FRAME_SIZE_8K
572# define JUMBO_FRAME_SIZE 8192
573# define __IPG_RXFRAG_SIZE 4088
574# else
575# ifdef JUMBO_FRAME_SIZE_9K
576# define JUMBO_FRAME_SIZE 9216
577# define __IPG_RXFRAG_SIZE 4088
578# else
579# ifdef JUMBO_FRAME_SIZE_10K
580# define JUMBO_FRAME_SIZE 10240
581# define __IPG_RXFRAG_SIZE 4088
582# else
583# define JUMBO_FRAME_SIZE 4096
584# endif
585# endif
586# endif
587# endif
588# endif
589# endif
590# endif
591# endif
592# endif
593#endif
594
595/* Size of allocated received buffers. Nominally 0x0600.
596 * Define larger if expecting jumbo frames.
597 */
598#ifdef JUMBO_FRAME
599/* IPG_TXFRAG_SIZE must <= 0x2b00, or TX will crash */
600#define IPG_TXFRAG_SIZE JUMBO_FRAME_SIZE
601#else
602#define IPG_TXFRAG_SIZE 0 /* use default MTU */
603#endif
604
605/* Size of allocated received buffers. Nominally 0x0600.
606 * Define larger if expecting jumbo frames.
607 */
608#ifdef JUMBO_FRAME
609/* 4088 = 4096 - 8 */
610#define IPG_RXFRAG_SIZE __IPG_RXFRAG_SIZE
611#define IPG_RXSUPPORT_SIZE IPG_MAX_RXFRAME_SIZE
612#else
613#define IPG_RXFRAG_SIZE 0x0600
614#define IPG_RXSUPPORT_SIZE IPG_RXFRAG_SIZE
615#endif
616
617/* IPG_MAX_RXFRAME_SIZE <= IPG_RXFRAG_SIZE */
618#ifdef JUMBO_FRAME
619#define IPG_MAX_RXFRAME_SIZE JUMBO_FRAME_SIZE
620#else
621#define IPG_MAX_RXFRAME_SIZE 0x0600
622#endif
623
624#define IPG_RFDLIST_LENGTH 0x100 539#define IPG_RFDLIST_LENGTH 0x100
625 540
626/* Maximum number of RFDs to process per interrupt. 541/* Maximum number of RFDs to process per interrupt.