aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/niu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/niu.c')
-rw-r--r--drivers/net/niu.c133
1 files changed, 53 insertions, 80 deletions
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index fe6983af6918..781e368329f9 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
284static u32 phy_encode(u32 type, int port) 284static u32 phy_encode(u32 type, int port)
285{ 285{
286 return (type << (port * 2)); 286 return type << (port * 2);
287} 287}
288 288
289static u32 phy_decode(u32 val, int port) 289static u32 phy_decode(u32 val, int port)
@@ -3043,8 +3043,7 @@ static int tcam_flush_all(struct niu *np)
3043 3043
3044static u64 hash_addr_regval(unsigned long index, unsigned long num_entries) 3044static u64 hash_addr_regval(unsigned long index, unsigned long num_entries)
3045{ 3045{
3046 return ((u64)index | (num_entries == 1 ? 3046 return (u64)index | (num_entries == 1 ? HASH_TBL_ADDR_AUTOINC : 0);
3047 HASH_TBL_ADDR_AUTOINC : 0));
3048} 3047}
3049 3048
3050#if 0 3049#if 0
@@ -3276,7 +3275,7 @@ static u16 tcam_get_index(struct niu *np, u16 idx)
3276 /* One entry reserved for IP fragment rule */ 3275 /* One entry reserved for IP fragment rule */
3277 if (idx >= (np->clas.tcam_sz - 1)) 3276 if (idx >= (np->clas.tcam_sz - 1))
3278 idx = 0; 3277 idx = 0;
3279 return (np->clas.tcam_top + ((idx+1) * np->parent->num_ports)); 3278 return np->clas.tcam_top + ((idx+1) * np->parent->num_ports);
3280} 3279}
3281 3280
3282static u16 tcam_get_size(struct niu *np) 3281static u16 tcam_get_size(struct niu *np)
@@ -3313,7 +3312,7 @@ static unsigned int niu_hash_rxaddr(struct rx_ring_info *rp, u64 a)
3313 a >>= PAGE_SHIFT; 3312 a >>= PAGE_SHIFT;
3314 a ^= (a >> ilog2(MAX_RBR_RING_SIZE)); 3313 a ^= (a >> ilog2(MAX_RBR_RING_SIZE));
3315 3314
3316 return (a & (MAX_RBR_RING_SIZE - 1)); 3315 return a & (MAX_RBR_RING_SIZE - 1);
3317} 3316}
3318 3317
3319static struct page *niu_find_rxpage(struct rx_ring_info *rp, u64 addr, 3318static struct page *niu_find_rxpage(struct rx_ring_info *rp, u64 addr,
@@ -3484,7 +3483,7 @@ static int niu_process_rx_pkt(struct napi_struct *napi, struct niu *np,
3484 RCR_ENTRY_ERROR))) 3483 RCR_ENTRY_ERROR)))
3485 skb->ip_summed = CHECKSUM_UNNECESSARY; 3484 skb->ip_summed = CHECKSUM_UNNECESSARY;
3486 else 3485 else
3487 skb->ip_summed = CHECKSUM_NONE; 3486 skb_checksum_none_assert(skb);
3488 } else if (!(val & RCR_ENTRY_MULTI)) 3487 } else if (!(val & RCR_ENTRY_MULTI))
3489 append_size = len - skb->len; 3488 append_size = len - skb->len;
3490 3489
@@ -4502,9 +4501,10 @@ static int niu_alloc_channels(struct niu *np)
4502 np->num_rx_rings = parent->rxchan_per_port[port]; 4501 np->num_rx_rings = parent->rxchan_per_port[port];
4503 np->num_tx_rings = parent->txchan_per_port[port]; 4502 np->num_tx_rings = parent->txchan_per_port[port];
4504 4503
4505 np->dev->real_num_tx_queues = np->num_tx_rings; 4504 netif_set_real_num_rx_queues(np->dev, np->num_rx_rings);
4505 netif_set_real_num_tx_queues(np->dev, np->num_tx_rings);
4506 4506
4507 np->rx_rings = kzalloc(np->num_rx_rings * sizeof(struct rx_ring_info), 4507 np->rx_rings = kcalloc(np->num_rx_rings, sizeof(struct rx_ring_info),
4508 GFP_KERNEL); 4508 GFP_KERNEL);
4509 err = -ENOMEM; 4509 err = -ENOMEM;
4510 if (!np->rx_rings) 4510 if (!np->rx_rings)
@@ -4538,7 +4538,7 @@ 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 np->tx_rings = kcalloc(np->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 (!np->tx_rings)
@@ -7090,24 +7090,20 @@ static int niu_get_hash_opts(struct niu *np, struct ethtool_rxnfc *nfc)
7090static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp, 7090static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp,
7091 struct ethtool_rx_flow_spec *fsp) 7091 struct ethtool_rx_flow_spec *fsp)
7092{ 7092{
7093 u32 tmp;
7094 u16 prt;
7093 7095
7094 fsp->h_u.tcp_ip4_spec.ip4src = (tp->key[3] & TCAM_V4KEY3_SADDR) >> 7096 tmp = (tp->key[3] & TCAM_V4KEY3_SADDR) >> TCAM_V4KEY3_SADDR_SHIFT;
7095 TCAM_V4KEY3_SADDR_SHIFT; 7097 fsp->h_u.tcp_ip4_spec.ip4src = cpu_to_be32(tmp);
7096 fsp->h_u.tcp_ip4_spec.ip4dst = (tp->key[3] & TCAM_V4KEY3_DADDR) >> 7098
7097 TCAM_V4KEY3_DADDR_SHIFT; 7099 tmp = (tp->key[3] & TCAM_V4KEY3_DADDR) >> TCAM_V4KEY3_DADDR_SHIFT;
7098 fsp->m_u.tcp_ip4_spec.ip4src = (tp->key_mask[3] & TCAM_V4KEY3_SADDR) >> 7100 fsp->h_u.tcp_ip4_spec.ip4dst = cpu_to_be32(tmp);
7099 TCAM_V4KEY3_SADDR_SHIFT; 7101
7100 fsp->m_u.tcp_ip4_spec.ip4dst = (tp->key_mask[3] & TCAM_V4KEY3_DADDR) >> 7102 tmp = (tp->key_mask[3] & TCAM_V4KEY3_SADDR) >> TCAM_V4KEY3_SADDR_SHIFT;
7101 TCAM_V4KEY3_DADDR_SHIFT; 7103 fsp->m_u.tcp_ip4_spec.ip4src = cpu_to_be32(tmp);
7102 7104
7103 fsp->h_u.tcp_ip4_spec.ip4src = 7105 tmp = (tp->key_mask[3] & TCAM_V4KEY3_DADDR) >> TCAM_V4KEY3_DADDR_SHIFT;
7104 cpu_to_be32(fsp->h_u.tcp_ip4_spec.ip4src); 7106 fsp->m_u.tcp_ip4_spec.ip4dst = cpu_to_be32(tmp);
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 7107
7112 fsp->h_u.tcp_ip4_spec.tos = (tp->key[2] & TCAM_V4KEY2_TOS) >> 7108 fsp->h_u.tcp_ip4_spec.tos = (tp->key[2] & TCAM_V4KEY2_TOS) >>
7113 TCAM_V4KEY2_TOS_SHIFT; 7109 TCAM_V4KEY2_TOS_SHIFT;
@@ -7118,54 +7114,40 @@ static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp,
7118 case TCP_V4_FLOW: 7114 case TCP_V4_FLOW:
7119 case UDP_V4_FLOW: 7115 case UDP_V4_FLOW:
7120 case SCTP_V4_FLOW: 7116 case SCTP_V4_FLOW:
7121 fsp->h_u.tcp_ip4_spec.psrc = 7117 prt = ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >>
7122 ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> 7118 TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16;
7123 TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; 7119 fsp->h_u.tcp_ip4_spec.psrc = cpu_to_be16(prt);
7124 fsp->h_u.tcp_ip4_spec.pdst =
7125 ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >>
7126 TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff;
7127 fsp->m_u.tcp_ip4_spec.psrc =
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 7120
7134 fsp->h_u.tcp_ip4_spec.psrc = 7121 prt = ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >>
7135 cpu_to_be16(fsp->h_u.tcp_ip4_spec.psrc); 7122 TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff;
7136 fsp->h_u.tcp_ip4_spec.pdst = 7123 fsp->h_u.tcp_ip4_spec.pdst = cpu_to_be16(prt);
7137 cpu_to_be16(fsp->h_u.tcp_ip4_spec.pdst); 7124
7138 fsp->m_u.tcp_ip4_spec.psrc = 7125 prt = ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >>
7139 cpu_to_be16(fsp->m_u.tcp_ip4_spec.psrc); 7126 TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16;
7140 fsp->m_u.tcp_ip4_spec.pdst = 7127 fsp->m_u.tcp_ip4_spec.psrc = cpu_to_be16(prt);
7141 cpu_to_be16(fsp->m_u.tcp_ip4_spec.pdst); 7128
7129 prt = ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >>
7130 TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff;
7131 fsp->m_u.tcp_ip4_spec.pdst = cpu_to_be16(prt);
7142 break; 7132 break;
7143 case AH_V4_FLOW: 7133 case AH_V4_FLOW:
7144 case ESP_V4_FLOW: 7134 case ESP_V4_FLOW:
7145 fsp->h_u.ah_ip4_spec.spi = 7135 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; 7136 TCAM_V4KEY2_PORT_SPI_SHIFT;
7137 fsp->h_u.ah_ip4_spec.spi = cpu_to_be32(tmp);
7151 7138
7152 fsp->h_u.ah_ip4_spec.spi = 7139 tmp = (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >>
7153 cpu_to_be32(fsp->h_u.ah_ip4_spec.spi); 7140 TCAM_V4KEY2_PORT_SPI_SHIFT;
7154 fsp->m_u.ah_ip4_spec.spi = 7141 fsp->m_u.ah_ip4_spec.spi = cpu_to_be32(tmp);
7155 cpu_to_be32(fsp->m_u.ah_ip4_spec.spi);
7156 break; 7142 break;
7157 case IP_USER_FLOW: 7143 case IP_USER_FLOW:
7158 fsp->h_u.usr_ip4_spec.l4_4_bytes = 7144 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; 7145 TCAM_V4KEY2_PORT_SPI_SHIFT;
7146 fsp->h_u.usr_ip4_spec.l4_4_bytes = cpu_to_be32(tmp);
7164 7147
7165 fsp->h_u.usr_ip4_spec.l4_4_bytes = 7148 tmp = (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >>
7166 cpu_to_be32(fsp->h_u.usr_ip4_spec.l4_4_bytes); 7149 TCAM_V4KEY2_PORT_SPI_SHIFT;
7167 fsp->m_u.usr_ip4_spec.l4_4_bytes = 7150 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 7151
7170 fsp->h_u.usr_ip4_spec.proto = 7152 fsp->h_u.usr_ip4_spec.proto =
7171 (tp->key[2] & TCAM_V4KEY2_PROTO) >> 7153 (tp->key[2] & TCAM_V4KEY2_PROTO) >>
@@ -7462,10 +7444,12 @@ static int niu_add_ethtool_tcam_entry(struct niu *np,
7462 if (fsp->flow_type == IP_USER_FLOW) { 7444 if (fsp->flow_type == IP_USER_FLOW) {
7463 int i; 7445 int i;
7464 int add_usr_cls = 0; 7446 int add_usr_cls = 0;
7465 int ipv6 = 0;
7466 struct ethtool_usrip4_spec *uspec = &fsp->h_u.usr_ip4_spec; 7447 struct ethtool_usrip4_spec *uspec = &fsp->h_u.usr_ip4_spec;
7467 struct ethtool_usrip4_spec *umask = &fsp->m_u.usr_ip4_spec; 7448 struct ethtool_usrip4_spec *umask = &fsp->m_u.usr_ip4_spec;
7468 7449
7450 if (uspec->ip_ver != ETH_RX_NFC_IP4)
7451 return -EINVAL;
7452
7469 niu_lock_parent(np, flags); 7453 niu_lock_parent(np, flags);
7470 7454
7471 for (i = 0; i < NIU_L3_PROG_CLS; i++) { 7455 for (i = 0; i < NIU_L3_PROG_CLS; i++) {
@@ -7494,9 +7478,7 @@ static int niu_add_ethtool_tcam_entry(struct niu *np,
7494 default: 7478 default:
7495 break; 7479 break;
7496 } 7480 }
7497 if (uspec->ip_ver == ETH_RX_NFC_IP6) 7481 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, 7482 uspec->proto,
7501 uspec->tos, 7483 uspec->tos,
7502 umask->tos); 7484 umask->tos);
@@ -7553,16 +7535,7 @@ static int niu_add_ethtool_tcam_entry(struct niu *np,
7553 ret = -EINVAL; 7535 ret = -EINVAL;
7554 goto out; 7536 goto out;
7555 case IP_USER_FLOW: 7537 case IP_USER_FLOW:
7556 if (fsp->h_u.usr_ip4_spec.ip_ver == ETH_RX_NFC_IP4) { 7538 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; 7539 break;
7567 default: 7540 default:
7568 netdev_info(np->dev, "niu%d: In %s(): Unknown flow type %d\n", 7541 netdev_info(np->dev, "niu%d: In %s(): Unknown flow type %d\n",
@@ -7805,11 +7778,11 @@ static int niu_get_sset_count(struct net_device *dev, int stringset)
7805 if (stringset != ETH_SS_STATS) 7778 if (stringset != ETH_SS_STATS)
7806 return -EINVAL; 7779 return -EINVAL;
7807 7780
7808 return ((np->flags & NIU_FLAGS_XMAC ? 7781 return (np->flags & NIU_FLAGS_XMAC ?
7809 NUM_XMAC_STAT_KEYS : 7782 NUM_XMAC_STAT_KEYS :
7810 NUM_BMAC_STAT_KEYS) + 7783 NUM_BMAC_STAT_KEYS) +
7811 (np->num_rx_rings * NUM_RXCHAN_STAT_KEYS) + 7784 (np->num_rx_rings * NUM_RXCHAN_STAT_KEYS) +
7812 (np->num_tx_rings * NUM_TXCHAN_STAT_KEYS)); 7785 (np->num_tx_rings * NUM_TXCHAN_STAT_KEYS);
7813} 7786}
7814 7787
7815static void niu_get_ethtool_stats(struct net_device *dev, 7788static void niu_get_ethtool_stats(struct net_device *dev,