diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/tehuti.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/tehuti.c')
-rw-r--r-- | drivers/net/tehuti.c | 84 |
1 files changed, 29 insertions, 55 deletions
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c index 737df6032bbc..80fbee0d40af 100644 --- a/drivers/net/tehuti.c +++ b/drivers/net/tehuti.c | |||
@@ -12,7 +12,7 @@ | |||
12 | /* | 12 | /* |
13 | * RX HW/SW interaction overview | 13 | * RX HW/SW interaction overview |
14 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 14 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
15 | * There are 2 types of RX communication channels betwean driver and NIC. | 15 | * There are 2 types of RX communication channels between driver and NIC. |
16 | * 1) RX Free Fifo - RXF - holds descriptors of empty buffers to accept incoming | 16 | * 1) RX Free Fifo - RXF - holds descriptors of empty buffers to accept incoming |
17 | * traffic. This Fifo is filled by SW and is readen by HW. Each descriptor holds | 17 | * traffic. This Fifo is filled by SW and is readen by HW. Each descriptor holds |
18 | * info about buffer's location, size and ID. An ID field is used to identify a | 18 | * info about buffer's location, size and ID. An ID field is used to identify a |
@@ -92,7 +92,7 @@ static void bdx_rx_free(struct bdx_priv *priv); | |||
92 | static void bdx_tx_free(struct bdx_priv *priv); | 92 | static void bdx_tx_free(struct bdx_priv *priv); |
93 | 93 | ||
94 | /* Definitions needed by bdx_probe */ | 94 | /* Definitions needed by bdx_probe */ |
95 | static void bdx_ethtool_ops(struct net_device *netdev); | 95 | static void bdx_set_ethtool_ops(struct net_device *netdev); |
96 | 96 | ||
97 | /************************************************************************* | 97 | /************************************************************************* |
98 | * Print Info * | 98 | * Print Info * |
@@ -324,7 +324,7 @@ static int bdx_fw_load(struct bdx_priv *priv) | |||
324 | ENTER; | 324 | ENTER; |
325 | master = READ_REG(priv, regINIT_SEMAPHORE); | 325 | master = READ_REG(priv, regINIT_SEMAPHORE); |
326 | if (!READ_REG(priv, regINIT_STATUS) && master) { | 326 | if (!READ_REG(priv, regINIT_STATUS) && master) { |
327 | rc = request_firmware(&fw, "tehuti/firmware.bin", &priv->pdev->dev); | 327 | rc = request_firmware(&fw, "tehuti/bdx.bin", &priv->pdev->dev); |
328 | if (rc) | 328 | if (rc) |
329 | goto out; | 329 | goto out; |
330 | bdx_tx_push_desc_safe(priv, (char *)fw->data, fw->size); | 330 | bdx_tx_push_desc_safe(priv, (char *)fw->data, fw->size); |
@@ -645,7 +645,7 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) | |||
645 | if (cmd != SIOCDEVPRIVATE) { | 645 | if (cmd != SIOCDEVPRIVATE) { |
646 | error = copy_from_user(data, ifr->ifr_data, sizeof(data)); | 646 | error = copy_from_user(data, ifr->ifr_data, sizeof(data)); |
647 | if (error) { | 647 | if (error) { |
648 | pr_err("cant copy from user\n"); | 648 | pr_err("can't copy from user\n"); |
649 | RET(-EFAULT); | 649 | RET(-EFAULT); |
650 | } | 650 | } |
651 | DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); | 651 | DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); |
@@ -821,7 +821,7 @@ static void bdx_setmulti(struct net_device *ndev) | |||
821 | } | 821 | } |
822 | 822 | ||
823 | /* use PMF to accept first MAC_MCST_NUM (15) addresses */ | 823 | /* use PMF to accept first MAC_MCST_NUM (15) addresses */ |
824 | /* TBD: sort addreses and write them in ascending order | 824 | /* TBD: sort addresses and write them in ascending order |
825 | * into RX_MAC_MCST regs. we skip this phase now and accept ALL | 825 | * into RX_MAC_MCST regs. we skip this phase now and accept ALL |
826 | * multicast frames throu IMF */ | 826 | * multicast frames throu IMF */ |
827 | /* accept the rest of addresses throu IMF */ | 827 | /* accept the rest of addresses throu IMF */ |
@@ -927,13 +927,6 @@ static void bdx_update_stats(struct bdx_priv *priv) | |||
927 | BDX_ASSERT((sizeof(struct bdx_stats) / sizeof(u64)) != i); | 927 | BDX_ASSERT((sizeof(struct bdx_stats) / sizeof(u64)) != i); |
928 | } | 928 | } |
929 | 929 | ||
930 | static struct net_device_stats *bdx_get_stats(struct net_device *ndev) | ||
931 | { | ||
932 | struct bdx_priv *priv = netdev_priv(ndev); | ||
933 | struct net_device_stats *net_stat = &priv->net_stats; | ||
934 | return net_stat; | ||
935 | } | ||
936 | |||
937 | static void print_rxdd(struct rxd_desc *rxdd, u32 rxd_val1, u16 len, | 930 | static void print_rxdd(struct rxd_desc *rxdd, u32 rxd_val1, u16 len, |
938 | u16 rxd_vlan); | 931 | u16 rxd_vlan); |
939 | static void print_rxfd(struct rxf_desc *rxfd); | 932 | static void print_rxfd(struct rxf_desc *rxfd); |
@@ -1006,7 +999,7 @@ static inline void bdx_rxdb_free_elem(struct rxdb *db, int n) | |||
1006 | * | 999 | * |
1007 | * RxD fifo is smaller than RxF fifo by design. Upon high load, RxD will be | 1000 | * RxD fifo is smaller than RxF fifo by design. Upon high load, RxD will be |
1008 | * filled and packets will be dropped by nic without getting into host or | 1001 | * filled and packets will be dropped by nic without getting into host or |
1009 | * cousing interrupt. Anyway, in that condition, host has no chance to proccess | 1002 | * cousing interrupt. Anyway, in that condition, host has no chance to process |
1010 | * all packets, but dropping in nic is cheaper, since it takes 0 cpu cycles | 1003 | * all packets, but dropping in nic is cheaper, since it takes 0 cpu cycles |
1011 | */ | 1004 | */ |
1012 | 1005 | ||
@@ -1207,8 +1200,8 @@ static void bdx_recycle_skb(struct bdx_priv *priv, struct rxd_desc *rxdd) | |||
1207 | RET(); | 1200 | RET(); |
1208 | } | 1201 | } |
1209 | 1202 | ||
1210 | /* bdx_rx_receive - recieves full packets from RXD fifo and pass them to OS | 1203 | /* bdx_rx_receive - receives full packets from RXD fifo and pass them to OS |
1211 | * NOTE: a special treatment is given to non-continous descriptors | 1204 | * NOTE: a special treatment is given to non-continuous descriptors |
1212 | * that start near the end, wraps around and continue at the beginning. a second | 1205 | * that start near the end, wraps around and continue at the beginning. a second |
1213 | * part is copied right after the first, and then descriptor is interpreted as | 1206 | * part is copied right after the first, and then descriptor is interpreted as |
1214 | * normal. fifo has an extra space to allow such operations | 1207 | * normal. fifo has an extra space to allow such operations |
@@ -1220,6 +1213,7 @@ static void bdx_recycle_skb(struct bdx_priv *priv, struct rxd_desc *rxdd) | |||
1220 | 1213 | ||
1221 | static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget) | 1214 | static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget) |
1222 | { | 1215 | { |
1216 | struct net_device *ndev = priv->ndev; | ||
1223 | struct sk_buff *skb, *skb2; | 1217 | struct sk_buff *skb, *skb2; |
1224 | struct rxd_desc *rxdd; | 1218 | struct rxd_desc *rxdd; |
1225 | struct rx_map *dm; | 1219 | struct rx_map *dm; |
@@ -1273,7 +1267,7 @@ static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget) | |||
1273 | 1267 | ||
1274 | if (unlikely(GET_RXD_ERR(rxd_val1))) { | 1268 | if (unlikely(GET_RXD_ERR(rxd_val1))) { |
1275 | DBG("rxd_err = 0x%x\n", GET_RXD_ERR(rxd_val1)); | 1269 | DBG("rxd_err = 0x%x\n", GET_RXD_ERR(rxd_val1)); |
1276 | priv->net_stats.rx_errors++; | 1270 | ndev->stats.rx_errors++; |
1277 | bdx_recycle_skb(priv, rxdd); | 1271 | bdx_recycle_skb(priv, rxdd); |
1278 | continue; | 1272 | continue; |
1279 | } | 1273 | } |
@@ -1300,15 +1294,16 @@ static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget) | |||
1300 | bdx_rxdb_free_elem(db, rxdd->va_lo); | 1294 | bdx_rxdb_free_elem(db, rxdd->va_lo); |
1301 | } | 1295 | } |
1302 | 1296 | ||
1303 | priv->net_stats.rx_bytes += len; | 1297 | ndev->stats.rx_bytes += len; |
1304 | 1298 | ||
1305 | skb_put(skb, len); | 1299 | skb_put(skb, len); |
1306 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 1300 | skb->protocol = eth_type_trans(skb, ndev); |
1307 | skb->protocol = eth_type_trans(skb, priv->ndev); | ||
1308 | 1301 | ||
1309 | /* Non-IP packets aren't checksum-offloaded */ | 1302 | /* Non-IP packets aren't checksum-offloaded */ |
1310 | if (GET_RXD_PKT_ID(rxd_val1) == 0) | 1303 | if (GET_RXD_PKT_ID(rxd_val1) == 0) |
1311 | skb->ip_summed = CHECKSUM_NONE; | 1304 | skb_checksum_none_assert(skb); |
1305 | else | ||
1306 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
1312 | 1307 | ||
1313 | NETIF_RX_MUX(priv, rxd_val1, rxd_vlan, skb); | 1308 | NETIF_RX_MUX(priv, rxd_val1, rxd_vlan, skb); |
1314 | 1309 | ||
@@ -1316,7 +1311,7 @@ static int bdx_rx_receive(struct bdx_priv *priv, struct rxd_fifo *f, int budget) | |||
1316 | break; | 1311 | break; |
1317 | } | 1312 | } |
1318 | 1313 | ||
1319 | priv->net_stats.rx_packets += done; | 1314 | ndev->stats.rx_packets += done; |
1320 | 1315 | ||
1321 | /* FIXME: do smth to minimize pci accesses */ | 1316 | /* FIXME: do smth to minimize pci accesses */ |
1322 | WRITE_REG(priv, f->m.reg_RPTR, f->m.rptr & TXF_WPTR_WR_PTR); | 1317 | WRITE_REG(priv, f->m.reg_RPTR, f->m.rptr & TXF_WPTR_WR_PTR); |
@@ -1351,7 +1346,7 @@ static void print_rxfd(struct rxf_desc *rxfd) | |||
1351 | /* | 1346 | /* |
1352 | * TX HW/SW interaction overview | 1347 | * TX HW/SW interaction overview |
1353 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 1348 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1354 | * There are 2 types of TX communication channels betwean driver and NIC. | 1349 | * There are 2 types of TX communication channels between driver and NIC. |
1355 | * 1) TX Free Fifo - TXF - holds ack descriptors for sent packets | 1350 | * 1) TX Free Fifo - TXF - holds ack descriptors for sent packets |
1356 | * 2) TX Data Fifo - TXD - holds descriptors of full buffers. | 1351 | * 2) TX Data Fifo - TXD - holds descriptors of full buffers. |
1357 | * | 1352 | * |
@@ -1589,9 +1584,9 @@ err_mem: | |||
1589 | } | 1584 | } |
1590 | 1585 | ||
1591 | /* | 1586 | /* |
1592 | * bdx_tx_space - calculates avalable space in TX fifo | 1587 | * bdx_tx_space - calculates available space in TX fifo |
1593 | * @priv - NIC private structure | 1588 | * @priv - NIC private structure |
1594 | * Returns avaliable space in TX fifo in bytes | 1589 | * Returns available space in TX fifo in bytes |
1595 | */ | 1590 | */ |
1596 | static inline int bdx_tx_space(struct bdx_priv *priv) | 1591 | static inline int bdx_tx_space(struct bdx_priv *priv) |
1597 | { | 1592 | { |
@@ -1712,8 +1707,8 @@ static netdev_tx_t bdx_tx_transmit(struct sk_buff *skb, | |||
1712 | #ifdef BDX_LLTX | 1707 | #ifdef BDX_LLTX |
1713 | ndev->trans_start = jiffies; /* NETIF_F_LLTX driver :( */ | 1708 | ndev->trans_start = jiffies; /* NETIF_F_LLTX driver :( */ |
1714 | #endif | 1709 | #endif |
1715 | priv->net_stats.tx_packets++; | 1710 | ndev->stats.tx_packets++; |
1716 | priv->net_stats.tx_bytes += skb->len; | 1711 | ndev->stats.tx_bytes += skb->len; |
1717 | 1712 | ||
1718 | if (priv->tx_level < BDX_MIN_TX_LEVEL) { | 1713 | if (priv->tx_level < BDX_MIN_TX_LEVEL) { |
1719 | DBG("%s: %s: TX Q STOP level %d\n", | 1714 | DBG("%s: %s: TX Q STOP level %d\n", |
@@ -1888,7 +1883,6 @@ static const struct net_device_ops bdx_netdev_ops = { | |||
1888 | .ndo_validate_addr = eth_validate_addr, | 1883 | .ndo_validate_addr = eth_validate_addr, |
1889 | .ndo_do_ioctl = bdx_ioctl, | 1884 | .ndo_do_ioctl = bdx_ioctl, |
1890 | .ndo_set_multicast_list = bdx_setmulti, | 1885 | .ndo_set_multicast_list = bdx_setmulti, |
1891 | .ndo_get_stats = bdx_get_stats, | ||
1892 | .ndo_change_mtu = bdx_change_mtu, | 1886 | .ndo_change_mtu = bdx_change_mtu, |
1893 | .ndo_set_mac_address = bdx_set_mac, | 1887 | .ndo_set_mac_address = bdx_set_mac, |
1894 | .ndo_vlan_rx_register = bdx_vlan_rx_register, | 1888 | .ndo_vlan_rx_register = bdx_vlan_rx_register, |
@@ -2012,7 +2006,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2012 | ndev->netdev_ops = &bdx_netdev_ops; | 2006 | ndev->netdev_ops = &bdx_netdev_ops; |
2013 | ndev->tx_queue_len = BDX_NDEV_TXQ_LEN; | 2007 | ndev->tx_queue_len = BDX_NDEV_TXQ_LEN; |
2014 | 2008 | ||
2015 | bdx_ethtool_ops(ndev); /* ethtool interface */ | 2009 | bdx_set_ethtool_ops(ndev); /* ethtool interface */ |
2016 | 2010 | ||
2017 | /* these fields are used for info purposes only | 2011 | /* these fields are used for info purposes only |
2018 | * so we can have them same for all ports of the board */ | 2012 | * so we can have them same for all ports of the board */ |
@@ -2023,9 +2017,11 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2023 | ndev->irq = pdev->irq; | 2017 | ndev->irq = pdev->irq; |
2024 | ndev->features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO | 2018 | ndev->features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO |
2025 | | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | | 2019 | | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | |
2026 | NETIF_F_HW_VLAN_FILTER | 2020 | NETIF_F_HW_VLAN_FILTER | NETIF_F_RXCSUM |
2027 | /*| NETIF_F_FRAGLIST */ | 2021 | /*| NETIF_F_FRAGLIST */ |
2028 | ; | 2022 | ; |
2023 | ndev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | | ||
2024 | NETIF_F_TSO | NETIF_F_HW_VLAN_TX; | ||
2029 | 2025 | ||
2030 | if (pci_using_dac) | 2026 | if (pci_using_dac) |
2031 | ndev->features |= NETIF_F_HIGHDMA; | 2027 | ndev->features |= NETIF_F_HIGHDMA; |
@@ -2155,7 +2151,7 @@ static int bdx_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) | |||
2155 | 2151 | ||
2156 | ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); | 2152 | ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE); |
2157 | ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); | 2153 | ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE); |
2158 | ecmd->speed = SPEED_10000; | 2154 | ethtool_cmd_speed_set(ecmd, SPEED_10000); |
2159 | ecmd->duplex = DUPLEX_FULL; | 2155 | ecmd->duplex = DUPLEX_FULL; |
2160 | ecmd->port = PORT_FIBRE; | 2156 | ecmd->port = PORT_FIBRE; |
2161 | ecmd->transceiver = XCVR_EXTERNAL; /* what does it mean? */ | 2157 | ecmd->transceiver = XCVR_EXTERNAL; /* what does it mean? */ |
@@ -2194,24 +2190,6 @@ bdx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) | |||
2194 | } | 2190 | } |
2195 | 2191 | ||
2196 | /* | 2192 | /* |
2197 | * bdx_get_rx_csum - report whether receive checksums are turned on or off | ||
2198 | * @netdev | ||
2199 | */ | ||
2200 | static u32 bdx_get_rx_csum(struct net_device *netdev) | ||
2201 | { | ||
2202 | return 1; /* always on */ | ||
2203 | } | ||
2204 | |||
2205 | /* | ||
2206 | * bdx_get_tx_csum - report whether transmit checksums are turned on or off | ||
2207 | * @netdev | ||
2208 | */ | ||
2209 | static u32 bdx_get_tx_csum(struct net_device *netdev) | ||
2210 | { | ||
2211 | return (netdev->features & NETIF_F_IP_CSUM) != 0; | ||
2212 | } | ||
2213 | |||
2214 | /* | ||
2215 | * bdx_get_coalesce - get interrupt coalescing parameters | 2193 | * bdx_get_coalesce - get interrupt coalescing parameters |
2216 | * @netdev | 2194 | * @netdev |
2217 | * @ecoal | 2195 | * @ecoal |
@@ -2417,10 +2395,10 @@ static void bdx_get_ethtool_stats(struct net_device *netdev, | |||
2417 | } | 2395 | } |
2418 | 2396 | ||
2419 | /* | 2397 | /* |
2420 | * bdx_ethtool_ops - ethtool interface implementation | 2398 | * bdx_set_ethtool_ops - ethtool interface implementation |
2421 | * @netdev | 2399 | * @netdev |
2422 | */ | 2400 | */ |
2423 | static void bdx_ethtool_ops(struct net_device *netdev) | 2401 | static void bdx_set_ethtool_ops(struct net_device *netdev) |
2424 | { | 2402 | { |
2425 | static const struct ethtool_ops bdx_ethtool_ops = { | 2403 | static const struct ethtool_ops bdx_ethtool_ops = { |
2426 | .get_settings = bdx_get_settings, | 2404 | .get_settings = bdx_get_settings, |
@@ -2430,10 +2408,6 @@ static void bdx_ethtool_ops(struct net_device *netdev) | |||
2430 | .set_coalesce = bdx_set_coalesce, | 2408 | .set_coalesce = bdx_set_coalesce, |
2431 | .get_ringparam = bdx_get_ringparam, | 2409 | .get_ringparam = bdx_get_ringparam, |
2432 | .set_ringparam = bdx_set_ringparam, | 2410 | .set_ringparam = bdx_set_ringparam, |
2433 | .get_rx_csum = bdx_get_rx_csum, | ||
2434 | .get_tx_csum = bdx_get_tx_csum, | ||
2435 | .get_sg = ethtool_op_get_sg, | ||
2436 | .get_tso = ethtool_op_get_tso, | ||
2437 | .get_strings = bdx_get_strings, | 2411 | .get_strings = bdx_get_strings, |
2438 | .get_sset_count = bdx_get_sset_count, | 2412 | .get_sset_count = bdx_get_sset_count, |
2439 | .get_ethtool_stats = bdx_get_ethtool_stats, | 2413 | .get_ethtool_stats = bdx_get_ethtool_stats, |
@@ -2516,4 +2490,4 @@ module_exit(bdx_module_exit); | |||
2516 | MODULE_LICENSE("GPL"); | 2490 | MODULE_LICENSE("GPL"); |
2517 | MODULE_AUTHOR(DRIVER_AUTHOR); | 2491 | MODULE_AUTHOR(DRIVER_AUTHOR); |
2518 | MODULE_DESCRIPTION(BDX_DRV_DESC); | 2492 | MODULE_DESCRIPTION(BDX_DRV_DESC); |
2519 | MODULE_FIRMWARE("tehuti/firmware.bin"); | 2493 | MODULE_FIRMWARE("tehuti/bdx.bin"); |