diff options
Diffstat (limited to 'drivers/net/niu.c')
-rw-r--r-- | drivers/net/niu.c | 266 |
1 files changed, 128 insertions, 138 deletions
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index fe6983af6918..cc25bff0bd3b 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -283,7 +283,7 @@ static int niu_enable_interrupts(struct niu *np, int on) | |||
283 | 283 | ||
284 | static u32 phy_encode(u32 type, int port) | 284 | static u32 phy_encode(u32 type, int port) |
285 | { | 285 | { |
286 | return (type << (port * 2)); | 286 | return type << (port * 2); |
287 | } | 287 | } |
288 | 288 | ||
289 | static u32 phy_decode(u32 val, int port) | 289 | static u32 phy_decode(u32 val, int port) |
@@ -1233,7 +1233,7 @@ static int link_status_1g_rgmii(struct niu *np, int *link_up_p) | |||
1233 | 1233 | ||
1234 | bmsr = err; | 1234 | bmsr = err; |
1235 | if (bmsr & BMSR_LSTATUS) { | 1235 | if (bmsr & BMSR_LSTATUS) { |
1236 | u16 adv, lpa, common, estat; | 1236 | u16 adv, lpa; |
1237 | 1237 | ||
1238 | err = mii_read(np, np->phy_addr, MII_ADVERTISE); | 1238 | err = mii_read(np, np->phy_addr, MII_ADVERTISE); |
1239 | if (err < 0) | 1239 | if (err < 0) |
@@ -1245,12 +1245,9 @@ static int link_status_1g_rgmii(struct niu *np, int *link_up_p) | |||
1245 | goto out; | 1245 | goto out; |
1246 | lpa = err; | 1246 | lpa = err; |
1247 | 1247 | ||
1248 | common = adv & lpa; | ||
1249 | |||
1250 | err = mii_read(np, np->phy_addr, MII_ESTATUS); | 1248 | err = mii_read(np, np->phy_addr, MII_ESTATUS); |
1251 | if (err < 0) | 1249 | if (err < 0) |
1252 | goto out; | 1250 | goto out; |
1253 | estat = err; | ||
1254 | link_up = 1; | 1251 | link_up = 1; |
1255 | current_speed = SPEED_1000; | 1252 | current_speed = SPEED_1000; |
1256 | current_duplex = DUPLEX_FULL; | 1253 | current_duplex = DUPLEX_FULL; |
@@ -1650,7 +1647,7 @@ static int xcvr_init_10g(struct niu *np) | |||
1650 | break; | 1647 | break; |
1651 | } | 1648 | } |
1652 | 1649 | ||
1653 | return 0; | 1650 | return err; |
1654 | } | 1651 | } |
1655 | 1652 | ||
1656 | static int mii_reset(struct niu *np) | 1653 | static int mii_reset(struct niu *np) |
@@ -2381,17 +2378,14 @@ static int serdes_init_10g_serdes(struct niu *np) | |||
2381 | struct niu_link_config *lp = &np->link_config; | 2378 | struct niu_link_config *lp = &np->link_config; |
2382 | unsigned long ctrl_reg, test_cfg_reg, pll_cfg, i; | 2379 | unsigned long ctrl_reg, test_cfg_reg, pll_cfg, i; |
2383 | u64 ctrl_val, test_cfg_val, sig, mask, val; | 2380 | u64 ctrl_val, test_cfg_val, sig, mask, val; |
2384 | u64 reset_val; | ||
2385 | 2381 | ||
2386 | switch (np->port) { | 2382 | switch (np->port) { |
2387 | case 0: | 2383 | case 0: |
2388 | reset_val = ENET_SERDES_RESET_0; | ||
2389 | ctrl_reg = ENET_SERDES_0_CTRL_CFG; | 2384 | ctrl_reg = ENET_SERDES_0_CTRL_CFG; |
2390 | test_cfg_reg = ENET_SERDES_0_TEST_CFG; | 2385 | test_cfg_reg = ENET_SERDES_0_TEST_CFG; |
2391 | pll_cfg = ENET_SERDES_0_PLL_CFG; | 2386 | pll_cfg = ENET_SERDES_0_PLL_CFG; |
2392 | break; | 2387 | break; |
2393 | case 1: | 2388 | case 1: |
2394 | reset_val = ENET_SERDES_RESET_1; | ||
2395 | ctrl_reg = ENET_SERDES_1_CTRL_CFG; | 2389 | ctrl_reg = ENET_SERDES_1_CTRL_CFG; |
2396 | test_cfg_reg = ENET_SERDES_1_TEST_CFG; | 2390 | test_cfg_reg = ENET_SERDES_1_TEST_CFG; |
2397 | pll_cfg = ENET_SERDES_1_PLL_CFG; | 2391 | pll_cfg = ENET_SERDES_1_PLL_CFG; |
@@ -3043,8 +3037,7 @@ static int tcam_flush_all(struct niu *np) | |||
3043 | 3037 | ||
3044 | static u64 hash_addr_regval(unsigned long index, unsigned long num_entries) | 3038 | static u64 hash_addr_regval(unsigned long index, unsigned long num_entries) |
3045 | { | 3039 | { |
3046 | return ((u64)index | (num_entries == 1 ? | 3040 | return (u64)index | (num_entries == 1 ? HASH_TBL_ADDR_AUTOINC : 0); |
3047 | HASH_TBL_ADDR_AUTOINC : 0)); | ||
3048 | } | 3041 | } |
3049 | 3042 | ||
3050 | #if 0 | 3043 | #if 0 |
@@ -3276,7 +3269,7 @@ static u16 tcam_get_index(struct niu *np, u16 idx) | |||
3276 | /* One entry reserved for IP fragment rule */ | 3269 | /* One entry reserved for IP fragment rule */ |
3277 | if (idx >= (np->clas.tcam_sz - 1)) | 3270 | if (idx >= (np->clas.tcam_sz - 1)) |
3278 | idx = 0; | 3271 | idx = 0; |
3279 | return (np->clas.tcam_top + ((idx+1) * np->parent->num_ports)); | 3272 | return np->clas.tcam_top + ((idx+1) * np->parent->num_ports); |
3280 | } | 3273 | } |
3281 | 3274 | ||
3282 | static u16 tcam_get_size(struct niu *np) | 3275 | static u16 tcam_get_size(struct niu *np) |
@@ -3313,7 +3306,7 @@ static unsigned int niu_hash_rxaddr(struct rx_ring_info *rp, u64 a) | |||
3313 | a >>= PAGE_SHIFT; | 3306 | a >>= PAGE_SHIFT; |
3314 | a ^= (a >> ilog2(MAX_RBR_RING_SIZE)); | 3307 | a ^= (a >> ilog2(MAX_RBR_RING_SIZE)); |
3315 | 3308 | ||
3316 | return (a & (MAX_RBR_RING_SIZE - 1)); | 3309 | return a & (MAX_RBR_RING_SIZE - 1); |
3317 | } | 3310 | } |
3318 | 3311 | ||
3319 | static struct page *niu_find_rxpage(struct rx_ring_info *rp, u64 addr, | 3312 | static struct page *niu_find_rxpage(struct rx_ring_info *rp, u64 addr, |
@@ -3484,7 +3477,7 @@ static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np, | |||
3484 | RCR_ENTRY_ERROR))) | 3477 | RCR_ENTRY_ERROR))) |
3485 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 3478 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
3486 | else | 3479 | else |
3487 | skb->ip_summed = CHECKSUM_NONE; | 3480 | skb_checksum_none_assert(skb); |
3488 | } else if (!(val & RCR_ENTRY_MULTI)) | 3481 | } else if (!(val & RCR_ENTRY_MULTI)) |
3489 | append_size = len - skb->len; | 3482 | append_size = len - skb->len; |
3490 | 3483 | ||
@@ -4490,6 +4483,9 @@ static int niu_alloc_channels(struct niu *np) | |||
4490 | { | 4483 | { |
4491 | struct niu_parent *parent = np->parent; | 4484 | struct niu_parent *parent = np->parent; |
4492 | int first_rx_channel, first_tx_channel; | 4485 | int first_rx_channel, first_tx_channel; |
4486 | int num_rx_rings, num_tx_rings; | ||
4487 | struct rx_ring_info *rx_rings; | ||
4488 | struct tx_ring_info *tx_rings; | ||
4493 | int i, port, err; | 4489 | int i, port, err; |
4494 | 4490 | ||
4495 | port = np->port; | 4491 | port = np->port; |
@@ -4499,17 +4495,21 @@ static int niu_alloc_channels(struct niu *np) | |||
4499 | first_tx_channel += parent->txchan_per_port[i]; | 4495 | first_tx_channel += parent->txchan_per_port[i]; |
4500 | } | 4496 | } |
4501 | 4497 | ||
4502 | np->num_rx_rings = parent->rxchan_per_port[port]; | 4498 | num_rx_rings = parent->rxchan_per_port[port]; |
4503 | np->num_tx_rings = parent->txchan_per_port[port]; | 4499 | num_tx_rings = parent->txchan_per_port[port]; |
4504 | 4500 | ||
4505 | np->dev->real_num_tx_queues = np->num_tx_rings; | 4501 | rx_rings = kcalloc(num_rx_rings, sizeof(struct rx_ring_info), |
4506 | 4502 | GFP_KERNEL); | |
4507 | np->rx_rings = kzalloc(np->num_rx_rings * sizeof(struct rx_ring_info), | ||
4508 | GFP_KERNEL); | ||
4509 | err = -ENOMEM; | 4503 | err = -ENOMEM; |
4510 | if (!np->rx_rings) | 4504 | if (!rx_rings) |
4511 | goto out_err; | 4505 | goto out_err; |
4512 | 4506 | ||
4507 | np->num_rx_rings = num_rx_rings; | ||
4508 | smp_wmb(); | ||
4509 | np->rx_rings = rx_rings; | ||
4510 | |||
4511 | netif_set_real_num_rx_queues(np->dev, num_rx_rings); | ||
4512 | |||
4513 | for (i = 0; i < np->num_rx_rings; i++) { | 4513 | for (i = 0; i < np->num_rx_rings; i++) { |
4514 | struct rx_ring_info *rp = &np->rx_rings[i]; | 4514 | struct rx_ring_info *rp = &np->rx_rings[i]; |
4515 | 4515 | ||
@@ -4538,12 +4538,18 @@ static int niu_alloc_channels(struct niu *np) | |||
4538 | return err; | 4538 | return err; |
4539 | } | 4539 | } |
4540 | 4540 | ||
4541 | np->tx_rings = kzalloc(np->num_tx_rings * sizeof(struct tx_ring_info), | 4541 | tx_rings = kcalloc(num_tx_rings, sizeof(struct tx_ring_info), |
4542 | GFP_KERNEL); | 4542 | GFP_KERNEL); |
4543 | err = -ENOMEM; | 4543 | err = -ENOMEM; |
4544 | if (!np->tx_rings) | 4544 | if (!tx_rings) |
4545 | goto out_err; | 4545 | goto out_err; |
4546 | 4546 | ||
4547 | np->num_tx_rings = num_tx_rings; | ||
4548 | smp_wmb(); | ||
4549 | np->tx_rings = tx_rings; | ||
4550 | |||
4551 | netif_set_real_num_tx_queues(np->dev, num_tx_rings); | ||
4552 | |||
4547 | for (i = 0; i < np->num_tx_rings; i++) { | 4553 | for (i = 0; i < np->num_tx_rings; i++) { |
4548 | struct tx_ring_info *rp = &np->tx_rings[i]; | 4554 | struct tx_ring_info *rp = &np->tx_rings[i]; |
4549 | 4555 | ||
@@ -6059,8 +6065,7 @@ static int niu_request_irq(struct niu *np) | |||
6059 | for (i = 0; i < np->num_ldg; i++) { | 6065 | for (i = 0; i < np->num_ldg; i++) { |
6060 | struct niu_ldg *lp = &np->ldg[i]; | 6066 | struct niu_ldg *lp = &np->ldg[i]; |
6061 | 6067 | ||
6062 | err = request_irq(lp->irq, niu_interrupt, | 6068 | err = request_irq(lp->irq, niu_interrupt, IRQF_SHARED, |
6063 | IRQF_SHARED | IRQF_SAMPLE_RANDOM, | ||
6064 | np->irq_name[i], lp); | 6069 | np->irq_name[i], lp); |
6065 | if (err) | 6070 | if (err) |
6066 | goto out_free_irqs; | 6071 | goto out_free_irqs; |
@@ -6246,11 +6251,17 @@ static void niu_sync_mac_stats(struct niu *np) | |||
6246 | static void niu_get_rx_stats(struct niu *np) | 6251 | static void niu_get_rx_stats(struct niu *np) |
6247 | { | 6252 | { |
6248 | unsigned long pkts, dropped, errors, bytes; | 6253 | unsigned long pkts, dropped, errors, bytes; |
6254 | struct rx_ring_info *rx_rings; | ||
6249 | int i; | 6255 | int i; |
6250 | 6256 | ||
6251 | pkts = dropped = errors = bytes = 0; | 6257 | pkts = dropped = errors = bytes = 0; |
6258 | |||
6259 | rx_rings = ACCESS_ONCE(np->rx_rings); | ||
6260 | if (!rx_rings) | ||
6261 | goto no_rings; | ||
6262 | |||
6252 | for (i = 0; i < np->num_rx_rings; i++) { | 6263 | for (i = 0; i < np->num_rx_rings; i++) { |
6253 | struct rx_ring_info *rp = &np->rx_rings[i]; | 6264 | struct rx_ring_info *rp = &rx_rings[i]; |
6254 | 6265 | ||
6255 | niu_sync_rx_discard_stats(np, rp, 0); | 6266 | niu_sync_rx_discard_stats(np, rp, 0); |
6256 | 6267 | ||
@@ -6259,6 +6270,8 @@ static void niu_get_rx_stats(struct niu *np) | |||
6259 | dropped += rp->rx_dropped; | 6270 | dropped += rp->rx_dropped; |
6260 | errors += rp->rx_errors; | 6271 | errors += rp->rx_errors; |
6261 | } | 6272 | } |
6273 | |||
6274 | no_rings: | ||
6262 | np->dev->stats.rx_packets = pkts; | 6275 | np->dev->stats.rx_packets = pkts; |
6263 | np->dev->stats.rx_bytes = bytes; | 6276 | np->dev->stats.rx_bytes = bytes; |
6264 | np->dev->stats.rx_dropped = dropped; | 6277 | np->dev->stats.rx_dropped = dropped; |
@@ -6268,16 +6281,24 @@ static void niu_get_rx_stats(struct niu *np) | |||
6268 | static void niu_get_tx_stats(struct niu *np) | 6281 | static void niu_get_tx_stats(struct niu *np) |
6269 | { | 6282 | { |
6270 | unsigned long pkts, errors, bytes; | 6283 | unsigned long pkts, errors, bytes; |
6284 | struct tx_ring_info *tx_rings; | ||
6271 | int i; | 6285 | int i; |
6272 | 6286 | ||
6273 | pkts = errors = bytes = 0; | 6287 | pkts = errors = bytes = 0; |
6288 | |||
6289 | tx_rings = ACCESS_ONCE(np->tx_rings); | ||
6290 | if (!tx_rings) | ||
6291 | goto no_rings; | ||
6292 | |||
6274 | for (i = 0; i < np->num_tx_rings; i++) { | 6293 | for (i = 0; i < np->num_tx_rings; i++) { |
6275 | struct tx_ring_info *rp = &np->tx_rings[i]; | 6294 | struct tx_ring_info *rp = &tx_rings[i]; |
6276 | 6295 | ||
6277 | pkts += rp->tx_packets; | 6296 | pkts += rp->tx_packets; |
6278 | bytes += rp->tx_bytes; | 6297 | bytes += rp->tx_bytes; |
6279 | errors += rp->tx_errors; | 6298 | errors += rp->tx_errors; |
6280 | } | 6299 | } |
6300 | |||
6301 | no_rings: | ||
6281 | np->dev->stats.tx_packets = pkts; | 6302 | np->dev->stats.tx_packets = pkts; |
6282 | np->dev->stats.tx_bytes = bytes; | 6303 | np->dev->stats.tx_bytes = bytes; |
6283 | np->dev->stats.tx_errors = errors; | 6304 | np->dev->stats.tx_errors = errors; |
@@ -6287,9 +6308,10 @@ static struct net_device_stats *niu_get_stats(struct net_device *dev) | |||
6287 | { | 6308 | { |
6288 | struct niu *np = netdev_priv(dev); | 6309 | struct niu *np = netdev_priv(dev); |
6289 | 6310 | ||
6290 | niu_get_rx_stats(np); | 6311 | if (netif_running(dev)) { |
6291 | niu_get_tx_stats(np); | 6312 | niu_get_rx_stats(np); |
6292 | 6313 | niu_get_tx_stats(np); | |
6314 | } | ||
6293 | return &dev->stats; | 6315 | return &dev->stats; |
6294 | } | 6316 | } |
6295 | 6317 | ||
@@ -6589,7 +6611,7 @@ static u64 niu_compute_tx_flags(struct sk_buff *skb, struct ethhdr *ehdr, | |||
6589 | (ip_proto == IPPROTO_UDP ? | 6611 | (ip_proto == IPPROTO_UDP ? |
6590 | TXHDR_CSUM_UDP : TXHDR_CSUM_SCTP)); | 6612 | TXHDR_CSUM_UDP : TXHDR_CSUM_SCTP)); |
6591 | 6613 | ||
6592 | start = skb_transport_offset(skb) - | 6614 | start = skb_checksum_start_offset(skb) - |
6593 | (pad_bytes + sizeof(struct tx_pkt_hdr)); | 6615 | (pad_bytes + sizeof(struct tx_pkt_hdr)); |
6594 | stuff = start + skb->csum_offset; | 6616 | stuff = start + skb->csum_offset; |
6595 | 6617 | ||
@@ -6822,7 +6844,7 @@ static int niu_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
6822 | cmd->supported = lp->supported; | 6844 | cmd->supported = lp->supported; |
6823 | cmd->advertising = lp->active_advertising; | 6845 | cmd->advertising = lp->active_advertising; |
6824 | cmd->autoneg = lp->active_autoneg; | 6846 | cmd->autoneg = lp->active_autoneg; |
6825 | cmd->speed = lp->active_speed; | 6847 | ethtool_cmd_speed_set(cmd, lp->active_speed); |
6826 | cmd->duplex = lp->active_duplex; | 6848 | cmd->duplex = lp->active_duplex; |
6827 | cmd->port = (np->flags & NIU_FLAGS_FIBER) ? PORT_FIBRE : PORT_TP; | 6849 | cmd->port = (np->flags & NIU_FLAGS_FIBER) ? PORT_FIBRE : PORT_TP; |
6828 | cmd->transceiver = (np->flags & NIU_FLAGS_XCVR_SERDES) ? | 6850 | cmd->transceiver = (np->flags & NIU_FLAGS_XCVR_SERDES) ? |
@@ -6837,7 +6859,7 @@ static int niu_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
6837 | struct niu_link_config *lp = &np->link_config; | 6859 | struct niu_link_config *lp = &np->link_config; |
6838 | 6860 | ||
6839 | lp->advertising = cmd->advertising; | 6861 | lp->advertising = cmd->advertising; |
6840 | lp->speed = cmd->speed; | 6862 | lp->speed = ethtool_cmd_speed(cmd); |
6841 | lp->duplex = cmd->duplex; | 6863 | lp->duplex = cmd->duplex; |
6842 | lp->autoneg = cmd->autoneg; | 6864 | lp->autoneg = cmd->autoneg; |
6843 | return niu_init_link(np); | 6865 | return niu_init_link(np); |
@@ -6994,6 +7016,7 @@ static int niu_ethflow_to_class(int flow_type, u64 *class) | |||
6994 | case UDP_V4_FLOW: | 7016 | case UDP_V4_FLOW: |
6995 | *class = CLASS_CODE_UDP_IPV4; | 7017 | *class = CLASS_CODE_UDP_IPV4; |
6996 | break; | 7018 | break; |
7019 | case AH_ESP_V4_FLOW: | ||
6997 | case AH_V4_FLOW: | 7020 | case AH_V4_FLOW: |
6998 | case ESP_V4_FLOW: | 7021 | case ESP_V4_FLOW: |
6999 | *class = CLASS_CODE_AH_ESP_IPV4; | 7022 | *class = CLASS_CODE_AH_ESP_IPV4; |
@@ -7007,6 +7030,7 @@ static int niu_ethflow_to_class(int flow_type, u64 *class) | |||
7007 | case UDP_V6_FLOW: | 7030 | case UDP_V6_FLOW: |
7008 | *class = CLASS_CODE_UDP_IPV6; | 7031 | *class = CLASS_CODE_UDP_IPV6; |
7009 | break; | 7032 | break; |
7033 | case AH_ESP_V6_FLOW: | ||
7010 | case AH_V6_FLOW: | 7034 | case AH_V6_FLOW: |
7011 | case ESP_V6_FLOW: | 7035 | case ESP_V6_FLOW: |
7012 | *class = CLASS_CODE_AH_ESP_IPV6; | 7036 | *class = CLASS_CODE_AH_ESP_IPV6; |
@@ -7090,24 +7114,20 @@ static int niu_get_hash_opts(struct niu *np, struct ethtool_rxnfc *nfc) | |||
7090 | static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp, | 7114 | static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp, |
7091 | struct ethtool_rx_flow_spec *fsp) | 7115 | struct ethtool_rx_flow_spec *fsp) |
7092 | { | 7116 | { |
7117 | u32 tmp; | ||
7118 | u16 prt; | ||
7119 | |||
7120 | tmp = (tp->key[3] & TCAM_V4KEY3_SADDR) >> TCAM_V4KEY3_SADDR_SHIFT; | ||
7121 | fsp->h_u.tcp_ip4_spec.ip4src = cpu_to_be32(tmp); | ||
7122 | |||
7123 | tmp = (tp->key[3] & TCAM_V4KEY3_DADDR) >> TCAM_V4KEY3_DADDR_SHIFT; | ||
7124 | fsp->h_u.tcp_ip4_spec.ip4dst = cpu_to_be32(tmp); | ||
7125 | |||
7126 | tmp = (tp->key_mask[3] & TCAM_V4KEY3_SADDR) >> TCAM_V4KEY3_SADDR_SHIFT; | ||
7127 | fsp->m_u.tcp_ip4_spec.ip4src = cpu_to_be32(tmp); | ||
7093 | 7128 | ||
7094 | fsp->h_u.tcp_ip4_spec.ip4src = (tp->key[3] & TCAM_V4KEY3_SADDR) >> | 7129 | tmp = (tp->key_mask[3] & TCAM_V4KEY3_DADDR) >> TCAM_V4KEY3_DADDR_SHIFT; |
7095 | TCAM_V4KEY3_SADDR_SHIFT; | 7130 | fsp->m_u.tcp_ip4_spec.ip4dst = cpu_to_be32(tmp); |
7096 | fsp->h_u.tcp_ip4_spec.ip4dst = (tp->key[3] & TCAM_V4KEY3_DADDR) >> | ||
7097 | TCAM_V4KEY3_DADDR_SHIFT; | ||
7098 | fsp->m_u.tcp_ip4_spec.ip4src = (tp->key_mask[3] & TCAM_V4KEY3_SADDR) >> | ||
7099 | TCAM_V4KEY3_SADDR_SHIFT; | ||
7100 | fsp->m_u.tcp_ip4_spec.ip4dst = (tp->key_mask[3] & TCAM_V4KEY3_DADDR) >> | ||
7101 | TCAM_V4KEY3_DADDR_SHIFT; | ||
7102 | |||
7103 | fsp->h_u.tcp_ip4_spec.ip4src = | ||
7104 | cpu_to_be32(fsp->h_u.tcp_ip4_spec.ip4src); | ||
7105 | fsp->m_u.tcp_ip4_spec.ip4src = | ||
7106 | cpu_to_be32(fsp->m_u.tcp_ip4_spec.ip4src); | ||
7107 | fsp->h_u.tcp_ip4_spec.ip4dst = | ||
7108 | cpu_to_be32(fsp->h_u.tcp_ip4_spec.ip4dst); | ||
7109 | fsp->m_u.tcp_ip4_spec.ip4dst = | ||
7110 | cpu_to_be32(fsp->m_u.tcp_ip4_spec.ip4dst); | ||
7111 | 7131 | ||
7112 | fsp->h_u.tcp_ip4_spec.tos = (tp->key[2] & TCAM_V4KEY2_TOS) >> | 7132 | fsp->h_u.tcp_ip4_spec.tos = (tp->key[2] & TCAM_V4KEY2_TOS) >> |
7113 | TCAM_V4KEY2_TOS_SHIFT; | 7133 | TCAM_V4KEY2_TOS_SHIFT; |
@@ -7118,54 +7138,40 @@ static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp, | |||
7118 | case TCP_V4_FLOW: | 7138 | case TCP_V4_FLOW: |
7119 | case UDP_V4_FLOW: | 7139 | case UDP_V4_FLOW: |
7120 | case SCTP_V4_FLOW: | 7140 | case SCTP_V4_FLOW: |
7121 | fsp->h_u.tcp_ip4_spec.psrc = | 7141 | prt = ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7122 | ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | 7142 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; |
7123 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; | 7143 | fsp->h_u.tcp_ip4_spec.psrc = cpu_to_be16(prt); |
7124 | fsp->h_u.tcp_ip4_spec.pdst = | 7144 | |
7125 | ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | 7145 | prt = ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7126 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; | 7146 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; |
7127 | fsp->m_u.tcp_ip4_spec.psrc = | 7147 | fsp->h_u.tcp_ip4_spec.pdst = cpu_to_be16(prt); |
7128 | ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7129 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; | ||
7130 | fsp->m_u.tcp_ip4_spec.pdst = | ||
7131 | ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7132 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; | ||
7133 | 7148 | ||
7134 | fsp->h_u.tcp_ip4_spec.psrc = | 7149 | prt = ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7135 | cpu_to_be16(fsp->h_u.tcp_ip4_spec.psrc); | 7150 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; |
7136 | fsp->h_u.tcp_ip4_spec.pdst = | 7151 | fsp->m_u.tcp_ip4_spec.psrc = cpu_to_be16(prt); |
7137 | cpu_to_be16(fsp->h_u.tcp_ip4_spec.pdst); | 7152 | |
7138 | fsp->m_u.tcp_ip4_spec.psrc = | 7153 | prt = ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7139 | cpu_to_be16(fsp->m_u.tcp_ip4_spec.psrc); | 7154 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; |
7140 | fsp->m_u.tcp_ip4_spec.pdst = | 7155 | fsp->m_u.tcp_ip4_spec.pdst = cpu_to_be16(prt); |
7141 | cpu_to_be16(fsp->m_u.tcp_ip4_spec.pdst); | ||
7142 | break; | 7156 | break; |
7143 | case AH_V4_FLOW: | 7157 | case AH_V4_FLOW: |
7144 | case ESP_V4_FLOW: | 7158 | case ESP_V4_FLOW: |
7145 | fsp->h_u.ah_ip4_spec.spi = | 7159 | tmp = (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7146 | (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7147 | TCAM_V4KEY2_PORT_SPI_SHIFT; | ||
7148 | fsp->m_u.ah_ip4_spec.spi = | ||
7149 | (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7150 | TCAM_V4KEY2_PORT_SPI_SHIFT; | 7160 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7161 | fsp->h_u.ah_ip4_spec.spi = cpu_to_be32(tmp); | ||
7151 | 7162 | ||
7152 | fsp->h_u.ah_ip4_spec.spi = | 7163 | tmp = (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7153 | cpu_to_be32(fsp->h_u.ah_ip4_spec.spi); | 7164 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7154 | fsp->m_u.ah_ip4_spec.spi = | 7165 | fsp->m_u.ah_ip4_spec.spi = cpu_to_be32(tmp); |
7155 | cpu_to_be32(fsp->m_u.ah_ip4_spec.spi); | ||
7156 | break; | 7166 | break; |
7157 | case IP_USER_FLOW: | 7167 | case IP_USER_FLOW: |
7158 | fsp->h_u.usr_ip4_spec.l4_4_bytes = | 7168 | tmp = (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7159 | (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7160 | TCAM_V4KEY2_PORT_SPI_SHIFT; | ||
7161 | fsp->m_u.usr_ip4_spec.l4_4_bytes = | ||
7162 | (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7163 | TCAM_V4KEY2_PORT_SPI_SHIFT; | 7169 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7170 | fsp->h_u.usr_ip4_spec.l4_4_bytes = cpu_to_be32(tmp); | ||
7164 | 7171 | ||
7165 | fsp->h_u.usr_ip4_spec.l4_4_bytes = | 7172 | tmp = (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7166 | cpu_to_be32(fsp->h_u.usr_ip4_spec.l4_4_bytes); | 7173 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7167 | fsp->m_u.usr_ip4_spec.l4_4_bytes = | 7174 | fsp->m_u.usr_ip4_spec.l4_4_bytes = cpu_to_be32(tmp); |
7168 | cpu_to_be32(fsp->m_u.usr_ip4_spec.l4_4_bytes); | ||
7169 | 7175 | ||
7170 | fsp->h_u.usr_ip4_spec.proto = | 7176 | fsp->h_u.usr_ip4_spec.proto = |
7171 | (tp->key[2] & TCAM_V4KEY2_PROTO) >> | 7177 | (tp->key[2] & TCAM_V4KEY2_PROTO) >> |
@@ -7462,10 +7468,12 @@ static int niu_add_ethtool_tcam_entry(struct niu *np, | |||
7462 | if (fsp->flow_type == IP_USER_FLOW) { | 7468 | if (fsp->flow_type == IP_USER_FLOW) { |
7463 | int i; | 7469 | int i; |
7464 | int add_usr_cls = 0; | 7470 | int add_usr_cls = 0; |
7465 | int ipv6 = 0; | ||
7466 | struct ethtool_usrip4_spec *uspec = &fsp->h_u.usr_ip4_spec; | 7471 | struct ethtool_usrip4_spec *uspec = &fsp->h_u.usr_ip4_spec; |
7467 | struct ethtool_usrip4_spec *umask = &fsp->m_u.usr_ip4_spec; | 7472 | struct ethtool_usrip4_spec *umask = &fsp->m_u.usr_ip4_spec; |
7468 | 7473 | ||
7474 | if (uspec->ip_ver != ETH_RX_NFC_IP4) | ||
7475 | return -EINVAL; | ||
7476 | |||
7469 | niu_lock_parent(np, flags); | 7477 | niu_lock_parent(np, flags); |
7470 | 7478 | ||
7471 | for (i = 0; i < NIU_L3_PROG_CLS; i++) { | 7479 | for (i = 0; i < NIU_L3_PROG_CLS; i++) { |
@@ -7494,9 +7502,7 @@ static int niu_add_ethtool_tcam_entry(struct niu *np, | |||
7494 | default: | 7502 | default: |
7495 | break; | 7503 | break; |
7496 | } | 7504 | } |
7497 | if (uspec->ip_ver == ETH_RX_NFC_IP6) | 7505 | ret = tcam_user_ip_class_set(np, class, 0, |
7498 | ipv6 = 1; | ||
7499 | ret = tcam_user_ip_class_set(np, class, ipv6, | ||
7500 | uspec->proto, | 7506 | uspec->proto, |
7501 | uspec->tos, | 7507 | uspec->tos, |
7502 | umask->tos); | 7508 | umask->tos); |
@@ -7553,16 +7559,7 @@ static int niu_add_ethtool_tcam_entry(struct niu *np, | |||
7553 | ret = -EINVAL; | 7559 | ret = -EINVAL; |
7554 | goto out; | 7560 | goto out; |
7555 | case IP_USER_FLOW: | 7561 | case IP_USER_FLOW: |
7556 | if (fsp->h_u.usr_ip4_spec.ip_ver == ETH_RX_NFC_IP4) { | 7562 | niu_get_tcamkey_from_ip4fs(fsp, tp, l2_rdc_table, class); |
7557 | niu_get_tcamkey_from_ip4fs(fsp, tp, l2_rdc_table, | ||
7558 | class); | ||
7559 | } else { | ||
7560 | /* Not yet implemented */ | ||
7561 | netdev_info(np->dev, "niu%d: In %s(): usr flow for IPv6 not implemented\n", | ||
7562 | parent->index, __func__); | ||
7563 | ret = -EINVAL; | ||
7564 | goto out; | ||
7565 | } | ||
7566 | break; | 7563 | break; |
7567 | default: | 7564 | default: |
7568 | netdev_info(np->dev, "niu%d: In %s(): Unknown flow type %d\n", | 7565 | netdev_info(np->dev, "niu%d: In %s(): Unknown flow type %d\n", |
@@ -7805,11 +7802,11 @@ static int niu_get_sset_count(struct net_device *dev, int stringset) | |||
7805 | if (stringset != ETH_SS_STATS) | 7802 | if (stringset != ETH_SS_STATS) |
7806 | return -EINVAL; | 7803 | return -EINVAL; |
7807 | 7804 | ||
7808 | return ((np->flags & NIU_FLAGS_XMAC ? | 7805 | return (np->flags & NIU_FLAGS_XMAC ? |
7809 | NUM_XMAC_STAT_KEYS : | 7806 | NUM_XMAC_STAT_KEYS : |
7810 | NUM_BMAC_STAT_KEYS) + | 7807 | NUM_BMAC_STAT_KEYS) + |
7811 | (np->num_rx_rings * NUM_RXCHAN_STAT_KEYS) + | 7808 | (np->num_rx_rings * NUM_RXCHAN_STAT_KEYS) + |
7812 | (np->num_tx_rings * NUM_TXCHAN_STAT_KEYS)); | 7809 | (np->num_tx_rings * NUM_TXCHAN_STAT_KEYS); |
7813 | } | 7810 | } |
7814 | 7811 | ||
7815 | static void niu_get_ethtool_stats(struct net_device *dev, | 7812 | static void niu_get_ethtool_stats(struct net_device *dev, |
@@ -7887,37 +7884,35 @@ static void niu_force_led(struct niu *np, int on) | |||
7887 | nw64_mac(reg, val); | 7884 | nw64_mac(reg, val); |
7888 | } | 7885 | } |
7889 | 7886 | ||
7890 | static int niu_phys_id(struct net_device *dev, u32 data) | 7887 | static int niu_set_phys_id(struct net_device *dev, |
7888 | enum ethtool_phys_id_state state) | ||
7889 | |||
7891 | { | 7890 | { |
7892 | struct niu *np = netdev_priv(dev); | 7891 | struct niu *np = netdev_priv(dev); |
7893 | u64 orig_led_state; | ||
7894 | int i; | ||
7895 | 7892 | ||
7896 | if (!netif_running(dev)) | 7893 | if (!netif_running(dev)) |
7897 | return -EAGAIN; | 7894 | return -EAGAIN; |
7898 | 7895 | ||
7899 | if (data == 0) | 7896 | switch (state) { |
7900 | data = 2; | 7897 | case ETHTOOL_ID_ACTIVE: |
7898 | np->orig_led_state = niu_led_state_save(np); | ||
7899 | return 1; /* cycle on/off once per second */ | ||
7901 | 7900 | ||
7902 | orig_led_state = niu_led_state_save(np); | 7901 | case ETHTOOL_ID_ON: |
7903 | for (i = 0; i < (data * 2); i++) { | 7902 | niu_force_led(np, 1); |
7904 | int on = ((i % 2) == 0); | 7903 | break; |
7905 | 7904 | ||
7906 | niu_force_led(np, on); | 7905 | case ETHTOOL_ID_OFF: |
7906 | niu_force_led(np, 0); | ||
7907 | break; | ||
7907 | 7908 | ||
7908 | if (msleep_interruptible(500)) | 7909 | case ETHTOOL_ID_INACTIVE: |
7909 | break; | 7910 | niu_led_state_restore(np, np->orig_led_state); |
7910 | } | 7911 | } |
7911 | niu_led_state_restore(np, orig_led_state); | ||
7912 | 7912 | ||
7913 | return 0; | 7913 | return 0; |
7914 | } | 7914 | } |
7915 | 7915 | ||
7916 | static int niu_set_flags(struct net_device *dev, u32 data) | ||
7917 | { | ||
7918 | return ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH); | ||
7919 | } | ||
7920 | |||
7921 | static const struct ethtool_ops niu_ethtool_ops = { | 7916 | static const struct ethtool_ops niu_ethtool_ops = { |
7922 | .get_drvinfo = niu_get_drvinfo, | 7917 | .get_drvinfo = niu_get_drvinfo, |
7923 | .get_link = ethtool_op_get_link, | 7918 | .get_link = ethtool_op_get_link, |
@@ -7931,11 +7926,9 @@ static const struct ethtool_ops niu_ethtool_ops = { | |||
7931 | .get_strings = niu_get_strings, | 7926 | .get_strings = niu_get_strings, |
7932 | .get_sset_count = niu_get_sset_count, | 7927 | .get_sset_count = niu_get_sset_count, |
7933 | .get_ethtool_stats = niu_get_ethtool_stats, | 7928 | .get_ethtool_stats = niu_get_ethtool_stats, |
7934 | .phys_id = niu_phys_id, | 7929 | .set_phys_id = niu_set_phys_id, |
7935 | .get_rxnfc = niu_get_nfc, | 7930 | .get_rxnfc = niu_get_nfc, |
7936 | .set_rxnfc = niu_set_nfc, | 7931 | .set_rxnfc = niu_set_nfc, |
7937 | .set_flags = niu_set_flags, | ||
7938 | .get_flags = ethtool_op_get_flags, | ||
7939 | }; | 7932 | }; |
7940 | 7933 | ||
7941 | static int niu_ldg_assign_ldn(struct niu *np, struct niu_parent *parent, | 7934 | static int niu_ldg_assign_ldn(struct niu *np, struct niu_parent *parent, |
@@ -8129,7 +8122,7 @@ static int __devinit niu_pci_vpd_scan_props(struct niu *np, | |||
8129 | netif_printk(np, probe, KERN_DEBUG, np->dev, | 8122 | netif_printk(np, probe, KERN_DEBUG, np->dev, |
8130 | "VPD_SCAN: start[%x] end[%x]\n", start, end); | 8123 | "VPD_SCAN: start[%x] end[%x]\n", start, end); |
8131 | while (start < end) { | 8124 | while (start < end) { |
8132 | int len, err, instance, type, prop_len; | 8125 | int len, err, prop_len; |
8133 | char namebuf[64]; | 8126 | char namebuf[64]; |
8134 | u8 *prop_buf; | 8127 | u8 *prop_buf; |
8135 | int max_len; | 8128 | int max_len; |
@@ -8145,8 +8138,6 @@ static int __devinit niu_pci_vpd_scan_props(struct niu *np, | |||
8145 | len = err; | 8138 | len = err; |
8146 | start += 3; | 8139 | start += 3; |
8147 | 8140 | ||
8148 | instance = niu_pci_eeprom_read(np, start); | ||
8149 | type = niu_pci_eeprom_read(np, start + 3); | ||
8150 | prop_len = niu_pci_eeprom_read(np, start + 4); | 8141 | prop_len = niu_pci_eeprom_read(np, start + 4); |
8151 | err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64); | 8142 | err = niu_pci_vpd_get_propname(np, start + 5, namebuf, 64); |
8152 | if (err < 0) | 8143 | if (err < 0) |
@@ -9499,7 +9490,7 @@ static struct niu_parent * __devinit niu_new_parent(struct niu *np, | |||
9499 | struct niu_parent *p; | 9490 | struct niu_parent *p; |
9500 | int i; | 9491 | int i; |
9501 | 9492 | ||
9502 | plat_dev = platform_device_register_simple("niu", niu_parent_index, | 9493 | plat_dev = platform_device_register_simple("niu-board", niu_parent_index, |
9503 | NULL, 0); | 9494 | NULL, 0); |
9504 | if (IS_ERR(plat_dev)) | 9495 | if (IS_ERR(plat_dev)) |
9505 | return NULL; | 9496 | return NULL; |
@@ -9766,8 +9757,8 @@ static void __devinit niu_device_announce(struct niu *np) | |||
9766 | 9757 | ||
9767 | static void __devinit niu_set_basic_features(struct net_device *dev) | 9758 | static void __devinit niu_set_basic_features(struct net_device *dev) |
9768 | { | 9759 | { |
9769 | dev->features |= (NETIF_F_SG | NETIF_F_HW_CSUM | | 9760 | dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_RXHASH; |
9770 | NETIF_F_GRO | NETIF_F_RXHASH); | 9761 | dev->features |= dev->hw_features | NETIF_F_RXCSUM; |
9771 | } | 9762 | } |
9772 | 9763 | ||
9773 | static int __devinit niu_pci_init_one(struct pci_dev *pdev, | 9764 | static int __devinit niu_pci_init_one(struct pci_dev *pdev, |
@@ -9944,7 +9935,7 @@ static int niu_suspend(struct pci_dev *pdev, pm_message_t state) | |||
9944 | if (!netif_running(dev)) | 9935 | if (!netif_running(dev)) |
9945 | return 0; | 9936 | return 0; |
9946 | 9937 | ||
9947 | flush_scheduled_work(); | 9938 | flush_work_sync(&np->reset_task); |
9948 | niu_netif_stop(np); | 9939 | niu_netif_stop(np); |
9949 | 9940 | ||
9950 | del_timer_sync(&np->timer); | 9941 | del_timer_sync(&np->timer); |
@@ -10060,8 +10051,7 @@ static const struct niu_ops niu_phys_ops = { | |||
10060 | .unmap_single = niu_phys_unmap_single, | 10051 | .unmap_single = niu_phys_unmap_single, |
10061 | }; | 10052 | }; |
10062 | 10053 | ||
10063 | static int __devinit niu_of_probe(struct platform_device *op, | 10054 | static int __devinit niu_of_probe(struct platform_device *op) |
10064 | const struct of_device_id *match) | ||
10065 | { | 10055 | { |
10066 | union niu_parent_id parent_id; | 10056 | union niu_parent_id parent_id; |
10067 | struct net_device *dev; | 10057 | struct net_device *dev; |
@@ -10221,7 +10211,7 @@ static const struct of_device_id niu_match[] = { | |||
10221 | }; | 10211 | }; |
10222 | MODULE_DEVICE_TABLE(of, niu_match); | 10212 | MODULE_DEVICE_TABLE(of, niu_match); |
10223 | 10213 | ||
10224 | static struct of_platform_driver niu_of_driver = { | 10214 | static struct platform_driver niu_of_driver = { |
10225 | .driver = { | 10215 | .driver = { |
10226 | .name = "niu", | 10216 | .name = "niu", |
10227 | .owner = THIS_MODULE, | 10217 | .owner = THIS_MODULE, |
@@ -10242,14 +10232,14 @@ static int __init niu_init(void) | |||
10242 | niu_debug = netif_msg_init(debug, NIU_MSG_DEFAULT); | 10232 | niu_debug = netif_msg_init(debug, NIU_MSG_DEFAULT); |
10243 | 10233 | ||
10244 | #ifdef CONFIG_SPARC64 | 10234 | #ifdef CONFIG_SPARC64 |
10245 | err = of_register_platform_driver(&niu_of_driver); | 10235 | err = platform_driver_register(&niu_of_driver); |
10246 | #endif | 10236 | #endif |
10247 | 10237 | ||
10248 | if (!err) { | 10238 | if (!err) { |
10249 | err = pci_register_driver(&niu_pci_driver); | 10239 | err = pci_register_driver(&niu_pci_driver); |
10250 | #ifdef CONFIG_SPARC64 | 10240 | #ifdef CONFIG_SPARC64 |
10251 | if (err) | 10241 | if (err) |
10252 | of_unregister_platform_driver(&niu_of_driver); | 10242 | platform_driver_unregister(&niu_of_driver); |
10253 | #endif | 10243 | #endif |
10254 | } | 10244 | } |
10255 | 10245 | ||
@@ -10260,7 +10250,7 @@ static void __exit niu_exit(void) | |||
10260 | { | 10250 | { |
10261 | pci_unregister_driver(&niu_pci_driver); | 10251 | pci_unregister_driver(&niu_pci_driver); |
10262 | #ifdef CONFIG_SPARC64 | 10252 | #ifdef CONFIG_SPARC64 |
10263 | of_unregister_platform_driver(&niu_of_driver); | 10253 | platform_driver_unregister(&niu_of_driver); |
10264 | #endif | 10254 | #endif |
10265 | } | 10255 | } |
10266 | 10256 | ||