Deleted Added
full compact
cxgb_main.c (178767) cxgb_main.c (180583)
1/**************************************************************************
2
3Copyright (c) 2007-2008, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 14 unchanged lines hidden (view full) ---

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
1/**************************************************************************
2
3Copyright (c) 2007-2008, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 14 unchanged lines hidden (view full) ---

23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26POSSIBILITY OF SUCH DAMAGE.
27
28***************************************************************************/
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_main.c 178767 2008-05-05 01:41:53Z kmacy $");
31__FBSDID("$FreeBSD: head/sys/dev/cxgb/cxgb_main.c 180583 2008-07-18 06:12:31Z kmacy $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/bus.h>
37#include <sys/module.h>
38#include <sys/pciio.h>
39#include <sys/conf.h>

--- 17 unchanged lines hidden (view full) ---

57
58#include <net/bpf.h>
59#include <net/ethernet.h>
60#include <net/if.h>
61#include <net/if_arp.h>
62#include <net/if_dl.h>
63#include <net/if_media.h>
64#include <net/if_types.h>
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/kernel.h>
36#include <sys/bus.h>
37#include <sys/module.h>
38#include <sys/pciio.h>
39#include <sys/conf.h>

--- 17 unchanged lines hidden (view full) ---

57
58#include <net/bpf.h>
59#include <net/ethernet.h>
60#include <net/if.h>
61#include <net/if_arp.h>
62#include <net/if_dl.h>
63#include <net/if_media.h>
64#include <net/if_types.h>
65#include <net/if_vlan_var.h>
65
66#include <netinet/in_systm.h>
67#include <netinet/in.h>
68#include <netinet/if_ether.h>
69#include <netinet/ip.h>
70#include <netinet/ip.h>
71#include <netinet/tcp.h>
72#include <netinet/udp.h>

--- 900 unchanged lines hidden (view full) ---

973 ifp->if_hwassist &= ~CSUM_TSO;
974 }
975
976 ether_ifattach(ifp, p->hw_addr);
977 /*
978 * Only default to jumbo frames on 10GigE
979 */
980 if (p->adapter->params.nports <= 2)
66
67#include <netinet/in_systm.h>
68#include <netinet/in.h>
69#include <netinet/if_ether.h>
70#include <netinet/ip.h>
71#include <netinet/ip.h>
72#include <netinet/tcp.h>
73#include <netinet/udp.h>

--- 900 unchanged lines hidden (view full) ---

974 ifp->if_hwassist &= ~CSUM_TSO;
975 }
976
977 ether_ifattach(ifp, p->hw_addr);
978 /*
979 * Only default to jumbo frames on 10GigE
980 */
981 if (p->adapter->params.nports <= 2)
981 ifp->if_mtu = 9000;
982 ifp->if_mtu = ETHERMTU_JUMBO;
982 if ((err = cxgb_makedev(p)) != 0) {
983 printf("makedev failed %d\n", err);
984 return (err);
985 }
986 ifmedia_init(&p->media, IFM_IMASK, cxgb_media_change,
987 cxgb_media_status);
988
989 if (!strcmp(p->phy.desc, "10GBASE-CX4")) {

--- 247 unchanged lines hidden (view full) ---

1237 * Performs the MAC and PHY actions needed to enable a port.
1238 */
1239static void
1240cxgb_link_start(struct port_info *p)
1241{
1242 struct ifnet *ifp;
1243 struct t3_rx_mode rm;
1244 struct cmac *mac = &p->mac;
983 if ((err = cxgb_makedev(p)) != 0) {
984 printf("makedev failed %d\n", err);
985 return (err);
986 }
987 ifmedia_init(&p->media, IFM_IMASK, cxgb_media_change,
988 cxgb_media_status);
989
990 if (!strcmp(p->phy.desc, "10GBASE-CX4")) {

--- 247 unchanged lines hidden (view full) ---

1238 * Performs the MAC and PHY actions needed to enable a port.
1239 */
1240static void
1241cxgb_link_start(struct port_info *p)
1242{
1243 struct ifnet *ifp;
1244 struct t3_rx_mode rm;
1245 struct cmac *mac = &p->mac;
1246 int mtu, hwtagging;
1245
1246 ifp = p->ifp;
1247
1247
1248 ifp = p->ifp;
1249
1250 bcopy(IF_LLADDR(ifp), p->hw_addr, ETHER_ADDR_LEN);
1251
1252 mtu = ifp->if_mtu;
1253 if (ifp->if_capenable & IFCAP_VLAN_MTU)
1254 mtu += ETHER_VLAN_ENCAP_LEN;
1255
1256 hwtagging = (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0;
1257
1248 t3_init_rx_mode(&rm, p);
1249 if (!mac->multiport)
1250 t3_mac_reset(mac);
1258 t3_init_rx_mode(&rm, p);
1259 if (!mac->multiport)
1260 t3_mac_reset(mac);
1251 t3_mac_set_mtu(mac, ifp->if_mtu + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
1261 t3_mac_set_mtu(mac, mtu);
1262 t3_set_vlan_accel(p->adapter, 1 << p->tx_chan, hwtagging);
1252 t3_mac_set_address(mac, 0, p->hw_addr);
1253 t3_mac_set_rx_mode(mac, &rm);
1254 t3_link_start(&p->phy, mac, &p->link_config);
1255 t3_mac_enable(mac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
1256}
1257
1258
1259static int

--- 629 unchanged lines hidden (view full) ---

1889}
1890
1891static int
1892cxgb_set_mtu(struct port_info *p, int mtu)
1893{
1894 struct ifnet *ifp = p->ifp;
1895 int error = 0;
1896
1263 t3_mac_set_address(mac, 0, p->hw_addr);
1264 t3_mac_set_rx_mode(mac, &rm);
1265 t3_link_start(&p->phy, mac, &p->link_config);
1266 t3_mac_enable(mac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
1267}
1268
1269
1270static int

--- 629 unchanged lines hidden (view full) ---

1900}
1901
1902static int
1903cxgb_set_mtu(struct port_info *p, int mtu)
1904{
1905 struct ifnet *ifp = p->ifp;
1906 int error = 0;
1907
1897 if ((mtu < ETHERMIN) || (mtu > ETHER_MAX_LEN_JUMBO))
1908 if ((mtu < ETHERMIN) || (mtu > ETHERMTU_JUMBO))
1898 error = EINVAL;
1899 else if (ifp->if_mtu != mtu) {
1900 PORT_LOCK(p);
1901 ifp->if_mtu = mtu;
1902 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
1903 cxgb_stop_locked(p);
1904 cxgb_init_locked(p);
1905 }
1906 PORT_UNLOCK(p);
1907 }
1908 return (error);
1909}
1910
1911static int
1912cxgb_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data)
1913{
1914 struct port_info *p = ifp->if_softc;
1915 struct ifaddr *ifa = (struct ifaddr *)data;
1916 struct ifreq *ifr = (struct ifreq *)data;
1909 error = EINVAL;
1910 else if (ifp->if_mtu != mtu) {
1911 PORT_LOCK(p);
1912 ifp->if_mtu = mtu;
1913 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
1914 cxgb_stop_locked(p);
1915 cxgb_init_locked(p);
1916 }
1917 PORT_UNLOCK(p);
1918 }
1919 return (error);
1920}
1921
1922static int
1923cxgb_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data)
1924{
1925 struct port_info *p = ifp->if_softc;
1926 struct ifaddr *ifa = (struct ifaddr *)data;
1927 struct ifreq *ifr = (struct ifreq *)data;
1917 int flags, error = 0;
1928 int flags, error = 0, reinit = 0;
1918 uint32_t mask;
1919
1920 /*
1921 * XXX need to check that we aren't in the middle of an unload
1922 */
1923 switch (command) {
1924 case SIOCSIFMTU:
1925 error = cxgb_set_mtu(p, ifr->ifr_mtu);

--- 38 unchanged lines hidden (view full) ---

1964 break;
1965 case SIOCSIFCAP:
1966 PORT_LOCK(p);
1967 mask = ifr->ifr_reqcap ^ ifp->if_capenable;
1968 if (mask & IFCAP_TXCSUM) {
1969 if (IFCAP_TXCSUM & ifp->if_capenable) {
1970 ifp->if_capenable &= ~(IFCAP_TXCSUM|IFCAP_TSO4);
1971 ifp->if_hwassist &= ~(CSUM_TCP | CSUM_UDP
1929 uint32_t mask;
1930
1931 /*
1932 * XXX need to check that we aren't in the middle of an unload
1933 */
1934 switch (command) {
1935 case SIOCSIFMTU:
1936 error = cxgb_set_mtu(p, ifr->ifr_mtu);

--- 38 unchanged lines hidden (view full) ---

1975 break;
1976 case SIOCSIFCAP:
1977 PORT_LOCK(p);
1978 mask = ifr->ifr_reqcap ^ ifp->if_capenable;
1979 if (mask & IFCAP_TXCSUM) {
1980 if (IFCAP_TXCSUM & ifp->if_capenable) {
1981 ifp->if_capenable &= ~(IFCAP_TXCSUM|IFCAP_TSO4);
1982 ifp->if_hwassist &= ~(CSUM_TCP | CSUM_UDP
1972 | CSUM_TSO);
1983 | CSUM_IP | CSUM_TSO);
1973 } else {
1974 ifp->if_capenable |= IFCAP_TXCSUM;
1984 } else {
1985 ifp->if_capenable |= IFCAP_TXCSUM;
1975 ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP);
1986 ifp->if_hwassist |= (CSUM_TCP | CSUM_UDP
1987 | CSUM_IP);
1976 }
1988 }
1977 } else if (mask & IFCAP_RXCSUM) {
1978 if (IFCAP_RXCSUM & ifp->if_capenable) {
1979 ifp->if_capenable &= ~IFCAP_RXCSUM;
1980 } else {
1981 ifp->if_capenable |= IFCAP_RXCSUM;
1982 }
1983 }
1989 }
1990 if (mask & IFCAP_RXCSUM) {
1991 ifp->if_capenable ^= IFCAP_RXCSUM;
1992 }
1984 if (mask & IFCAP_TSO4) {
1985 if (IFCAP_TSO4 & ifp->if_capenable) {
1986 ifp->if_capenable &= ~IFCAP_TSO4;
1987 ifp->if_hwassist &= ~CSUM_TSO;
1988 } else if (IFCAP_TXCSUM & ifp->if_capenable) {
1989 ifp->if_capenable |= IFCAP_TSO4;
1990 ifp->if_hwassist |= CSUM_TSO;
1991 } else {
1992 if (cxgb_debug)
1993 printf("cxgb requires tx checksum offload"
1994 " be enabled to use TSO\n");
1995 error = EINVAL;
1996 }
1997 }
1993 if (mask & IFCAP_TSO4) {
1994 if (IFCAP_TSO4 & ifp->if_capenable) {
1995 ifp->if_capenable &= ~IFCAP_TSO4;
1996 ifp->if_hwassist &= ~CSUM_TSO;
1997 } else if (IFCAP_TXCSUM & ifp->if_capenable) {
1998 ifp->if_capenable |= IFCAP_TSO4;
1999 ifp->if_hwassist |= CSUM_TSO;
2000 } else {
2001 if (cxgb_debug)
2002 printf("cxgb requires tx checksum offload"
2003 " be enabled to use TSO\n");
2004 error = EINVAL;
2005 }
2006 }
2007 if (mask & IFCAP_VLAN_HWTAGGING) {
2008 ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
2009 reinit = ifp->if_drv_flags & IFF_DRV_RUNNING;
2010 }
2011 if (mask & IFCAP_VLAN_MTU) {
2012 ifp->if_capenable ^= IFCAP_VLAN_MTU;
2013 reinit = ifp->if_drv_flags & IFF_DRV_RUNNING;
2014 }
2015 if (mask & IFCAP_VLAN_HWCSUM) {
2016 ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
2017 }
2018 if (reinit) {
2019 cxgb_stop_locked(p);
2020 cxgb_init_locked(p);
2021 }
1998 PORT_UNLOCK(p);
2022 PORT_UNLOCK(p);
2023
2024#ifdef VLAN_CAPABILITIES
2025 VLAN_CAPABILITIES(ifp);
2026#endif
1999 break;
2000 default:
2001 error = ether_ioctl(ifp, command, data);
2002 break;
2003 }
2004 return (error);
2005}
2006

--- 104 unchanged lines hidden (view full) ---

2111 status = 0;
2112 PORT_LOCK(p);
2113 if ((ifp->if_drv_flags & IFF_DRV_RUNNING))
2114 status = t3b2_mac_watchdog_task(&p->mac);
2115 if (status == 1)
2116 p->mac.stats.num_toggled++;
2117 else if (status == 2) {
2118 struct cmac *mac = &p->mac;
2027 break;
2028 default:
2029 error = ether_ioctl(ifp, command, data);
2030 break;
2031 }
2032 return (error);
2033}
2034

--- 104 unchanged lines hidden (view full) ---

2139 status = 0;
2140 PORT_LOCK(p);
2141 if ((ifp->if_drv_flags & IFF_DRV_RUNNING))
2142 status = t3b2_mac_watchdog_task(&p->mac);
2143 if (status == 1)
2144 p->mac.stats.num_toggled++;
2145 else if (status == 2) {
2146 struct cmac *mac = &p->mac;
2147 int mtu = ifp->if_mtu;
2119
2148
2120 t3_mac_set_mtu(mac, ifp->if_mtu + ETHER_HDR_LEN
2121 + ETHER_VLAN_ENCAP_LEN);
2149 if (ifp->if_capenable & IFCAP_VLAN_MTU)
2150 mtu += ETHER_VLAN_ENCAP_LEN;
2151 t3_mac_set_mtu(mac, mtu);
2122 t3_mac_set_address(mac, 0, p->hw_addr);
2123 cxgb_set_rxmode(p);
2124 t3_link_start(&p->phy, mac, &p->link_config);
2125 t3_mac_enable(mac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
2126 t3_port_intr_enable(adapter, p->port_id);
2127 p->mac.stats.num_resets++;
2128 }
2129 PORT_UNLOCK(p);

--- 289 unchanged lines hidden (view full) ---

2419 q->txq_size[1] = t->txq_size[1];
2420 if (t->txq_size[2] >= 0)
2421 q->txq_size[2] = t->txq_size[2];
2422 if (t->cong_thres >= 0)
2423 q->cong_thres = t->cong_thres;
2424 if (t->intr_lat >= 0) {
2425 struct sge_qset *qs = &sc->sge.qs[t->qset_idx];
2426
2152 t3_mac_set_address(mac, 0, p->hw_addr);
2153 cxgb_set_rxmode(p);
2154 t3_link_start(&p->phy, mac, &p->link_config);
2155 t3_mac_enable(mac, MAC_DIRECTION_RX | MAC_DIRECTION_TX);
2156 t3_port_intr_enable(adapter, p->port_id);
2157 p->mac.stats.num_resets++;
2158 }
2159 PORT_UNLOCK(p);

--- 289 unchanged lines hidden (view full) ---

2449 q->txq_size[1] = t->txq_size[1];
2450 if (t->txq_size[2] >= 0)
2451 q->txq_size[2] = t->txq_size[2];
2452 if (t->cong_thres >= 0)
2453 q->cong_thres = t->cong_thres;
2454 if (t->intr_lat >= 0) {
2455 struct sge_qset *qs = &sc->sge.qs[t->qset_idx];
2456
2427 q->coalesce_nsecs = t->intr_lat*1000;
2457 q->coalesce_usecs = t->intr_lat;
2428 t3_update_qset_coalesce(qs, q);
2429 }
2430 break;
2431 }
2432 case CHELSIO_GET_QSET_PARAMS: {
2433 struct qset_params *q;
2434 struct ch_qset_params *t = (struct ch_qset_params *)data;
2435
2436 if (t->qset_idx >= SGE_QSETS)
2437 return (EINVAL);
2438
2439 q = &(sc)->params.sge.qset[t->qset_idx];
2440 t->rspq_size = q->rspq_size;
2441 t->txq_size[0] = q->txq_size[0];
2442 t->txq_size[1] = q->txq_size[1];
2443 t->txq_size[2] = q->txq_size[2];
2444 t->fl_size[0] = q->fl_size;
2445 t->fl_size[1] = q->jumbo_size;
2446 t->polling = q->polling;
2458 t3_update_qset_coalesce(qs, q);
2459 }
2460 break;
2461 }
2462 case CHELSIO_GET_QSET_PARAMS: {
2463 struct qset_params *q;
2464 struct ch_qset_params *t = (struct ch_qset_params *)data;
2465
2466 if (t->qset_idx >= SGE_QSETS)
2467 return (EINVAL);
2468
2469 q = &(sc)->params.sge.qset[t->qset_idx];
2470 t->rspq_size = q->rspq_size;
2471 t->txq_size[0] = q->txq_size[0];
2472 t->txq_size[1] = q->txq_size[1];
2473 t->txq_size[2] = q->txq_size[2];
2474 t->fl_size[0] = q->fl_size;
2475 t->fl_size[1] = q->jumbo_size;
2476 t->polling = q->polling;
2447 t->intr_lat = q->coalesce_nsecs / 1000;
2477 t->intr_lat = q->coalesce_usecs;
2448 t->cong_thres = q->cong_thres;
2449 break;
2450 }
2451 case CHELSIO_SET_QSET_NUM: {
2452 struct ch_reg *edata = (struct ch_reg *)data;
2453 unsigned int port_idx = pi->port_id;
2454
2455 if (sc->flags & FULL_INIT_DONE)

--- 256 unchanged lines hidden ---
2478 t->cong_thres = q->cong_thres;
2479 break;
2480 }
2481 case CHELSIO_SET_QSET_NUM: {
2482 struct ch_reg *edata = (struct ch_reg *)data;
2483 unsigned int port_idx = pi->port_id;
2484
2485 if (sc->flags & FULL_INIT_DONE)

--- 256 unchanged lines hidden ---