diff options
63 files changed, 1020 insertions, 560 deletions
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 7717b19dc806..947adda3397d 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c | |||
| @@ -962,9 +962,10 @@ static void b53_vlan_add(struct dsa_switch *ds, int port, | |||
| 962 | 962 | ||
| 963 | vl->members |= BIT(port) | BIT(cpu_port); | 963 | vl->members |= BIT(port) | BIT(cpu_port); |
| 964 | if (untagged) | 964 | if (untagged) |
| 965 | vl->untag |= BIT(port) | BIT(cpu_port); | 965 | vl->untag |= BIT(port); |
| 966 | else | 966 | else |
| 967 | vl->untag &= ~(BIT(port) | BIT(cpu_port)); | 967 | vl->untag &= ~BIT(port); |
| 968 | vl->untag &= ~BIT(cpu_port); | ||
| 968 | 969 | ||
| 969 | b53_set_vlan_entry(dev, vid, vl); | 970 | b53_set_vlan_entry(dev, vid, vl); |
| 970 | b53_fast_age_vlan(dev, vid); | 971 | b53_fast_age_vlan(dev, vid); |
| @@ -973,8 +974,6 @@ static void b53_vlan_add(struct dsa_switch *ds, int port, | |||
| 973 | if (pvid) { | 974 | if (pvid) { |
| 974 | b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), | 975 | b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), |
| 975 | vlan->vid_end); | 976 | vlan->vid_end); |
| 976 | b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(cpu_port), | ||
| 977 | vlan->vid_end); | ||
| 978 | b53_fast_age_vlan(dev, vid); | 977 | b53_fast_age_vlan(dev, vid); |
| 979 | } | 978 | } |
| 980 | } | 979 | } |
| @@ -984,7 +983,6 @@ static int b53_vlan_del(struct dsa_switch *ds, int port, | |||
| 984 | { | 983 | { |
| 985 | struct b53_device *dev = ds->priv; | 984 | struct b53_device *dev = ds->priv; |
| 986 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; | 985 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 987 | unsigned int cpu_port = dev->cpu_port; | ||
| 988 | struct b53_vlan *vl; | 986 | struct b53_vlan *vl; |
| 989 | u16 vid; | 987 | u16 vid; |
| 990 | u16 pvid; | 988 | u16 pvid; |
| @@ -997,8 +995,6 @@ static int b53_vlan_del(struct dsa_switch *ds, int port, | |||
| 997 | b53_get_vlan_entry(dev, vid, vl); | 995 | b53_get_vlan_entry(dev, vid, vl); |
| 998 | 996 | ||
| 999 | vl->members &= ~BIT(port); | 997 | vl->members &= ~BIT(port); |
| 1000 | if ((vl->members & BIT(cpu_port)) == BIT(cpu_port)) | ||
| 1001 | vl->members = 0; | ||
| 1002 | 998 | ||
| 1003 | if (pvid == vid) { | 999 | if (pvid == vid) { |
| 1004 | if (is5325(dev) || is5365(dev)) | 1000 | if (is5325(dev) || is5365(dev)) |
| @@ -1007,18 +1003,14 @@ static int b53_vlan_del(struct dsa_switch *ds, int port, | |||
| 1007 | pvid = 0; | 1003 | pvid = 0; |
| 1008 | } | 1004 | } |
| 1009 | 1005 | ||
| 1010 | if (untagged) { | 1006 | if (untagged) |
| 1011 | vl->untag &= ~(BIT(port)); | 1007 | vl->untag &= ~(BIT(port)); |
| 1012 | if ((vl->untag & BIT(cpu_port)) == BIT(cpu_port)) | ||
| 1013 | vl->untag = 0; | ||
| 1014 | } | ||
| 1015 | 1008 | ||
| 1016 | b53_set_vlan_entry(dev, vid, vl); | 1009 | b53_set_vlan_entry(dev, vid, vl); |
| 1017 | b53_fast_age_vlan(dev, vid); | 1010 | b53_fast_age_vlan(dev, vid); |
| 1018 | } | 1011 | } |
| 1019 | 1012 | ||
| 1020 | b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), pvid); | 1013 | b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(port), pvid); |
| 1021 | b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(cpu_port), pvid); | ||
| 1022 | b53_fast_age_vlan(dev, pvid); | 1014 | b53_fast_age_vlan(dev, pvid); |
| 1023 | 1015 | ||
| 1024 | return 0; | 1016 | return 0; |
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c index b0da9693f28a..be865b4dada2 100644 --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c | |||
| @@ -460,7 +460,7 @@ static void arc_emac_set_rx_mode(struct net_device *ndev) | |||
| 460 | if (ndev->flags & IFF_ALLMULTI) { | 460 | if (ndev->flags & IFF_ALLMULTI) { |
| 461 | arc_reg_set(priv, R_LAFL, ~0); | 461 | arc_reg_set(priv, R_LAFL, ~0); |
| 462 | arc_reg_set(priv, R_LAFH, ~0); | 462 | arc_reg_set(priv, R_LAFH, ~0); |
| 463 | } else { | 463 | } else if (ndev->flags & IFF_MULTICAST) { |
| 464 | struct netdev_hw_addr *ha; | 464 | struct netdev_hw_addr *ha; |
| 465 | unsigned int filter[2] = { 0, 0 }; | 465 | unsigned int filter[2] = { 0, 0 }; |
| 466 | int bit; | 466 | int bit; |
| @@ -472,6 +472,9 @@ static void arc_emac_set_rx_mode(struct net_device *ndev) | |||
| 472 | 472 | ||
| 473 | arc_reg_set(priv, R_LAFL, filter[0]); | 473 | arc_reg_set(priv, R_LAFL, filter[0]); |
| 474 | arc_reg_set(priv, R_LAFH, filter[1]); | 474 | arc_reg_set(priv, R_LAFH, filter[1]); |
| 475 | } else { | ||
| 476 | arc_reg_set(priv, R_LAFL, 0); | ||
| 477 | arc_reg_set(priv, R_LAFH, 0); | ||
| 475 | } | 478 | } |
| 476 | } | 479 | } |
| 477 | } | 480 | } |
| @@ -764,8 +767,6 @@ int arc_emac_probe(struct net_device *ndev, int interface) | |||
| 764 | ndev->netdev_ops = &arc_emac_netdev_ops; | 767 | ndev->netdev_ops = &arc_emac_netdev_ops; |
| 765 | ndev->ethtool_ops = &arc_emac_ethtool_ops; | 768 | ndev->ethtool_ops = &arc_emac_ethtool_ops; |
| 766 | ndev->watchdog_timeo = TX_TIMEOUT; | 769 | ndev->watchdog_timeo = TX_TIMEOUT; |
| 767 | /* FIXME :: no multicast support yet */ | ||
| 768 | ndev->flags &= ~IFF_MULTICAST; | ||
| 769 | 770 | ||
| 770 | priv = netdev_priv(ndev); | 771 | priv = netdev_priv(ndev); |
| 771 | priv->dev = dev; | 772 | priv->dev = dev; |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c6909660e097..e18635b2a002 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
| @@ -4934,6 +4934,10 @@ static void bnxt_del_napi(struct bnxt *bp) | |||
| 4934 | napi_hash_del(&bnapi->napi); | 4934 | napi_hash_del(&bnapi->napi); |
| 4935 | netif_napi_del(&bnapi->napi); | 4935 | netif_napi_del(&bnapi->napi); |
| 4936 | } | 4936 | } |
| 4937 | /* We called napi_hash_del() before netif_napi_del(), we need | ||
| 4938 | * to respect an RCU grace period before freeing napi structures. | ||
| 4939 | */ | ||
| 4940 | synchronize_net(); | ||
| 4937 | } | 4941 | } |
| 4938 | 4942 | ||
| 4939 | static void bnxt_init_napi(struct bnxt *bp) | 4943 | static void bnxt_init_napi(struct bnxt *bp) |
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index b32444a3ed79..533653bd7aec 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c | |||
| @@ -2673,6 +2673,12 @@ static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 2673 | lp->skb_length = skb->len; | 2673 | lp->skb_length = skb->len; |
| 2674 | lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, | 2674 | lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, |
| 2675 | DMA_TO_DEVICE); | 2675 | DMA_TO_DEVICE); |
| 2676 | if (dma_mapping_error(NULL, lp->skb_physaddr)) { | ||
| 2677 | dev_kfree_skb_any(skb); | ||
| 2678 | dev->stats.tx_dropped++; | ||
| 2679 | netdev_err(dev, "%s: DMA mapping error\n", __func__); | ||
| 2680 | return NETDEV_TX_OK; | ||
| 2681 | } | ||
| 2676 | 2682 | ||
| 2677 | /* Set address of the data in the Transmit Address register */ | 2683 | /* Set address of the data in the Transmit Address register */ |
| 2678 | macb_writel(lp, TAR, lp->skb_physaddr); | 2684 | macb_writel(lp, TAR, lp->skb_physaddr); |
diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h index 30426109711c..86bd93ce2ea3 100644 --- a/drivers/net/ethernet/cavium/thunder/nic.h +++ b/drivers/net/ethernet/cavium/thunder/nic.h | |||
| @@ -47,7 +47,7 @@ | |||
| 47 | 47 | ||
| 48 | /* Min/Max packet size */ | 48 | /* Min/Max packet size */ |
| 49 | #define NIC_HW_MIN_FRS 64 | 49 | #define NIC_HW_MIN_FRS 64 |
| 50 | #define NIC_HW_MAX_FRS 9200 /* 9216 max packet including FCS */ | 50 | #define NIC_HW_MAX_FRS 9190 /* Excluding L2 header and FCS */ |
| 51 | 51 | ||
| 52 | /* Max pkinds */ | 52 | /* Max pkinds */ |
| 53 | #define NIC_MAX_PKIND 16 | 53 | #define NIC_MAX_PKIND 16 |
| @@ -178,11 +178,11 @@ enum tx_stats_reg_offset { | |||
| 178 | 178 | ||
| 179 | struct nicvf_hw_stats { | 179 | struct nicvf_hw_stats { |
| 180 | u64 rx_bytes; | 180 | u64 rx_bytes; |
| 181 | u64 rx_frames; | ||
| 181 | u64 rx_ucast_frames; | 182 | u64 rx_ucast_frames; |
| 182 | u64 rx_bcast_frames; | 183 | u64 rx_bcast_frames; |
| 183 | u64 rx_mcast_frames; | 184 | u64 rx_mcast_frames; |
| 184 | u64 rx_fcs_errors; | 185 | u64 rx_drops; |
| 185 | u64 rx_l2_errors; | ||
| 186 | u64 rx_drop_red; | 186 | u64 rx_drop_red; |
| 187 | u64 rx_drop_red_bytes; | 187 | u64 rx_drop_red_bytes; |
| 188 | u64 rx_drop_overrun; | 188 | u64 rx_drop_overrun; |
| @@ -191,6 +191,19 @@ struct nicvf_hw_stats { | |||
| 191 | u64 rx_drop_mcast; | 191 | u64 rx_drop_mcast; |
| 192 | u64 rx_drop_l3_bcast; | 192 | u64 rx_drop_l3_bcast; |
| 193 | u64 rx_drop_l3_mcast; | 193 | u64 rx_drop_l3_mcast; |
| 194 | u64 rx_fcs_errors; | ||
| 195 | u64 rx_l2_errors; | ||
| 196 | |||
| 197 | u64 tx_bytes; | ||
| 198 | u64 tx_frames; | ||
| 199 | u64 tx_ucast_frames; | ||
| 200 | u64 tx_bcast_frames; | ||
| 201 | u64 tx_mcast_frames; | ||
| 202 | u64 tx_drops; | ||
| 203 | }; | ||
| 204 | |||
| 205 | struct nicvf_drv_stats { | ||
| 206 | /* CQE Rx errs */ | ||
| 194 | u64 rx_bgx_truncated_pkts; | 207 | u64 rx_bgx_truncated_pkts; |
| 195 | u64 rx_jabber_errs; | 208 | u64 rx_jabber_errs; |
| 196 | u64 rx_fcs_errs; | 209 | u64 rx_fcs_errs; |
| @@ -216,34 +229,30 @@ struct nicvf_hw_stats { | |||
| 216 | u64 rx_l4_pclp; | 229 | u64 rx_l4_pclp; |
| 217 | u64 rx_truncated_pkts; | 230 | u64 rx_truncated_pkts; |
| 218 | 231 | ||
| 219 | u64 tx_bytes_ok; | 232 | /* CQE Tx errs */ |
| 220 | u64 tx_ucast_frames_ok; | 233 | u64 tx_desc_fault; |
| 221 | u64 tx_bcast_frames_ok; | 234 | u64 tx_hdr_cons_err; |
| 222 | u64 tx_mcast_frames_ok; | 235 | u64 tx_subdesc_err; |
| 223 | u64 tx_drops; | 236 | u64 tx_max_size_exceeded; |
| 224 | }; | 237 | u64 tx_imm_size_oflow; |
| 225 | 238 | u64 tx_data_seq_err; | |
| 226 | struct nicvf_drv_stats { | 239 | u64 tx_mem_seq_err; |
| 227 | /* Rx */ | 240 | u64 tx_lock_viol; |
| 228 | u64 rx_frames_ok; | 241 | u64 tx_data_fault; |
| 229 | u64 rx_frames_64; | 242 | u64 tx_tstmp_conflict; |
| 230 | u64 rx_frames_127; | 243 | u64 tx_tstmp_timeout; |
| 231 | u64 rx_frames_255; | 244 | u64 tx_mem_fault; |
| 232 | u64 rx_frames_511; | 245 | u64 tx_csum_overlap; |
| 233 | u64 rx_frames_1023; | 246 | u64 tx_csum_overflow; |
| 234 | u64 rx_frames_1518; | 247 | |
| 235 | u64 rx_frames_jumbo; | 248 | /* driver debug stats */ |
| 236 | u64 rx_drops; | ||
| 237 | |||
| 238 | u64 rcv_buffer_alloc_failures; | 249 | u64 rcv_buffer_alloc_failures; |
| 239 | |||
| 240 | /* Tx */ | ||
| 241 | u64 tx_frames_ok; | ||
| 242 | u64 tx_drops; | ||
| 243 | u64 tx_tso; | 250 | u64 tx_tso; |
| 244 | u64 tx_timeout; | 251 | u64 tx_timeout; |
| 245 | u64 txq_stop; | 252 | u64 txq_stop; |
| 246 | u64 txq_wake; | 253 | u64 txq_wake; |
| 254 | |||
| 255 | struct u64_stats_sync syncp; | ||
| 247 | }; | 256 | }; |
| 248 | 257 | ||
| 249 | struct nicvf { | 258 | struct nicvf { |
| @@ -282,7 +291,6 @@ struct nicvf { | |||
| 282 | 291 | ||
| 283 | u8 node; | 292 | u8 node; |
| 284 | u8 cpi_alg; | 293 | u8 cpi_alg; |
| 285 | u16 mtu; | ||
| 286 | bool link_up; | 294 | bool link_up; |
| 287 | u8 duplex; | 295 | u8 duplex; |
| 288 | u32 speed; | 296 | u32 speed; |
| @@ -298,7 +306,7 @@ struct nicvf { | |||
| 298 | 306 | ||
| 299 | /* Stats */ | 307 | /* Stats */ |
| 300 | struct nicvf_hw_stats hw_stats; | 308 | struct nicvf_hw_stats hw_stats; |
| 301 | struct nicvf_drv_stats drv_stats; | 309 | struct nicvf_drv_stats __percpu *drv_stats; |
| 302 | struct bgx_stats bgx_stats; | 310 | struct bgx_stats bgx_stats; |
| 303 | 311 | ||
| 304 | /* MSI-X */ | 312 | /* MSI-X */ |
diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c index 2bbf4cbf08b2..6677b96e1f3f 100644 --- a/drivers/net/ethernet/cavium/thunder/nic_main.c +++ b/drivers/net/ethernet/cavium/thunder/nic_main.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/pci.h> | 11 | #include <linux/pci.h> |
| 12 | #include <linux/etherdevice.h> | 12 | #include <linux/etherdevice.h> |
| 13 | #include <linux/of.h> | 13 | #include <linux/of.h> |
| 14 | #include <linux/if_vlan.h> | ||
| 14 | 15 | ||
| 15 | #include "nic_reg.h" | 16 | #include "nic_reg.h" |
| 16 | #include "nic.h" | 17 | #include "nic.h" |
| @@ -260,18 +261,31 @@ static void nic_get_bgx_stats(struct nicpf *nic, struct bgx_stats_msg *bgx) | |||
| 260 | /* Update hardware min/max frame size */ | 261 | /* Update hardware min/max frame size */ |
| 261 | static int nic_update_hw_frs(struct nicpf *nic, int new_frs, int vf) | 262 | static int nic_update_hw_frs(struct nicpf *nic, int new_frs, int vf) |
| 262 | { | 263 | { |
| 263 | if ((new_frs > NIC_HW_MAX_FRS) || (new_frs < NIC_HW_MIN_FRS)) { | 264 | int bgx, lmac, lmac_cnt; |
| 264 | dev_err(&nic->pdev->dev, | 265 | u64 lmac_credits; |
| 265 | "Invalid MTU setting from VF%d rejected, should be between %d and %d\n", | 266 | |
| 266 | vf, NIC_HW_MIN_FRS, NIC_HW_MAX_FRS); | 267 | if ((new_frs > NIC_HW_MAX_FRS) || (new_frs < NIC_HW_MIN_FRS)) |
| 267 | return 1; | 268 | return 1; |
| 268 | } | ||
| 269 | new_frs += ETH_HLEN; | ||
| 270 | if (new_frs <= nic->pkind.maxlen) | ||
| 271 | return 0; | ||
| 272 | 269 | ||
| 273 | nic->pkind.maxlen = new_frs; | 270 | bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); |
| 274 | nic_reg_write(nic, NIC_PF_PKIND_0_15_CFG, *(u64 *)&nic->pkind); | 271 | lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]); |
| 272 | lmac += bgx * MAX_LMAC_PER_BGX; | ||
| 273 | |||
| 274 | new_frs += VLAN_ETH_HLEN + ETH_FCS_LEN + 4; | ||
| 275 | |||
| 276 | /* Update corresponding LMAC credits */ | ||
| 277 | lmac_cnt = bgx_get_lmac_count(nic->node, bgx); | ||
| 278 | lmac_credits = nic_reg_read(nic, NIC_PF_LMAC_0_7_CREDIT + (lmac * 8)); | ||
| 279 | lmac_credits &= ~(0xFFFFFULL << 12); | ||
| 280 | lmac_credits |= (((((48 * 1024) / lmac_cnt) - new_frs) / 16) << 12); | ||
| 281 | nic_reg_write(nic, NIC_PF_LMAC_0_7_CREDIT + (lmac * 8), lmac_credits); | ||
| 282 | |||
| 283 | /* Enforce MTU in HW | ||
| 284 | * This config is supported only from 88xx pass 2.0 onwards. | ||
| 285 | */ | ||
| 286 | if (!pass1_silicon(nic->pdev)) | ||
| 287 | nic_reg_write(nic, | ||
| 288 | NIC_PF_LMAC_0_7_CFG2 + (lmac * 8), new_frs); | ||
| 275 | return 0; | 289 | return 0; |
| 276 | } | 290 | } |
| 277 | 291 | ||
| @@ -464,7 +478,7 @@ static int nic_init_hw(struct nicpf *nic) | |||
| 464 | 478 | ||
| 465 | /* PKIND configuration */ | 479 | /* PKIND configuration */ |
| 466 | nic->pkind.minlen = 0; | 480 | nic->pkind.minlen = 0; |
| 467 | nic->pkind.maxlen = NIC_HW_MAX_FRS + ETH_HLEN; | 481 | nic->pkind.maxlen = NIC_HW_MAX_FRS + VLAN_ETH_HLEN + ETH_FCS_LEN + 4; |
| 468 | nic->pkind.lenerr_en = 1; | 482 | nic->pkind.lenerr_en = 1; |
| 469 | nic->pkind.rx_hdr = 0; | 483 | nic->pkind.rx_hdr = 0; |
| 470 | nic->pkind.hdr_sl = 0; | 484 | nic->pkind.hdr_sl = 0; |
| @@ -837,6 +851,7 @@ static int nic_reset_stat_counters(struct nicpf *nic, | |||
| 837 | nic_reg_write(nic, reg_addr, 0); | 851 | nic_reg_write(nic, reg_addr, 0); |
| 838 | } | 852 | } |
| 839 | } | 853 | } |
| 854 | |||
| 840 | return 0; | 855 | return 0; |
| 841 | } | 856 | } |
| 842 | 857 | ||
diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h index edf779f5a227..80d46337cf29 100644 --- a/drivers/net/ethernet/cavium/thunder/nic_reg.h +++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h | |||
| @@ -106,6 +106,7 @@ | |||
| 106 | #define NIC_PF_MPI_0_2047_CFG (0x210000) | 106 | #define NIC_PF_MPI_0_2047_CFG (0x210000) |
| 107 | #define NIC_PF_RSSI_0_4097_RQ (0x220000) | 107 | #define NIC_PF_RSSI_0_4097_RQ (0x220000) |
| 108 | #define NIC_PF_LMAC_0_7_CFG (0x240000) | 108 | #define NIC_PF_LMAC_0_7_CFG (0x240000) |
| 109 | #define NIC_PF_LMAC_0_7_CFG2 (0x240100) | ||
| 109 | #define NIC_PF_LMAC_0_7_SW_XOFF (0x242000) | 110 | #define NIC_PF_LMAC_0_7_SW_XOFF (0x242000) |
| 110 | #define NIC_PF_LMAC_0_7_CREDIT (0x244000) | 111 | #define NIC_PF_LMAC_0_7_CREDIT (0x244000) |
| 111 | #define NIC_PF_CHAN_0_255_TX_CFG (0x400000) | 112 | #define NIC_PF_CHAN_0_255_TX_CFG (0x400000) |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c index ad4fddb55421..432bf6be57cb 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c | |||
| @@ -36,11 +36,11 @@ struct nicvf_stat { | |||
| 36 | 36 | ||
| 37 | static const struct nicvf_stat nicvf_hw_stats[] = { | 37 | static const struct nicvf_stat nicvf_hw_stats[] = { |
| 38 | NICVF_HW_STAT(rx_bytes), | 38 | NICVF_HW_STAT(rx_bytes), |
| 39 | NICVF_HW_STAT(rx_frames), | ||
| 39 | NICVF_HW_STAT(rx_ucast_frames), | 40 | NICVF_HW_STAT(rx_ucast_frames), |
| 40 | NICVF_HW_STAT(rx_bcast_frames), | 41 | NICVF_HW_STAT(rx_bcast_frames), |
| 41 | NICVF_HW_STAT(rx_mcast_frames), | 42 | NICVF_HW_STAT(rx_mcast_frames), |
| 42 | NICVF_HW_STAT(rx_fcs_errors), | 43 | NICVF_HW_STAT(rx_drops), |
| 43 | NICVF_HW_STAT(rx_l2_errors), | ||
| 44 | NICVF_HW_STAT(rx_drop_red), | 44 | NICVF_HW_STAT(rx_drop_red), |
| 45 | NICVF_HW_STAT(rx_drop_red_bytes), | 45 | NICVF_HW_STAT(rx_drop_red_bytes), |
| 46 | NICVF_HW_STAT(rx_drop_overrun), | 46 | NICVF_HW_STAT(rx_drop_overrun), |
| @@ -49,50 +49,59 @@ static const struct nicvf_stat nicvf_hw_stats[] = { | |||
| 49 | NICVF_HW_STAT(rx_drop_mcast), | 49 | NICVF_HW_STAT(rx_drop_mcast), |
| 50 | NICVF_HW_STAT(rx_drop_l3_bcast), | 50 | NICVF_HW_STAT(rx_drop_l3_bcast), |
| 51 | NICVF_HW_STAT(rx_drop_l3_mcast), | 51 | NICVF_HW_STAT(rx_drop_l3_mcast), |
| 52 | NICVF_HW_STAT(rx_bgx_truncated_pkts), | 52 | NICVF_HW_STAT(rx_fcs_errors), |
| 53 | NICVF_HW_STAT(rx_jabber_errs), | 53 | NICVF_HW_STAT(rx_l2_errors), |
| 54 | NICVF_HW_STAT(rx_fcs_errs), | 54 | NICVF_HW_STAT(tx_bytes), |
| 55 | NICVF_HW_STAT(rx_bgx_errs), | 55 | NICVF_HW_STAT(tx_frames), |
| 56 | NICVF_HW_STAT(rx_prel2_errs), | 56 | NICVF_HW_STAT(tx_ucast_frames), |
| 57 | NICVF_HW_STAT(rx_l2_hdr_malformed), | 57 | NICVF_HW_STAT(tx_bcast_frames), |
| 58 | NICVF_HW_STAT(rx_oversize), | 58 | NICVF_HW_STAT(tx_mcast_frames), |
| 59 | NICVF_HW_STAT(rx_undersize), | 59 | NICVF_HW_STAT(tx_drops), |
| 60 | NICVF_HW_STAT(rx_l2_len_mismatch), | ||
| 61 | NICVF_HW_STAT(rx_l2_pclp), | ||
| 62 | NICVF_HW_STAT(rx_ip_ver_errs), | ||
| 63 | NICVF_HW_STAT(rx_ip_csum_errs), | ||
| 64 | NICVF_HW_STAT(rx_ip_hdr_malformed), | ||
| 65 | NICVF_HW_STAT(rx_ip_payload_malformed), | ||
| 66 | NICVF_HW_STAT(rx_ip_ttl_errs), | ||
| 67 | NICVF_HW_STAT(rx_l3_pclp), | ||
| 68 | NICVF_HW_STAT(rx_l4_malformed), | ||
| 69 | NICVF_HW_STAT(rx_l4_csum_errs), | ||
| 70 | NICVF_HW_STAT(rx_udp_len_errs), | ||
| 71 | NICVF_HW_STAT(rx_l4_port_errs), | ||
| 72 | NICVF_HW_STAT(rx_tcp_flag_errs), | ||
| 73 | NICVF_HW_STAT(rx_tcp_offset_errs), | ||
| 74 | NICVF_HW_STAT(rx_l4_pclp), | ||
| 75 | NICVF_HW_STAT(rx_truncated_pkts), | ||
| 76 | NICVF_HW_STAT(tx_bytes_ok), | ||
| 77 | NICVF_HW_STAT(tx_ucast_frames_ok), | ||
| 78 | NICVF_HW_STAT(tx_bcast_frames_ok), | ||
| 79 | NICVF_HW_STAT(tx_mcast_frames_ok), | ||
| 80 | }; | 60 | }; |
| 81 | 61 | ||
| 82 | static const struct nicvf_stat nicvf_drv_stats[] = { | 62 | static const struct nicvf_stat nicvf_drv_stats[] = { |
| 83 | NICVF_DRV_STAT(rx_frames_ok), | 63 | NICVF_DRV_STAT(rx_bgx_truncated_pkts), |
| 84 | NICVF_DRV_STAT(rx_frames_64), | 64 | NICVF_DRV_STAT(rx_jabber_errs), |
| 85 | NICVF_DRV_STAT(rx_frames_127), | 65 | NICVF_DRV_STAT(rx_fcs_errs), |
| 86 | NICVF_DRV_STAT(rx_frames_255), | 66 | NICVF_DRV_STAT(rx_bgx_errs), |
| 87 | NICVF_DRV_STAT(rx_frames_511), | 67 | NICVF_DRV_STAT(rx_prel2_errs), |
| 88 | NICVF_DRV_STAT(rx_frames_1023), | 68 | NICVF_DRV_STAT(rx_l2_hdr_malformed), |
| 89 | NICVF_DRV_STAT(rx_frames_1518), | 69 | NICVF_DRV_STAT(rx_oversize), |
| 90 | NICVF_DRV_STAT(rx_frames_jumbo), | 70 | NICVF_DRV_STAT(rx_undersize), |
| 91 | NICVF_DRV_STAT(rx_drops), | 71 | NICVF_DRV_STAT(rx_l2_len_mismatch), |
| 72 | NICVF_DRV_STAT(rx_l2_pclp), | ||
| 73 | NICVF_DRV_STAT(rx_ip_ver_errs), | ||
| 74 | NICVF_DRV_STAT(rx_ip_csum_errs), | ||
| 75 | NICVF_DRV_STAT(rx_ip_hdr_malformed), | ||
| 76 | NICVF_DRV_STAT(rx_ip_payload_malformed), | ||
| 77 | NICVF_DRV_STAT(rx_ip_ttl_errs), | ||
| 78 | NICVF_DRV_STAT(rx_l3_pclp), | ||
| 79 | NICVF_DRV_STAT(rx_l4_malformed), | ||
| 80 | NICVF_DRV_STAT(rx_l4_csum_errs), | ||
| 81 | NICVF_DRV_STAT(rx_udp_len_errs), | ||
| 82 | NICVF_DRV_STAT(rx_l4_port_errs), | ||
| 83 | NICVF_DRV_STAT(rx_tcp_flag_errs), | ||
| 84 | NICVF_DRV_STAT(rx_tcp_offset_errs), | ||
| 85 | NICVF_DRV_STAT(rx_l4_pclp), | ||
| 86 | NICVF_DRV_STAT(rx_truncated_pkts), | ||
| 87 | |||
| 88 | NICVF_DRV_STAT(tx_desc_fault), | ||
| 89 | NICVF_DRV_STAT(tx_hdr_cons_err), | ||
| 90 | NICVF_DRV_STAT(tx_subdesc_err), | ||
| 91 | NICVF_DRV_STAT(tx_max_size_exceeded), | ||
| 92 | NICVF_DRV_STAT(tx_imm_size_oflow), | ||
| 93 | NICVF_DRV_STAT(tx_data_seq_err), | ||
| 94 | NICVF_DRV_STAT(tx_mem_seq_err), | ||
| 95 | NICVF_DRV_STAT(tx_lock_viol), | ||
| 96 | NICVF_DRV_STAT(tx_data_fault), | ||
| 97 | NICVF_DRV_STAT(tx_tstmp_conflict), | ||
| 98 | NICVF_DRV_STAT(tx_tstmp_timeout), | ||
| 99 | NICVF_DRV_STAT(tx_mem_fault), | ||
| 100 | NICVF_DRV_STAT(tx_csum_overlap), | ||
| 101 | NICVF_DRV_STAT(tx_csum_overflow), | ||
| 102 | |||
| 92 | NICVF_DRV_STAT(rcv_buffer_alloc_failures), | 103 | NICVF_DRV_STAT(rcv_buffer_alloc_failures), |
| 93 | NICVF_DRV_STAT(tx_frames_ok), | ||
| 94 | NICVF_DRV_STAT(tx_tso), | 104 | NICVF_DRV_STAT(tx_tso), |
| 95 | NICVF_DRV_STAT(tx_drops), | ||
| 96 | NICVF_DRV_STAT(tx_timeout), | 105 | NICVF_DRV_STAT(tx_timeout), |
| 97 | NICVF_DRV_STAT(txq_stop), | 106 | NICVF_DRV_STAT(txq_stop), |
| 98 | NICVF_DRV_STAT(txq_wake), | 107 | NICVF_DRV_STAT(txq_wake), |
| @@ -278,8 +287,8 @@ static void nicvf_get_ethtool_stats(struct net_device *netdev, | |||
| 278 | struct ethtool_stats *stats, u64 *data) | 287 | struct ethtool_stats *stats, u64 *data) |
| 279 | { | 288 | { |
| 280 | struct nicvf *nic = netdev_priv(netdev); | 289 | struct nicvf *nic = netdev_priv(netdev); |
| 281 | int stat; | 290 | int stat, tmp_stats; |
| 282 | int sqs; | 291 | int sqs, cpu; |
| 283 | 292 | ||
| 284 | nicvf_update_stats(nic); | 293 | nicvf_update_stats(nic); |
| 285 | 294 | ||
| @@ -289,9 +298,13 @@ static void nicvf_get_ethtool_stats(struct net_device *netdev, | |||
| 289 | for (stat = 0; stat < nicvf_n_hw_stats; stat++) | 298 | for (stat = 0; stat < nicvf_n_hw_stats; stat++) |
| 290 | *(data++) = ((u64 *)&nic->hw_stats) | 299 | *(data++) = ((u64 *)&nic->hw_stats) |
| 291 | [nicvf_hw_stats[stat].index]; | 300 | [nicvf_hw_stats[stat].index]; |
| 292 | for (stat = 0; stat < nicvf_n_drv_stats; stat++) | 301 | for (stat = 0; stat < nicvf_n_drv_stats; stat++) { |
| 293 | *(data++) = ((u64 *)&nic->drv_stats) | 302 | tmp_stats = 0; |
| 294 | [nicvf_drv_stats[stat].index]; | 303 | for_each_possible_cpu(cpu) |
| 304 | tmp_stats += ((u64 *)per_cpu_ptr(nic->drv_stats, cpu)) | ||
| 305 | [nicvf_drv_stats[stat].index]; | ||
| 306 | *(data++) = tmp_stats; | ||
| 307 | } | ||
| 295 | 308 | ||
| 296 | nicvf_get_qset_stats(nic, stats, &data); | 309 | nicvf_get_qset_stats(nic, stats, &data); |
| 297 | 310 | ||
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c index 45a13f718863..8a37012c9c89 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c | |||
| @@ -69,25 +69,6 @@ static inline u8 nicvf_netdev_qidx(struct nicvf *nic, u8 qidx) | |||
| 69 | return qidx; | 69 | return qidx; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | static inline void nicvf_set_rx_frame_cnt(struct nicvf *nic, | ||
| 73 | struct sk_buff *skb) | ||
| 74 | { | ||
| 75 | if (skb->len <= 64) | ||
| 76 | nic->drv_stats.rx_frames_64++; | ||
| 77 | else if (skb->len <= 127) | ||
| 78 | nic->drv_stats.rx_frames_127++; | ||
| 79 | else if (skb->len <= 255) | ||
| 80 | nic->drv_stats.rx_frames_255++; | ||
| 81 | else if (skb->len <= 511) | ||
| 82 | nic->drv_stats.rx_frames_511++; | ||
| 83 | else if (skb->len <= 1023) | ||
| 84 | nic->drv_stats.rx_frames_1023++; | ||
| 85 | else if (skb->len <= 1518) | ||
| 86 | nic->drv_stats.rx_frames_1518++; | ||
| 87 | else | ||
| 88 | nic->drv_stats.rx_frames_jumbo++; | ||
| 89 | } | ||
| 90 | |||
| 91 | /* The Cavium ThunderX network controller can *only* be found in SoCs | 72 | /* The Cavium ThunderX network controller can *only* be found in SoCs |
| 92 | * containing the ThunderX ARM64 CPU implementation. All accesses to the device | 73 | * containing the ThunderX ARM64 CPU implementation. All accesses to the device |
| 93 | * registers on this platform are implicitly strongly ordered with respect | 74 | * registers on this platform are implicitly strongly ordered with respect |
| @@ -492,9 +473,6 @@ int nicvf_set_real_num_queues(struct net_device *netdev, | |||
| 492 | static int nicvf_init_resources(struct nicvf *nic) | 473 | static int nicvf_init_resources(struct nicvf *nic) |
| 493 | { | 474 | { |
| 494 | int err; | 475 | int err; |
| 495 | union nic_mbx mbx = {}; | ||
| 496 | |||
| 497 | mbx.msg.msg = NIC_MBOX_MSG_CFG_DONE; | ||
| 498 | 476 | ||
| 499 | /* Enable Qset */ | 477 | /* Enable Qset */ |
| 500 | nicvf_qset_config(nic, true); | 478 | nicvf_qset_config(nic, true); |
| @@ -507,14 +485,10 @@ static int nicvf_init_resources(struct nicvf *nic) | |||
| 507 | return err; | 485 | return err; |
| 508 | } | 486 | } |
| 509 | 487 | ||
| 510 | /* Send VF config done msg to PF */ | ||
| 511 | nicvf_write_to_mbx(nic, &mbx); | ||
| 512 | |||
| 513 | return 0; | 488 | return 0; |
| 514 | } | 489 | } |
| 515 | 490 | ||
| 516 | static void nicvf_snd_pkt_handler(struct net_device *netdev, | 491 | static void nicvf_snd_pkt_handler(struct net_device *netdev, |
| 517 | struct cmp_queue *cq, | ||
| 518 | struct cqe_send_t *cqe_tx, | 492 | struct cqe_send_t *cqe_tx, |
| 519 | int cqe_type, int budget, | 493 | int cqe_type, int budget, |
| 520 | unsigned int *tx_pkts, unsigned int *tx_bytes) | 494 | unsigned int *tx_pkts, unsigned int *tx_bytes) |
| @@ -536,7 +510,7 @@ static void nicvf_snd_pkt_handler(struct net_device *netdev, | |||
| 536 | __func__, cqe_tx->sq_qs, cqe_tx->sq_idx, | 510 | __func__, cqe_tx->sq_qs, cqe_tx->sq_idx, |
| 537 | cqe_tx->sqe_ptr, hdr->subdesc_cnt); | 511 | cqe_tx->sqe_ptr, hdr->subdesc_cnt); |
| 538 | 512 | ||
| 539 | nicvf_check_cqe_tx_errs(nic, cq, cqe_tx); | 513 | nicvf_check_cqe_tx_errs(nic, cqe_tx); |
| 540 | skb = (struct sk_buff *)sq->skbuff[cqe_tx->sqe_ptr]; | 514 | skb = (struct sk_buff *)sq->skbuff[cqe_tx->sqe_ptr]; |
| 541 | if (skb) { | 515 | if (skb) { |
| 542 | /* Check for dummy descriptor used for HW TSO offload on 88xx */ | 516 | /* Check for dummy descriptor used for HW TSO offload on 88xx */ |
| @@ -630,8 +604,6 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev, | |||
| 630 | return; | 604 | return; |
| 631 | } | 605 | } |
| 632 | 606 | ||
| 633 | nicvf_set_rx_frame_cnt(nic, skb); | ||
| 634 | |||
| 635 | nicvf_set_rxhash(netdev, cqe_rx, skb); | 607 | nicvf_set_rxhash(netdev, cqe_rx, skb); |
| 636 | 608 | ||
| 637 | skb_record_rx_queue(skb, rq_idx); | 609 | skb_record_rx_queue(skb, rq_idx); |
| @@ -703,7 +675,7 @@ loop: | |||
| 703 | work_done++; | 675 | work_done++; |
| 704 | break; | 676 | break; |
| 705 | case CQE_TYPE_SEND: | 677 | case CQE_TYPE_SEND: |
| 706 | nicvf_snd_pkt_handler(netdev, cq, | 678 | nicvf_snd_pkt_handler(netdev, |
| 707 | (void *)cq_desc, CQE_TYPE_SEND, | 679 | (void *)cq_desc, CQE_TYPE_SEND, |
| 708 | budget, &tx_pkts, &tx_bytes); | 680 | budget, &tx_pkts, &tx_bytes); |
| 709 | tx_done++; | 681 | tx_done++; |
| @@ -740,7 +712,7 @@ done: | |||
| 740 | nic = nic->pnicvf; | 712 | nic = nic->pnicvf; |
| 741 | if (netif_tx_queue_stopped(txq) && netif_carrier_ok(netdev)) { | 713 | if (netif_tx_queue_stopped(txq) && netif_carrier_ok(netdev)) { |
| 742 | netif_tx_start_queue(txq); | 714 | netif_tx_start_queue(txq); |
| 743 | nic->drv_stats.txq_wake++; | 715 | this_cpu_inc(nic->drv_stats->txq_wake); |
| 744 | if (netif_msg_tx_err(nic)) | 716 | if (netif_msg_tx_err(nic)) |
| 745 | netdev_warn(netdev, | 717 | netdev_warn(netdev, |
| 746 | "%s: Transmit queue wakeup SQ%d\n", | 718 | "%s: Transmit queue wakeup SQ%d\n", |
| @@ -1084,7 +1056,7 @@ static netdev_tx_t nicvf_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
| 1084 | 1056 | ||
| 1085 | if (!netif_tx_queue_stopped(txq) && !nicvf_sq_append_skb(nic, skb)) { | 1057 | if (!netif_tx_queue_stopped(txq) && !nicvf_sq_append_skb(nic, skb)) { |
| 1086 | netif_tx_stop_queue(txq); | 1058 | netif_tx_stop_queue(txq); |
| 1087 | nic->drv_stats.txq_stop++; | 1059 | this_cpu_inc(nic->drv_stats->txq_stop); |
| 1088 | if (netif_msg_tx_err(nic)) | 1060 | if (netif_msg_tx_err(nic)) |
| 1089 | netdev_warn(netdev, | 1061 | netdev_warn(netdev, |
| 1090 | "%s: Transmit ring full, stopping SQ%d\n", | 1062 | "%s: Transmit ring full, stopping SQ%d\n", |
| @@ -1189,14 +1161,24 @@ int nicvf_stop(struct net_device *netdev) | |||
| 1189 | return 0; | 1161 | return 0; |
| 1190 | } | 1162 | } |
| 1191 | 1163 | ||
| 1164 | static int nicvf_update_hw_max_frs(struct nicvf *nic, int mtu) | ||
| 1165 | { | ||
| 1166 | union nic_mbx mbx = {}; | ||
| 1167 | |||
| 1168 | mbx.frs.msg = NIC_MBOX_MSG_SET_MAX_FRS; | ||
| 1169 | mbx.frs.max_frs = mtu; | ||
| 1170 | mbx.frs.vf_id = nic->vf_id; | ||
| 1171 | |||
| 1172 | return nicvf_send_msg_to_pf(nic, &mbx); | ||
| 1173 | } | ||
| 1174 | |||
| 1192 | int nicvf_open(struct net_device *netdev) | 1175 | int nicvf_open(struct net_device *netdev) |
| 1193 | { | 1176 | { |
| 1194 | int err, qidx; | 1177 | int cpu, err, qidx; |
| 1195 | struct nicvf *nic = netdev_priv(netdev); | 1178 | struct nicvf *nic = netdev_priv(netdev); |
| 1196 | struct queue_set *qs = nic->qs; | 1179 | struct queue_set *qs = nic->qs; |
| 1197 | struct nicvf_cq_poll *cq_poll = NULL; | 1180 | struct nicvf_cq_poll *cq_poll = NULL; |
| 1198 | 1181 | union nic_mbx mbx = {}; | |
| 1199 | nic->mtu = netdev->mtu; | ||
| 1200 | 1182 | ||
| 1201 | netif_carrier_off(netdev); | 1183 | netif_carrier_off(netdev); |
| 1202 | 1184 | ||
| @@ -1248,9 +1230,17 @@ int nicvf_open(struct net_device *netdev) | |||
| 1248 | if (nic->sqs_mode) | 1230 | if (nic->sqs_mode) |
| 1249 | nicvf_get_primary_vf_struct(nic); | 1231 | nicvf_get_primary_vf_struct(nic); |
| 1250 | 1232 | ||
| 1251 | /* Configure receive side scaling */ | 1233 | /* Configure receive side scaling and MTU */ |
| 1252 | if (!nic->sqs_mode) | 1234 | if (!nic->sqs_mode) { |
| 1253 | nicvf_rss_init(nic); | 1235 | nicvf_rss_init(nic); |
| 1236 | if (nicvf_update_hw_max_frs(nic, netdev->mtu)) | ||
| 1237 | goto cleanup; | ||
| 1238 | |||
| 1239 | /* Clear percpu stats */ | ||
| 1240 | for_each_possible_cpu(cpu) | ||
| 1241 | memset(per_cpu_ptr(nic->drv_stats, cpu), 0, | ||
| 1242 | sizeof(struct nicvf_drv_stats)); | ||
| 1243 | } | ||
| 1254 | 1244 | ||
| 1255 | err = nicvf_register_interrupts(nic); | 1245 | err = nicvf_register_interrupts(nic); |
| 1256 | if (err) | 1246 | if (err) |
| @@ -1276,8 +1266,9 @@ int nicvf_open(struct net_device *netdev) | |||
| 1276 | for (qidx = 0; qidx < qs->rbdr_cnt; qidx++) | 1266 | for (qidx = 0; qidx < qs->rbdr_cnt; qidx++) |
| 1277 | nicvf_enable_intr(nic, NICVF_INTR_RBDR, qidx); | 1267 | nicvf_enable_intr(nic, NICVF_INTR_RBDR, qidx); |
| 1278 | 1268 | ||
| 1279 | nic->drv_stats.txq_stop = 0; | 1269 | /* Send VF config done msg to PF */ |
| 1280 | nic->drv_stats.txq_wake = 0; | 1270 | mbx.msg.msg = NIC_MBOX_MSG_CFG_DONE; |
| 1271 | nicvf_write_to_mbx(nic, &mbx); | ||
| 1281 | 1272 | ||
| 1282 | return 0; | 1273 | return 0; |
| 1283 | cleanup: | 1274 | cleanup: |
| @@ -1297,17 +1288,6 @@ napi_del: | |||
| 1297 | return err; | 1288 | return err; |
| 1298 | } | 1289 | } |
| 1299 | 1290 | ||
| 1300 | static int nicvf_update_hw_max_frs(struct nicvf *nic, int mtu) | ||
| 1301 | { | ||
| 1302 | union nic_mbx mbx = {}; | ||
| 1303 | |||
| 1304 | mbx.frs.msg = NIC_MBOX_MSG_SET_MAX_FRS; | ||
| 1305 | mbx.frs.max_frs = mtu; | ||
| 1306 | mbx.frs.vf_id = nic->vf_id; | ||
| 1307 | |||
| 1308 | return nicvf_send_msg_to_pf(nic, &mbx); | ||
| 1309 | } | ||
| 1310 | |||
| 1311 | static int nicvf_change_mtu(struct net_device *netdev, int new_mtu) | 1291 | static int nicvf_change_mtu(struct net_device *netdev, int new_mtu) |
| 1312 | { | 1292 | { |
| 1313 | struct nicvf *nic = netdev_priv(netdev); | 1293 | struct nicvf *nic = netdev_priv(netdev); |
| @@ -1318,10 +1298,13 @@ static int nicvf_change_mtu(struct net_device *netdev, int new_mtu) | |||
| 1318 | if (new_mtu < NIC_HW_MIN_FRS) | 1298 | if (new_mtu < NIC_HW_MIN_FRS) |
| 1319 | return -EINVAL; | 1299 | return -EINVAL; |
| 1320 | 1300 | ||
| 1301 | netdev->mtu = new_mtu; | ||
| 1302 | |||
| 1303 | if (!netif_running(netdev)) | ||
| 1304 | return 0; | ||
| 1305 | |||
| 1321 | if (nicvf_update_hw_max_frs(nic, new_mtu)) | 1306 | if (nicvf_update_hw_max_frs(nic, new_mtu)) |
| 1322 | return -EINVAL; | 1307 | return -EINVAL; |
| 1323 | netdev->mtu = new_mtu; | ||
| 1324 | nic->mtu = new_mtu; | ||
| 1325 | 1308 | ||
| 1326 | return 0; | 1309 | return 0; |
| 1327 | } | 1310 | } |
| @@ -1379,9 +1362,10 @@ void nicvf_update_lmac_stats(struct nicvf *nic) | |||
| 1379 | 1362 | ||
| 1380 | void nicvf_update_stats(struct nicvf *nic) | 1363 | void nicvf_update_stats(struct nicvf *nic) |
| 1381 | { | 1364 | { |
| 1382 | int qidx; | 1365 | int qidx, cpu; |
| 1366 | u64 tmp_stats = 0; | ||
| 1383 | struct nicvf_hw_stats *stats = &nic->hw_stats; | 1367 | struct nicvf_hw_stats *stats = &nic->hw_stats; |
| 1384 | struct nicvf_drv_stats *drv_stats = &nic->drv_stats; | 1368 | struct nicvf_drv_stats *drv_stats; |
| 1385 | struct queue_set *qs = nic->qs; | 1369 | struct queue_set *qs = nic->qs; |
| 1386 | 1370 | ||
| 1387 | #define GET_RX_STATS(reg) \ | 1371 | #define GET_RX_STATS(reg) \ |
| @@ -1404,21 +1388,33 @@ void nicvf_update_stats(struct nicvf *nic) | |||
| 1404 | stats->rx_drop_l3_bcast = GET_RX_STATS(RX_DRP_L3BCAST); | 1388 | stats->rx_drop_l3_bcast = GET_RX_STATS(RX_DRP_L3BCAST); |
| 1405 | stats->rx_drop_l3_mcast = GET_RX_STATS(RX_DRP_L3MCAST); | 1389 | stats->rx_drop_l3_mcast = GET_RX_STATS(RX_DRP_L3MCAST); |
| 1406 | 1390 | ||
| 1407 | stats->tx_bytes_ok = GET_TX_STATS(TX_OCTS); | 1391 | stats->tx_bytes = GET_TX_STATS(TX_OCTS); |
| 1408 | stats->tx_ucast_frames_ok = GET_TX_STATS(TX_UCAST); | 1392 | stats->tx_ucast_frames = GET_TX_STATS(TX_UCAST); |
| 1409 | stats->tx_bcast_frames_ok = GET_TX_STATS(TX_BCAST); | 1393 | stats->tx_bcast_frames = GET_TX_STATS(TX_BCAST); |
| 1410 | stats->tx_mcast_frames_ok = GET_TX_STATS(TX_MCAST); | 1394 | stats->tx_mcast_frames = GET_TX_STATS(TX_MCAST); |
| 1411 | stats->tx_drops = GET_TX_STATS(TX_DROP); | 1395 | stats->tx_drops = GET_TX_STATS(TX_DROP); |
| 1412 | 1396 | ||
| 1413 | drv_stats->tx_frames_ok = stats->tx_ucast_frames_ok + | 1397 | /* On T88 pass 2.0, the dummy SQE added for TSO notification |
| 1414 | stats->tx_bcast_frames_ok + | 1398 | * via CQE has 'dont_send' set. Hence HW drops the pkt pointed |
| 1415 | stats->tx_mcast_frames_ok; | 1399 | * pointed by dummy SQE and results in tx_drops counter being |
| 1416 | drv_stats->rx_frames_ok = stats->rx_ucast_frames + | 1400 | * incremented. Subtracting it from tx_tso counter will give |
| 1417 | stats->rx_bcast_frames + | 1401 | * exact tx_drops counter. |
| 1418 | stats->rx_mcast_frames; | 1402 | */ |
| 1419 | drv_stats->rx_drops = stats->rx_drop_red + | 1403 | if (nic->t88 && nic->hw_tso) { |
| 1420 | stats->rx_drop_overrun; | 1404 | for_each_possible_cpu(cpu) { |
| 1421 | drv_stats->tx_drops = stats->tx_drops; | 1405 | drv_stats = per_cpu_ptr(nic->drv_stats, cpu); |
| 1406 | tmp_stats += drv_stats->tx_tso; | ||
| 1407 | } | ||
| 1408 | stats->tx_drops = tmp_stats - stats->tx_drops; | ||
| 1409 | } | ||
| 1410 | stats->tx_frames = stats->tx_ucast_frames + | ||
| 1411 | stats->tx_bcast_frames + | ||
| 1412 | stats->tx_mcast_frames; | ||
| 1413 | stats->rx_frames = stats->rx_ucast_frames + | ||
| 1414 | stats->rx_bcast_frames + | ||
| 1415 | stats->rx_mcast_frames; | ||
| 1416 | stats->rx_drops = stats->rx_drop_red + | ||
| 1417 | stats->rx_drop_overrun; | ||
| 1422 | 1418 | ||
| 1423 | /* Update RQ and SQ stats */ | 1419 | /* Update RQ and SQ stats */ |
| 1424 | for (qidx = 0; qidx < qs->rq_cnt; qidx++) | 1420 | for (qidx = 0; qidx < qs->rq_cnt; qidx++) |
| @@ -1432,18 +1428,17 @@ static struct rtnl_link_stats64 *nicvf_get_stats64(struct net_device *netdev, | |||
| 1432 | { | 1428 | { |
| 1433 | struct nicvf *nic = netdev_priv(netdev); | 1429 | struct nicvf *nic = netdev_priv(netdev); |
| 1434 | struct nicvf_hw_stats *hw_stats = &nic->hw_stats; | 1430 | struct nicvf_hw_stats *hw_stats = &nic->hw_stats; |
| 1435 | struct nicvf_drv_stats *drv_stats = &nic->drv_stats; | ||
| 1436 | 1431 | ||
| 1437 | nicvf_update_stats(nic); | 1432 | nicvf_update_stats(nic); |
| 1438 | 1433 | ||
| 1439 | stats->rx_bytes = hw_stats->rx_bytes; | 1434 | stats->rx_bytes = hw_stats->rx_bytes; |
| 1440 | stats->rx_packets = drv_stats->rx_frames_ok; | 1435 | stats->rx_packets = hw_stats->rx_frames; |
| 1441 | stats->rx_dropped = drv_stats->rx_drops; | 1436 | stats->rx_dropped = hw_stats->rx_drops; |
| 1442 | stats->multicast = hw_stats->rx_mcast_frames; | 1437 | stats->multicast = hw_stats->rx_mcast_frames; |
| 1443 | 1438 | ||
| 1444 | stats->tx_bytes = hw_stats->tx_bytes_ok; | 1439 | stats->tx_bytes = hw_stats->tx_bytes; |
| 1445 | stats->tx_packets = drv_stats->tx_frames_ok; | 1440 | stats->tx_packets = hw_stats->tx_frames; |
| 1446 | stats->tx_dropped = drv_stats->tx_drops; | 1441 | stats->tx_dropped = hw_stats->tx_drops; |
| 1447 | 1442 | ||
| 1448 | return stats; | 1443 | return stats; |
| 1449 | } | 1444 | } |
| @@ -1456,7 +1451,7 @@ static void nicvf_tx_timeout(struct net_device *dev) | |||
| 1456 | netdev_warn(dev, "%s: Transmit timed out, resetting\n", | 1451 | netdev_warn(dev, "%s: Transmit timed out, resetting\n", |
| 1457 | dev->name); | 1452 | dev->name); |
| 1458 | 1453 | ||
| 1459 | nic->drv_stats.tx_timeout++; | 1454 | this_cpu_inc(nic->drv_stats->tx_timeout); |
| 1460 | schedule_work(&nic->reset_task); | 1455 | schedule_work(&nic->reset_task); |
| 1461 | } | 1456 | } |
| 1462 | 1457 | ||
| @@ -1590,6 +1585,12 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1590 | goto err_free_netdev; | 1585 | goto err_free_netdev; |
| 1591 | } | 1586 | } |
| 1592 | 1587 | ||
| 1588 | nic->drv_stats = netdev_alloc_pcpu_stats(struct nicvf_drv_stats); | ||
| 1589 | if (!nic->drv_stats) { | ||
| 1590 | err = -ENOMEM; | ||
| 1591 | goto err_free_netdev; | ||
| 1592 | } | ||
| 1593 | |||
| 1593 | err = nicvf_set_qset_resources(nic); | 1594 | err = nicvf_set_qset_resources(nic); |
| 1594 | if (err) | 1595 | if (err) |
| 1595 | goto err_free_netdev; | 1596 | goto err_free_netdev; |
| @@ -1648,6 +1649,8 @@ err_unregister_interrupts: | |||
| 1648 | nicvf_unregister_interrupts(nic); | 1649 | nicvf_unregister_interrupts(nic); |
| 1649 | err_free_netdev: | 1650 | err_free_netdev: |
| 1650 | pci_set_drvdata(pdev, NULL); | 1651 | pci_set_drvdata(pdev, NULL); |
| 1652 | if (nic->drv_stats) | ||
| 1653 | free_percpu(nic->drv_stats); | ||
| 1651 | free_netdev(netdev); | 1654 | free_netdev(netdev); |
| 1652 | err_release_regions: | 1655 | err_release_regions: |
| 1653 | pci_release_regions(pdev); | 1656 | pci_release_regions(pdev); |
| @@ -1675,6 +1678,8 @@ static void nicvf_remove(struct pci_dev *pdev) | |||
| 1675 | unregister_netdev(pnetdev); | 1678 | unregister_netdev(pnetdev); |
| 1676 | nicvf_unregister_interrupts(nic); | 1679 | nicvf_unregister_interrupts(nic); |
| 1677 | pci_set_drvdata(pdev, NULL); | 1680 | pci_set_drvdata(pdev, NULL); |
| 1681 | if (nic->drv_stats) | ||
| 1682 | free_percpu(nic->drv_stats); | ||
| 1678 | free_netdev(netdev); | 1683 | free_netdev(netdev); |
| 1679 | pci_release_regions(pdev); | 1684 | pci_release_regions(pdev); |
| 1680 | pci_disable_device(pdev); | 1685 | pci_disable_device(pdev); |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index a4fc50155881..747ef0882976 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c | |||
| @@ -104,7 +104,8 @@ static inline int nicvf_alloc_rcv_buffer(struct nicvf *nic, gfp_t gfp, | |||
| 104 | nic->rb_page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN, | 104 | nic->rb_page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN, |
| 105 | order); | 105 | order); |
| 106 | if (!nic->rb_page) { | 106 | if (!nic->rb_page) { |
| 107 | nic->drv_stats.rcv_buffer_alloc_failures++; | 107 | this_cpu_inc(nic->pnicvf->drv_stats-> |
| 108 | rcv_buffer_alloc_failures); | ||
| 108 | return -ENOMEM; | 109 | return -ENOMEM; |
| 109 | } | 110 | } |
| 110 | nic->rb_page_offset = 0; | 111 | nic->rb_page_offset = 0; |
| @@ -270,7 +271,8 @@ refill: | |||
| 270 | rbdr_idx, new_rb); | 271 | rbdr_idx, new_rb); |
| 271 | next_rbdr: | 272 | next_rbdr: |
| 272 | /* Re-enable RBDR interrupts only if buffer allocation is success */ | 273 | /* Re-enable RBDR interrupts only if buffer allocation is success */ |
| 273 | if (!nic->rb_alloc_fail && rbdr->enable) | 274 | if (!nic->rb_alloc_fail && rbdr->enable && |
| 275 | netif_running(nic->pnicvf->netdev)) | ||
| 274 | nicvf_enable_intr(nic, NICVF_INTR_RBDR, rbdr_idx); | 276 | nicvf_enable_intr(nic, NICVF_INTR_RBDR, rbdr_idx); |
| 275 | 277 | ||
| 276 | if (rbdr_idx) | 278 | if (rbdr_idx) |
| @@ -361,6 +363,8 @@ static int nicvf_init_snd_queue(struct nicvf *nic, | |||
| 361 | 363 | ||
| 362 | static void nicvf_free_snd_queue(struct nicvf *nic, struct snd_queue *sq) | 364 | static void nicvf_free_snd_queue(struct nicvf *nic, struct snd_queue *sq) |
| 363 | { | 365 | { |
| 366 | struct sk_buff *skb; | ||
| 367 | |||
| 364 | if (!sq) | 368 | if (!sq) |
| 365 | return; | 369 | return; |
| 366 | if (!sq->dmem.base) | 370 | if (!sq->dmem.base) |
| @@ -371,6 +375,15 @@ static void nicvf_free_snd_queue(struct nicvf *nic, struct snd_queue *sq) | |||
| 371 | sq->dmem.q_len * TSO_HEADER_SIZE, | 375 | sq->dmem.q_len * TSO_HEADER_SIZE, |
| 372 | sq->tso_hdrs, sq->tso_hdrs_phys); | 376 | sq->tso_hdrs, sq->tso_hdrs_phys); |
| 373 | 377 | ||
| 378 | /* Free pending skbs in the queue */ | ||
| 379 | smp_rmb(); | ||
| 380 | while (sq->head != sq->tail) { | ||
| 381 | skb = (struct sk_buff *)sq->skbuff[sq->head]; | ||
| 382 | if (skb) | ||
| 383 | dev_kfree_skb_any(skb); | ||
| 384 | sq->head++; | ||
| 385 | sq->head &= (sq->dmem.q_len - 1); | ||
| 386 | } | ||
| 374 | kfree(sq->skbuff); | 387 | kfree(sq->skbuff); |
| 375 | nicvf_free_q_desc_mem(nic, &sq->dmem); | 388 | nicvf_free_q_desc_mem(nic, &sq->dmem); |
| 376 | } | 389 | } |
| @@ -483,9 +496,12 @@ static void nicvf_reset_rcv_queue_stats(struct nicvf *nic) | |||
| 483 | { | 496 | { |
| 484 | union nic_mbx mbx = {}; | 497 | union nic_mbx mbx = {}; |
| 485 | 498 | ||
| 486 | /* Reset all RXQ's stats */ | 499 | /* Reset all RQ/SQ and VF stats */ |
| 487 | mbx.reset_stat.msg = NIC_MBOX_MSG_RESET_STAT_COUNTER; | 500 | mbx.reset_stat.msg = NIC_MBOX_MSG_RESET_STAT_COUNTER; |
| 501 | mbx.reset_stat.rx_stat_mask = 0x3FFF; | ||
| 502 | mbx.reset_stat.tx_stat_mask = 0x1F; | ||
| 488 | mbx.reset_stat.rq_stat_mask = 0xFFFF; | 503 | mbx.reset_stat.rq_stat_mask = 0xFFFF; |
| 504 | mbx.reset_stat.sq_stat_mask = 0xFFFF; | ||
| 489 | nicvf_send_msg_to_pf(nic, &mbx); | 505 | nicvf_send_msg_to_pf(nic, &mbx); |
| 490 | } | 506 | } |
| 491 | 507 | ||
| @@ -538,9 +554,12 @@ static void nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs, | |||
| 538 | mbx.rq.cfg = (1ULL << 62) | (RQ_CQ_DROP << 8); | 554 | mbx.rq.cfg = (1ULL << 62) | (RQ_CQ_DROP << 8); |
| 539 | nicvf_send_msg_to_pf(nic, &mbx); | 555 | nicvf_send_msg_to_pf(nic, &mbx); |
| 540 | 556 | ||
| 541 | nicvf_queue_reg_write(nic, NIC_QSET_RQ_GEN_CFG, 0, 0x00); | 557 | if (!nic->sqs_mode && (qidx == 0)) { |
| 542 | if (!nic->sqs_mode) | 558 | /* Enable checking L3/L4 length and TCP/UDP checksums */ |
| 559 | nicvf_queue_reg_write(nic, NIC_QSET_RQ_GEN_CFG, 0, | ||
| 560 | (BIT(24) | BIT(23) | BIT(21))); | ||
| 543 | nicvf_config_vlan_stripping(nic, nic->netdev->features); | 561 | nicvf_config_vlan_stripping(nic, nic->netdev->features); |
| 562 | } | ||
| 544 | 563 | ||
| 545 | /* Enable Receive queue */ | 564 | /* Enable Receive queue */ |
| 546 | memset(&rq_cfg, 0, sizeof(struct rq_cfg)); | 565 | memset(&rq_cfg, 0, sizeof(struct rq_cfg)); |
| @@ -1029,7 +1048,7 @@ nicvf_sq_add_hdr_subdesc(struct nicvf *nic, struct snd_queue *sq, int qentry, | |||
| 1029 | hdr->tso_max_paysize = skb_shinfo(skb)->gso_size; | 1048 | hdr->tso_max_paysize = skb_shinfo(skb)->gso_size; |
| 1030 | /* For non-tunneled pkts, point this to L2 ethertype */ | 1049 | /* For non-tunneled pkts, point this to L2 ethertype */ |
| 1031 | hdr->inner_l3_offset = skb_network_offset(skb) - 2; | 1050 | hdr->inner_l3_offset = skb_network_offset(skb) - 2; |
| 1032 | nic->drv_stats.tx_tso++; | 1051 | this_cpu_inc(nic->pnicvf->drv_stats->tx_tso); |
| 1033 | } | 1052 | } |
| 1034 | } | 1053 | } |
| 1035 | 1054 | ||
| @@ -1161,7 +1180,7 @@ static int nicvf_sq_append_tso(struct nicvf *nic, struct snd_queue *sq, | |||
| 1161 | 1180 | ||
| 1162 | nicvf_sq_doorbell(nic, skb, sq_num, desc_cnt); | 1181 | nicvf_sq_doorbell(nic, skb, sq_num, desc_cnt); |
| 1163 | 1182 | ||
| 1164 | nic->drv_stats.tx_tso++; | 1183 | this_cpu_inc(nic->pnicvf->drv_stats->tx_tso); |
| 1165 | return 1; | 1184 | return 1; |
| 1166 | } | 1185 | } |
| 1167 | 1186 | ||
| @@ -1422,8 +1441,6 @@ void nicvf_update_sq_stats(struct nicvf *nic, int sq_idx) | |||
| 1422 | /* Check for errors in the receive cmp.queue entry */ | 1441 | /* Check for errors in the receive cmp.queue entry */ |
| 1423 | int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx) | 1442 | int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx) |
| 1424 | { | 1443 | { |
| 1425 | struct nicvf_hw_stats *stats = &nic->hw_stats; | ||
| 1426 | |||
| 1427 | if (!cqe_rx->err_level && !cqe_rx->err_opcode) | 1444 | if (!cqe_rx->err_level && !cqe_rx->err_opcode) |
| 1428 | return 0; | 1445 | return 0; |
| 1429 | 1446 | ||
| @@ -1435,76 +1452,76 @@ int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx) | |||
| 1435 | 1452 | ||
| 1436 | switch (cqe_rx->err_opcode) { | 1453 | switch (cqe_rx->err_opcode) { |
| 1437 | case CQ_RX_ERROP_RE_PARTIAL: | 1454 | case CQ_RX_ERROP_RE_PARTIAL: |
| 1438 | stats->rx_bgx_truncated_pkts++; | 1455 | this_cpu_inc(nic->drv_stats->rx_bgx_truncated_pkts); |
| 1439 | break; | 1456 | break; |
| 1440 | case CQ_RX_ERROP_RE_JABBER: | 1457 | case CQ_RX_ERROP_RE_JABBER: |
| 1441 | stats->rx_jabber_errs++; | 1458 | this_cpu_inc(nic->drv_stats->rx_jabber_errs); |
| 1442 | break; | 1459 | break; |
| 1443 | case CQ_RX_ERROP_RE_FCS: | 1460 | case CQ_RX_ERROP_RE_FCS: |
| 1444 | stats->rx_fcs_errs++; | 1461 | this_cpu_inc(nic->drv_stats->rx_fcs_errs); |
| 1445 | break; | 1462 | break; |
| 1446 | case CQ_RX_ERROP_RE_RX_CTL: | 1463 | case CQ_RX_ERROP_RE_RX_CTL: |
| 1447 | stats->rx_bgx_errs++; | 1464 | this_cpu_inc(nic->drv_stats->rx_bgx_errs); |
| 1448 | break; | 1465 | break; |
| 1449 | case CQ_RX_ERROP_PREL2_ERR: | 1466 | case CQ_RX_ERROP_PREL2_ERR: |
| 1450 | stats->rx_prel2_errs++; | 1467 | this_cpu_inc(nic->drv_stats->rx_prel2_errs); |
| 1451 | break; | 1468 | break; |
| 1452 | case CQ_RX_ERROP_L2_MAL: | 1469 | case CQ_RX_ERROP_L2_MAL: |
| 1453 | stats->rx_l2_hdr_malformed++; | 1470 | this_cpu_inc(nic->drv_stats->rx_l2_hdr_malformed); |
| 1454 | break; | 1471 | break; |
| 1455 | case CQ_RX_ERROP_L2_OVERSIZE: | 1472 | case CQ_RX_ERROP_L2_OVERSIZE: |
| 1456 | stats->rx_oversize++; | 1473 | this_cpu_inc(nic->drv_stats->rx_oversize); |
| 1457 | break; | 1474 | break; |
| 1458 | case CQ_RX_ERROP_L2_UNDERSIZE: | 1475 | case CQ_RX_ERROP_L2_UNDERSIZE: |
| 1459 | stats->rx_undersize++; | 1476 | this_cpu_inc(nic->drv_stats->rx_undersize); |
| 1460 | break; | 1477 | break; |
| 1461 | case CQ_RX_ERROP_L2_LENMISM: | 1478 | case CQ_RX_ERROP_L2_LENMISM: |
| 1462 | stats->rx_l2_len_mismatch++; | 1479 | this_cpu_inc(nic->drv_stats->rx_l2_len_mismatch); |
| 1463 | break; | 1480 | break; |
| 1464 | case CQ_RX_ERROP_L2_PCLP: | 1481 | case CQ_RX_ERROP_L2_PCLP: |
| 1465 | stats->rx_l2_pclp++; | 1482 | this_cpu_inc(nic->drv_stats->rx_l2_pclp); |
| 1466 | break; | 1483 | break; |
| 1467 | case CQ_RX_ERROP_IP_NOT: | 1484 | case CQ_RX_ERROP_IP_NOT: |
| 1468 | stats->rx_ip_ver_errs++; | 1485 | this_cpu_inc(nic->drv_stats->rx_ip_ver_errs); |
| 1469 | break; | 1486 | break; |
| 1470 | case CQ_RX_ERROP_IP_CSUM_ERR: | 1487 | case CQ_RX_ERROP_IP_CSUM_ERR: |
| 1471 | stats->rx_ip_csum_errs++; | 1488 | this_cpu_inc(nic->drv_stats->rx_ip_csum_errs); |
| 1472 | break; | 1489 | break; |
| 1473 | case CQ_RX_ERROP_IP_MAL: | 1490 | case CQ_RX_ERROP_IP_MAL: |
| 1474 | stats->rx_ip_hdr_malformed++; | 1491 | this_cpu_inc(nic->drv_stats->rx_ip_hdr_malformed); |
| 1475 | break; | 1492 | break; |
| 1476 | case CQ_RX_ERROP_IP_MALD: | 1493 | case CQ_RX_ERROP_IP_MALD: |
| 1477 | stats->rx_ip_payload_malformed++; | 1494 | this_cpu_inc(nic->drv_stats->rx_ip_payload_malformed); |
| 1478 | break; | 1495 | break; |
| 1479 | case CQ_RX_ERROP_IP_HOP: | 1496 | case CQ_RX_ERROP_IP_HOP: |
| 1480 | stats->rx_ip_ttl_errs++; | 1497 | this_cpu_inc(nic->drv_stats->rx_ip_ttl_errs); |
| 1481 | break; | 1498 | break; |
| 1482 | case CQ_RX_ERROP_L3_PCLP: | 1499 | case CQ_RX_ERROP_L3_PCLP: |
| 1483 | stats->rx_l3_pclp++; | 1500 | this_cpu_inc(nic->drv_stats->rx_l3_pclp); |
| 1484 | break; | 1501 | break; |
| 1485 | case CQ_RX_ERROP_L4_MAL: | 1502 | case CQ_RX_ERROP_L4_MAL: |
| 1486 | stats->rx_l4_malformed++; | 1503 | this_cpu_inc(nic->drv_stats->rx_l4_malformed); |
| 1487 | break; | 1504 | break; |
| 1488 | case CQ_RX_ERROP_L4_CHK: | 1505 | case CQ_RX_ERROP_L4_CHK: |
| 1489 | stats->rx_l4_csum_errs++; | 1506 | this_cpu_inc(nic->drv_stats->rx_l4_csum_errs); |
| 1490 | break; | 1507 | break; |
| 1491 | case CQ_RX_ERROP_UDP_LEN: | 1508 | case CQ_RX_ERROP_UDP_LEN: |
| 1492 | stats->rx_udp_len_errs++; | 1509 | this_cpu_inc(nic->drv_stats->rx_udp_len_errs); |
| 1493 | break; | 1510 | break; |
| 1494 | case CQ_RX_ERROP_L4_PORT: | 1511 | case CQ_RX_ERROP_L4_PORT: |
| 1495 | stats->rx_l4_port_errs++; | 1512 | this_cpu_inc(nic->drv_stats->rx_l4_port_errs); |
| 1496 | break; | 1513 | break; |
| 1497 | case CQ_RX_ERROP_TCP_FLAG: | 1514 | case CQ_RX_ERROP_TCP_FLAG: |
| 1498 | stats->rx_tcp_flag_errs++; | 1515 | this_cpu_inc(nic->drv_stats->rx_tcp_flag_errs); |
| 1499 | break; | 1516 | break; |
| 1500 | case CQ_RX_ERROP_TCP_OFFSET: | 1517 | case CQ_RX_ERROP_TCP_OFFSET: |
| 1501 | stats->rx_tcp_offset_errs++; | 1518 | this_cpu_inc(nic->drv_stats->rx_tcp_offset_errs); |
| 1502 | break; | 1519 | break; |
| 1503 | case CQ_RX_ERROP_L4_PCLP: | 1520 | case CQ_RX_ERROP_L4_PCLP: |
| 1504 | stats->rx_l4_pclp++; | 1521 | this_cpu_inc(nic->drv_stats->rx_l4_pclp); |
| 1505 | break; | 1522 | break; |
| 1506 | case CQ_RX_ERROP_RBDR_TRUNC: | 1523 | case CQ_RX_ERROP_RBDR_TRUNC: |
| 1507 | stats->rx_truncated_pkts++; | 1524 | this_cpu_inc(nic->drv_stats->rx_truncated_pkts); |
| 1508 | break; | 1525 | break; |
| 1509 | } | 1526 | } |
| 1510 | 1527 | ||
| @@ -1512,53 +1529,52 @@ int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx) | |||
| 1512 | } | 1529 | } |
| 1513 | 1530 | ||
| 1514 | /* Check for errors in the send cmp.queue entry */ | 1531 | /* Check for errors in the send cmp.queue entry */ |
| 1515 | int nicvf_check_cqe_tx_errs(struct nicvf *nic, | 1532 | int nicvf_check_cqe_tx_errs(struct nicvf *nic, struct cqe_send_t *cqe_tx) |
| 1516 | struct cmp_queue *cq, struct cqe_send_t *cqe_tx) | ||
| 1517 | { | 1533 | { |
| 1518 | struct cmp_queue_stats *stats = &cq->stats; | ||
| 1519 | |||
| 1520 | switch (cqe_tx->send_status) { | 1534 | switch (cqe_tx->send_status) { |
| 1521 | case CQ_TX_ERROP_GOOD: | 1535 | case CQ_TX_ERROP_GOOD: |
| 1522 | stats->tx.good++; | ||
| 1523 | return 0; | 1536 | return 0; |
| 1524 | case CQ_TX_ERROP_DESC_FAULT: | 1537 | case CQ_TX_ERROP_DESC_FAULT: |
| 1525 | stats->tx.desc_fault++; | 1538 | this_cpu_inc(nic->drv_stats->tx_desc_fault); |
| 1526 | break; | 1539 | break; |
| 1527 | case CQ_TX_ERROP_HDR_CONS_ERR: | 1540 | case CQ_TX_ERROP_HDR_CONS_ERR: |
| 1528 | stats->tx.hdr_cons_err++; | 1541 | this_cpu_inc(nic->drv_stats->tx_hdr_cons_err); |
| 1529 | break; | 1542 | break; |
| 1530 | case CQ_TX_ERROP_SUBDC_ERR: | 1543 | case CQ_TX_ERROP_SUBDC_ERR: |
| 1531 | stats->tx.subdesc_err++; | 1544 | this_cpu_inc(nic->drv_stats->tx_subdesc_err); |
| 1545 | break; | ||
| 1546 | case CQ_TX_ERROP_MAX_SIZE_VIOL: | ||
| 1547 | this_cpu_inc(nic->drv_stats->tx_max_size_exceeded); | ||
| 1532 | break; | 1548 | break; |
| 1533 | case CQ_TX_ERROP_IMM_SIZE_OFLOW: | 1549 | case CQ_TX_ERROP_IMM_SIZE_OFLOW: |
| 1534 | stats->tx.imm_size_oflow++; | 1550 | this_cpu_inc(nic->drv_stats->tx_imm_size_oflow); |
| 1535 | break; | 1551 | break; |
| 1536 | case CQ_TX_ERROP_DATA_SEQUENCE_ERR: | 1552 | case CQ_TX_ERROP_DATA_SEQUENCE_ERR: |
| 1537 | stats->tx.data_seq_err++; | 1553 | this_cpu_inc(nic->drv_stats->tx_data_seq_err); |
| 1538 | break; | 1554 | break; |
| 1539 | case CQ_TX_ERROP_MEM_SEQUENCE_ERR: | 1555 | case CQ_TX_ERROP_MEM_SEQUENCE_ERR: |
| 1540 | stats->tx.mem_seq_err++; | 1556 | this_cpu_inc(nic->drv_stats->tx_mem_seq_err); |
| 1541 | break; | 1557 | break; |
| 1542 | case CQ_TX_ERROP_LOCK_VIOL: | 1558 | case CQ_TX_ERROP_LOCK_VIOL: |
| 1543 | stats->tx.lock_viol++; | 1559 | this_cpu_inc(nic->drv_stats->tx_lock_viol); |
| 1544 | break; | 1560 | break; |
| 1545 | case CQ_TX_ERROP_DATA_FAULT: | 1561 | case CQ_TX_ERROP_DATA_FAULT: |
| 1546 | stats->tx.data_fault++; | 1562 | this_cpu_inc(nic->drv_stats->tx_data_fault); |
| 1547 | break; | 1563 | break; |
| 1548 | case CQ_TX_ERROP_TSTMP_CONFLICT: | 1564 | case CQ_TX_ERROP_TSTMP_CONFLICT: |
| 1549 | stats->tx.tstmp_conflict++; | 1565 | this_cpu_inc(nic->drv_stats->tx_tstmp_conflict); |
| 1550 | break; | 1566 | break; |
| 1551 | case CQ_TX_ERROP_TSTMP_TIMEOUT: | 1567 | case CQ_TX_ERROP_TSTMP_TIMEOUT: |
| 1552 | stats->tx.tstmp_timeout++; | 1568 | this_cpu_inc(nic->drv_stats->tx_tstmp_timeout); |
| 1553 | break; | 1569 | break; |
| 1554 | case CQ_TX_ERROP_MEM_FAULT: | 1570 | case CQ_TX_ERROP_MEM_FAULT: |
| 1555 | stats->tx.mem_fault++; | 1571 | this_cpu_inc(nic->drv_stats->tx_mem_fault); |
| 1556 | break; | 1572 | break; |
| 1557 | case CQ_TX_ERROP_CK_OVERLAP: | 1573 | case CQ_TX_ERROP_CK_OVERLAP: |
| 1558 | stats->tx.csum_overlap++; | 1574 | this_cpu_inc(nic->drv_stats->tx_csum_overlap); |
| 1559 | break; | 1575 | break; |
| 1560 | case CQ_TX_ERROP_CK_OFLOW: | 1576 | case CQ_TX_ERROP_CK_OFLOW: |
| 1561 | stats->tx.csum_overflow++; | 1577 | this_cpu_inc(nic->drv_stats->tx_csum_overflow); |
| 1562 | break; | 1578 | break; |
| 1563 | } | 1579 | } |
| 1564 | 1580 | ||
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h index 869f3386028b..2e3c940c1093 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h | |||
| @@ -158,6 +158,7 @@ enum CQ_TX_ERROP_E { | |||
| 158 | CQ_TX_ERROP_DESC_FAULT = 0x10, | 158 | CQ_TX_ERROP_DESC_FAULT = 0x10, |
| 159 | CQ_TX_ERROP_HDR_CONS_ERR = 0x11, | 159 | CQ_TX_ERROP_HDR_CONS_ERR = 0x11, |
| 160 | CQ_TX_ERROP_SUBDC_ERR = 0x12, | 160 | CQ_TX_ERROP_SUBDC_ERR = 0x12, |
| 161 | CQ_TX_ERROP_MAX_SIZE_VIOL = 0x13, | ||
| 161 | CQ_TX_ERROP_IMM_SIZE_OFLOW = 0x80, | 162 | CQ_TX_ERROP_IMM_SIZE_OFLOW = 0x80, |
| 162 | CQ_TX_ERROP_DATA_SEQUENCE_ERR = 0x81, | 163 | CQ_TX_ERROP_DATA_SEQUENCE_ERR = 0x81, |
| 163 | CQ_TX_ERROP_MEM_SEQUENCE_ERR = 0x82, | 164 | CQ_TX_ERROP_MEM_SEQUENCE_ERR = 0x82, |
| @@ -171,25 +172,6 @@ enum CQ_TX_ERROP_E { | |||
| 171 | CQ_TX_ERROP_ENUM_LAST = 0x8a, | 172 | CQ_TX_ERROP_ENUM_LAST = 0x8a, |
| 172 | }; | 173 | }; |
| 173 | 174 | ||
| 174 | struct cmp_queue_stats { | ||
| 175 | struct tx_stats { | ||
| 176 | u64 good; | ||
| 177 | u64 desc_fault; | ||
| 178 | u64 hdr_cons_err; | ||
| 179 | u64 subdesc_err; | ||
| 180 | u64 imm_size_oflow; | ||
| 181 | u64 data_seq_err; | ||
| 182 | u64 mem_seq_err; | ||
| 183 | u64 lock_viol; | ||
| 184 | u64 data_fault; | ||
| 185 | u64 tstmp_conflict; | ||
| 186 | u64 tstmp_timeout; | ||
| 187 | u64 mem_fault; | ||
| 188 | u64 csum_overlap; | ||
| 189 | u64 csum_overflow; | ||
| 190 | } tx; | ||
| 191 | } ____cacheline_aligned_in_smp; | ||
| 192 | |||
| 193 | enum RQ_SQ_STATS { | 175 | enum RQ_SQ_STATS { |
| 194 | RQ_SQ_STATS_OCTS, | 176 | RQ_SQ_STATS_OCTS, |
| 195 | RQ_SQ_STATS_PKTS, | 177 | RQ_SQ_STATS_PKTS, |
| @@ -241,7 +223,6 @@ struct cmp_queue { | |||
| 241 | spinlock_t lock; /* lock to serialize processing CQEs */ | 223 | spinlock_t lock; /* lock to serialize processing CQEs */ |
| 242 | void *desc; | 224 | void *desc; |
| 243 | struct q_desc_mem dmem; | 225 | struct q_desc_mem dmem; |
| 244 | struct cmp_queue_stats stats; | ||
| 245 | int irq; | 226 | int irq; |
| 246 | } ____cacheline_aligned_in_smp; | 227 | } ____cacheline_aligned_in_smp; |
| 247 | 228 | ||
| @@ -336,6 +317,5 @@ u64 nicvf_queue_reg_read(struct nicvf *nic, | |||
| 336 | void nicvf_update_rq_stats(struct nicvf *nic, int rq_idx); | 317 | void nicvf_update_rq_stats(struct nicvf *nic, int rq_idx); |
| 337 | void nicvf_update_sq_stats(struct nicvf *nic, int sq_idx); | 318 | void nicvf_update_sq_stats(struct nicvf *nic, int sq_idx); |
| 338 | int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx); | 319 | int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx); |
| 339 | int nicvf_check_cqe_tx_errs(struct nicvf *nic, | 320 | int nicvf_check_cqe_tx_errs(struct nicvf *nic, struct cqe_send_t *cqe_tx); |
| 340 | struct cmp_queue *cq, struct cqe_send_t *cqe_tx); | ||
| 341 | #endif /* NICVF_QUEUES_H */ | 321 | #endif /* NICVF_QUEUES_H */ |
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index 8bbaedbb7b94..050e21fbb147 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c | |||
| @@ -1242,8 +1242,8 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 1242 | 1242 | ||
| 1243 | pci_read_config_word(pdev, PCI_DEVICE_ID, &sdevid); | 1243 | pci_read_config_word(pdev, PCI_DEVICE_ID, &sdevid); |
| 1244 | if (sdevid != PCI_DEVICE_ID_THUNDER_RGX) { | 1244 | if (sdevid != PCI_DEVICE_ID_THUNDER_RGX) { |
| 1245 | bgx->bgx_id = | 1245 | bgx->bgx_id = (pci_resource_start(pdev, |
| 1246 | (pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM) >> 24) & 1; | 1246 | PCI_CFG_REG_BAR_NUM) >> 24) & BGX_ID_MASK; |
| 1247 | bgx->bgx_id += nic_get_node_id(pdev) * MAX_BGX_PER_NODE; | 1247 | bgx->bgx_id += nic_get_node_id(pdev) * MAX_BGX_PER_NODE; |
| 1248 | bgx->max_lmac = MAX_LMAC_PER_BGX; | 1248 | bgx->max_lmac = MAX_LMAC_PER_BGX; |
| 1249 | bgx_vnic[bgx->bgx_id] = bgx; | 1249 | bgx_vnic[bgx->bgx_id] = bgx; |
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h index d59c71e4a000..01cc7c859131 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #define MAX_DMAC_PER_LMAC 8 | 28 | #define MAX_DMAC_PER_LMAC 8 |
| 29 | #define MAX_FRAME_SIZE 9216 | 29 | #define MAX_FRAME_SIZE 9216 |
| 30 | 30 | ||
| 31 | #define BGX_ID_MASK 0x3 | ||
| 32 | |||
| 31 | #define MAX_DMAC_PER_LMAC_TNS_BYPASS_MODE 2 | 33 | #define MAX_DMAC_PER_LMAC_TNS_BYPASS_MODE 2 |
| 32 | 34 | ||
| 33 | /* Registers */ | 35 | /* Registers */ |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 1e74fd6085df..e19a0ca8e5dd 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
| @@ -2951,7 +2951,6 @@ void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, | |||
| 2951 | rq->cntxt_id, fl_id, 0xffff); | 2951 | rq->cntxt_id, fl_id, 0xffff); |
| 2952 | dma_free_coherent(adap->pdev_dev, (rq->size + 1) * rq->iqe_len, | 2952 | dma_free_coherent(adap->pdev_dev, (rq->size + 1) * rq->iqe_len, |
| 2953 | rq->desc, rq->phys_addr); | 2953 | rq->desc, rq->phys_addr); |
| 2954 | napi_hash_del(&rq->napi); | ||
| 2955 | netif_napi_del(&rq->napi); | 2954 | netif_napi_del(&rq->napi); |
| 2956 | rq->netdev = NULL; | 2955 | rq->netdev = NULL; |
| 2957 | rq->cntxt_id = rq->abs_id = 0; | 2956 | rq->cntxt_id = rq->abs_id = 0; |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index cece8a08edca..93aa2939142a 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
| @@ -2813,7 +2813,6 @@ static void be_evt_queues_destroy(struct be_adapter *adapter) | |||
| 2813 | if (eqo->q.created) { | 2813 | if (eqo->q.created) { |
| 2814 | be_eq_clean(eqo); | 2814 | be_eq_clean(eqo); |
| 2815 | be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); | 2815 | be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); |
| 2816 | napi_hash_del(&eqo->napi); | ||
| 2817 | netif_napi_del(&eqo->napi); | 2816 | netif_napi_del(&eqo->napi); |
| 2818 | free_cpumask_var(eqo->affinity_mask); | 2817 | free_cpumask_var(eqo->affinity_mask); |
| 2819 | } | 2818 | } |
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c index f05ea56dcff2..941c8e2c944e 100644 --- a/drivers/net/ethernet/marvell/sky2.c +++ b/drivers/net/ethernet/marvell/sky2.c | |||
| @@ -5220,6 +5220,19 @@ static SIMPLE_DEV_PM_OPS(sky2_pm_ops, sky2_suspend, sky2_resume); | |||
| 5220 | 5220 | ||
| 5221 | static void sky2_shutdown(struct pci_dev *pdev) | 5221 | static void sky2_shutdown(struct pci_dev *pdev) |
| 5222 | { | 5222 | { |
| 5223 | struct sky2_hw *hw = pci_get_drvdata(pdev); | ||
| 5224 | int port; | ||
| 5225 | |||
| 5226 | for (port = 0; port < hw->ports; port++) { | ||
| 5227 | struct net_device *ndev = hw->dev[port]; | ||
| 5228 | |||
| 5229 | rtnl_lock(); | ||
| 5230 | if (netif_running(ndev)) { | ||
| 5231 | dev_close(ndev); | ||
| 5232 | netif_device_detach(ndev); | ||
| 5233 | } | ||
| 5234 | rtnl_unlock(); | ||
| 5235 | } | ||
| 5223 | sky2_suspend(&pdev->dev); | 5236 | sky2_suspend(&pdev->dev); |
| 5224 | pci_wake_from_d3(pdev, device_may_wakeup(&pdev->dev)); | 5237 | pci_wake_from_d3(pdev, device_may_wakeup(&pdev->dev)); |
| 5225 | pci_set_power_state(pdev, PCI_D3hot); | 5238 | pci_set_power_state(pdev, PCI_D3hot); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 3818c5e06eba..4b78168a5f3c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig | |||
| @@ -107,7 +107,7 @@ config DWMAC_STI | |||
| 107 | config DWMAC_STM32 | 107 | config DWMAC_STM32 |
| 108 | tristate "STM32 DWMAC support" | 108 | tristate "STM32 DWMAC support" |
| 109 | default ARCH_STM32 | 109 | default ARCH_STM32 |
| 110 | depends on OF && HAS_IOMEM | 110 | depends on OF && HAS_IOMEM && (ARCH_STM32 || COMPILE_TEST) |
| 111 | select MFD_SYSCON | 111 | select MFD_SYSCON |
| 112 | ---help--- | 112 | ---help--- |
| 113 | Support for ethernet controller on STM32 SOCs. | 113 | Support for ethernet controller on STM32 SOCs. |
diff --git a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c index 2920e2ee3864..489ef146201e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c | |||
| @@ -63,8 +63,8 @@ | |||
| 63 | #define TSE_PCS_SGMII_LINK_TIMER_0 0x0D40 | 63 | #define TSE_PCS_SGMII_LINK_TIMER_0 0x0D40 |
| 64 | #define TSE_PCS_SGMII_LINK_TIMER_1 0x0003 | 64 | #define TSE_PCS_SGMII_LINK_TIMER_1 0x0003 |
| 65 | #define TSE_PCS_SW_RESET_TIMEOUT 100 | 65 | #define TSE_PCS_SW_RESET_TIMEOUT 100 |
| 66 | #define TSE_PCS_USE_SGMII_AN_MASK BIT(2) | 66 | #define TSE_PCS_USE_SGMII_AN_MASK BIT(1) |
| 67 | #define TSE_PCS_USE_SGMII_ENA BIT(1) | 67 | #define TSE_PCS_USE_SGMII_ENA BIT(0) |
| 68 | 68 | ||
| 69 | #define SGMII_ADAPTER_CTRL_REG 0x00 | 69 | #define SGMII_ADAPTER_CTRL_REG 0x00 |
| 70 | #define SGMII_ADAPTER_DISABLE 0x0001 | 70 | #define SGMII_ADAPTER_DISABLE 0x0001 |
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index d3292c4a6eda..6d2de4e01f6d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h | |||
| @@ -120,14 +120,17 @@ struct stmmac_extra_stats { | |||
| 120 | unsigned long ip_csum_bypassed; | 120 | unsigned long ip_csum_bypassed; |
| 121 | unsigned long ipv4_pkt_rcvd; | 121 | unsigned long ipv4_pkt_rcvd; |
| 122 | unsigned long ipv6_pkt_rcvd; | 122 | unsigned long ipv6_pkt_rcvd; |
| 123 | unsigned long rx_msg_type_ext_no_ptp; | 123 | unsigned long no_ptp_rx_msg_type_ext; |
| 124 | unsigned long rx_msg_type_sync; | 124 | unsigned long ptp_rx_msg_type_sync; |
| 125 | unsigned long rx_msg_type_follow_up; | 125 | unsigned long ptp_rx_msg_type_follow_up; |
| 126 | unsigned long rx_msg_type_delay_req; | 126 | unsigned long ptp_rx_msg_type_delay_req; |
| 127 | unsigned long rx_msg_type_delay_resp; | 127 | unsigned long ptp_rx_msg_type_delay_resp; |
| 128 | unsigned long rx_msg_type_pdelay_req; | 128 | unsigned long ptp_rx_msg_type_pdelay_req; |
| 129 | unsigned long rx_msg_type_pdelay_resp; | 129 | unsigned long ptp_rx_msg_type_pdelay_resp; |
| 130 | unsigned long rx_msg_type_pdelay_follow_up; | 130 | unsigned long ptp_rx_msg_type_pdelay_follow_up; |
| 131 | unsigned long ptp_rx_msg_type_announce; | ||
| 132 | unsigned long ptp_rx_msg_type_management; | ||
| 133 | unsigned long ptp_rx_msg_pkt_reserved_type; | ||
| 131 | unsigned long ptp_frame_type; | 134 | unsigned long ptp_frame_type; |
| 132 | unsigned long ptp_ver; | 135 | unsigned long ptp_ver; |
| 133 | unsigned long timestamp_dropped; | 136 | unsigned long timestamp_dropped; |
| @@ -482,11 +485,12 @@ struct stmmac_ops { | |||
| 482 | /* PTP and HW Timer helpers */ | 485 | /* PTP and HW Timer helpers */ |
| 483 | struct stmmac_hwtimestamp { | 486 | struct stmmac_hwtimestamp { |
| 484 | void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); | 487 | void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); |
| 485 | u32 (*config_sub_second_increment) (void __iomem *ioaddr, u32 clk_rate); | 488 | u32 (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock, |
| 489 | int gmac4); | ||
| 486 | int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); | 490 | int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); |
| 487 | int (*config_addend) (void __iomem *ioaddr, u32 addend); | 491 | int (*config_addend) (void __iomem *ioaddr, u32 addend); |
| 488 | int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec, | 492 | int (*adjust_systime) (void __iomem *ioaddr, u32 sec, u32 nsec, |
| 489 | int add_sub); | 493 | int add_sub, int gmac4); |
| 490 | u64(*get_systime) (void __iomem *ioaddr); | 494 | u64(*get_systime) (void __iomem *ioaddr); |
| 491 | }; | 495 | }; |
| 492 | 496 | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/descs.h b/drivers/net/ethernet/stmicro/stmmac/descs.h index 2e4c171a2b41..e3c86d422109 100644 --- a/drivers/net/ethernet/stmicro/stmmac/descs.h +++ b/drivers/net/ethernet/stmicro/stmmac/descs.h | |||
| @@ -155,14 +155,18 @@ | |||
| 155 | #define ERDES4_L3_L4_FILT_NO_MATCH_MASK GENMASK(27, 26) | 155 | #define ERDES4_L3_L4_FILT_NO_MATCH_MASK GENMASK(27, 26) |
| 156 | 156 | ||
| 157 | /* Extended RDES4 message type definitions */ | 157 | /* Extended RDES4 message type definitions */ |
| 158 | #define RDES_EXT_NO_PTP 0 | 158 | #define RDES_EXT_NO_PTP 0x0 |
| 159 | #define RDES_EXT_SYNC 1 | 159 | #define RDES_EXT_SYNC 0x1 |
| 160 | #define RDES_EXT_FOLLOW_UP 2 | 160 | #define RDES_EXT_FOLLOW_UP 0x2 |
| 161 | #define RDES_EXT_DELAY_REQ 3 | 161 | #define RDES_EXT_DELAY_REQ 0x3 |
| 162 | #define RDES_EXT_DELAY_RESP 4 | 162 | #define RDES_EXT_DELAY_RESP 0x4 |
| 163 | #define RDES_EXT_PDELAY_REQ 5 | 163 | #define RDES_EXT_PDELAY_REQ 0x5 |
| 164 | #define RDES_EXT_PDELAY_RESP 6 | 164 | #define RDES_EXT_PDELAY_RESP 0x6 |
| 165 | #define RDES_EXT_PDELAY_FOLLOW_UP 7 | 165 | #define RDES_EXT_PDELAY_FOLLOW_UP 0x7 |
| 166 | #define RDES_PTP_ANNOUNCE 0x8 | ||
| 167 | #define RDES_PTP_MANAGEMENT 0x9 | ||
| 168 | #define RDES_PTP_SIGNALING 0xa | ||
| 169 | #define RDES_PTP_PKT_RESERVED_TYPE 0xf | ||
| 166 | 170 | ||
| 167 | /* Basic descriptor structure for normal and alternate descriptors */ | 171 | /* Basic descriptor structure for normal and alternate descriptors */ |
| 168 | struct dma_desc { | 172 | struct dma_desc { |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index a1b17cd7886b..a601f8d43b75 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | |||
| @@ -123,22 +123,29 @@ static int dwmac4_wrback_get_rx_status(void *data, struct stmmac_extra_stats *x, | |||
| 123 | x->ipv4_pkt_rcvd++; | 123 | x->ipv4_pkt_rcvd++; |
| 124 | if (rdes1 & RDES1_IPV6_HEADER) | 124 | if (rdes1 & RDES1_IPV6_HEADER) |
| 125 | x->ipv6_pkt_rcvd++; | 125 | x->ipv6_pkt_rcvd++; |
| 126 | if (message_type == RDES_EXT_SYNC) | 126 | |
| 127 | x->rx_msg_type_sync++; | 127 | if (message_type == RDES_EXT_NO_PTP) |
| 128 | x->no_ptp_rx_msg_type_ext++; | ||
| 129 | else if (message_type == RDES_EXT_SYNC) | ||
| 130 | x->ptp_rx_msg_type_sync++; | ||
| 128 | else if (message_type == RDES_EXT_FOLLOW_UP) | 131 | else if (message_type == RDES_EXT_FOLLOW_UP) |
| 129 | x->rx_msg_type_follow_up++; | 132 | x->ptp_rx_msg_type_follow_up++; |
| 130 | else if (message_type == RDES_EXT_DELAY_REQ) | 133 | else if (message_type == RDES_EXT_DELAY_REQ) |
| 131 | x->rx_msg_type_delay_req++; | 134 | x->ptp_rx_msg_type_delay_req++; |
| 132 | else if (message_type == RDES_EXT_DELAY_RESP) | 135 | else if (message_type == RDES_EXT_DELAY_RESP) |
| 133 | x->rx_msg_type_delay_resp++; | 136 | x->ptp_rx_msg_type_delay_resp++; |
| 134 | else if (message_type == RDES_EXT_PDELAY_REQ) | 137 | else if (message_type == RDES_EXT_PDELAY_REQ) |
| 135 | x->rx_msg_type_pdelay_req++; | 138 | x->ptp_rx_msg_type_pdelay_req++; |
| 136 | else if (message_type == RDES_EXT_PDELAY_RESP) | 139 | else if (message_type == RDES_EXT_PDELAY_RESP) |
| 137 | x->rx_msg_type_pdelay_resp++; | 140 | x->ptp_rx_msg_type_pdelay_resp++; |
| 138 | else if (message_type == RDES_EXT_PDELAY_FOLLOW_UP) | 141 | else if (message_type == RDES_EXT_PDELAY_FOLLOW_UP) |
| 139 | x->rx_msg_type_pdelay_follow_up++; | 142 | x->ptp_rx_msg_type_pdelay_follow_up++; |
| 140 | else | 143 | else if (message_type == RDES_PTP_ANNOUNCE) |
| 141 | x->rx_msg_type_ext_no_ptp++; | 144 | x->ptp_rx_msg_type_announce++; |
| 145 | else if (message_type == RDES_PTP_MANAGEMENT) | ||
| 146 | x->ptp_rx_msg_type_management++; | ||
| 147 | else if (message_type == RDES_PTP_PKT_RESERVED_TYPE) | ||
| 148 | x->ptp_rx_msg_pkt_reserved_type++; | ||
| 142 | 149 | ||
| 143 | if (rdes1 & RDES1_PTP_PACKET_TYPE) | 150 | if (rdes1 & RDES1_PTP_PACKET_TYPE) |
| 144 | x->ptp_frame_type++; | 151 | x->ptp_frame_type++; |
| @@ -204,14 +211,18 @@ static void dwmac4_rd_enable_tx_timestamp(struct dma_desc *p) | |||
| 204 | 211 | ||
| 205 | static int dwmac4_wrback_get_tx_timestamp_status(struct dma_desc *p) | 212 | static int dwmac4_wrback_get_tx_timestamp_status(struct dma_desc *p) |
| 206 | { | 213 | { |
| 207 | return (p->des3 & TDES3_TIMESTAMP_STATUS) | 214 | /* Context type from W/B descriptor must be zero */ |
| 208 | >> TDES3_TIMESTAMP_STATUS_SHIFT; | 215 | if (p->des3 & TDES3_CONTEXT_TYPE) |
| 216 | return -EINVAL; | ||
| 217 | |||
| 218 | /* Tx Timestamp Status is 1 so des0 and des1'll have valid values */ | ||
| 219 | if (p->des3 & TDES3_TIMESTAMP_STATUS) | ||
| 220 | return 0; | ||
| 221 | |||
| 222 | return 1; | ||
| 209 | } | 223 | } |
| 210 | 224 | ||
| 211 | /* NOTE: For RX CTX bit has to be checked before | 225 | static inline u64 dwmac4_get_timestamp(void *desc, u32 ats) |
| 212 | * HAVE a specific function for TX and another one for RX | ||
| 213 | */ | ||
| 214 | static u64 dwmac4_wrback_get_timestamp(void *desc, u32 ats) | ||
| 215 | { | 226 | { |
| 216 | struct dma_desc *p = (struct dma_desc *)desc; | 227 | struct dma_desc *p = (struct dma_desc *)desc; |
| 217 | u64 ns; | 228 | u64 ns; |
| @@ -223,12 +234,54 @@ static u64 dwmac4_wrback_get_timestamp(void *desc, u32 ats) | |||
| 223 | return ns; | 234 | return ns; |
| 224 | } | 235 | } |
| 225 | 236 | ||
| 226 | static int dwmac4_context_get_rx_timestamp_status(void *desc, u32 ats) | 237 | static int dwmac4_rx_check_timestamp(void *desc) |
| 238 | { | ||
| 239 | struct dma_desc *p = (struct dma_desc *)desc; | ||
| 240 | u32 own, ctxt; | ||
| 241 | int ret = 1; | ||
| 242 | |||
| 243 | own = p->des3 & RDES3_OWN; | ||
| 244 | ctxt = ((p->des3 & RDES3_CONTEXT_DESCRIPTOR) | ||
| 245 | >> RDES3_CONTEXT_DESCRIPTOR_SHIFT); | ||
| 246 | |||
| 247 | if (likely(!own && ctxt)) { | ||
| 248 | if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff)) | ||
| 249 | /* Corrupted value */ | ||
| 250 | ret = -EINVAL; | ||
| 251 | else | ||
| 252 | /* A valid Timestamp is ready to be read */ | ||
| 253 | ret = 0; | ||
| 254 | } | ||
| 255 | |||
| 256 | /* Timestamp not ready */ | ||
| 257 | return ret; | ||
| 258 | } | ||
| 259 | |||
| 260 | static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats) | ||
| 227 | { | 261 | { |
| 228 | struct dma_desc *p = (struct dma_desc *)desc; | 262 | struct dma_desc *p = (struct dma_desc *)desc; |
| 263 | int ret = -EINVAL; | ||
| 264 | |||
| 265 | /* Get the status from normal w/b descriptor */ | ||
| 266 | if (likely(p->des3 & TDES3_RS1V)) { | ||
| 267 | if (likely(p->des1 & RDES1_TIMESTAMP_AVAILABLE)) { | ||
| 268 | int i = 0; | ||
| 269 | |||
| 270 | /* Check if timestamp is OK from context descriptor */ | ||
| 271 | do { | ||
| 272 | ret = dwmac4_rx_check_timestamp(desc); | ||
| 273 | if (ret < 0) | ||
| 274 | goto exit; | ||
| 275 | i++; | ||
| 229 | 276 | ||
| 230 | return (p->des1 & RDES1_TIMESTAMP_AVAILABLE) | 277 | } while ((ret == 1) || (i < 10)); |
| 231 | >> RDES1_TIMESTAMP_AVAILABLE_SHIFT; | 278 | |
| 279 | if (i == 10) | ||
| 280 | ret = -EBUSY; | ||
| 281 | } | ||
| 282 | } | ||
| 283 | exit: | ||
| 284 | return ret; | ||
| 232 | } | 285 | } |
| 233 | 286 | ||
| 234 | static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic, | 287 | static void dwmac4_rd_init_rx_desc(struct dma_desc *p, int disable_rx_ic, |
| @@ -373,8 +426,8 @@ const struct stmmac_desc_ops dwmac4_desc_ops = { | |||
| 373 | .get_rx_frame_len = dwmac4_wrback_get_rx_frame_len, | 426 | .get_rx_frame_len = dwmac4_wrback_get_rx_frame_len, |
| 374 | .enable_tx_timestamp = dwmac4_rd_enable_tx_timestamp, | 427 | .enable_tx_timestamp = dwmac4_rd_enable_tx_timestamp, |
| 375 | .get_tx_timestamp_status = dwmac4_wrback_get_tx_timestamp_status, | 428 | .get_tx_timestamp_status = dwmac4_wrback_get_tx_timestamp_status, |
| 376 | .get_timestamp = dwmac4_wrback_get_timestamp, | 429 | .get_rx_timestamp_status = dwmac4_wrback_get_rx_timestamp_status, |
| 377 | .get_rx_timestamp_status = dwmac4_context_get_rx_timestamp_status, | 430 | .get_timestamp = dwmac4_get_timestamp, |
| 378 | .set_tx_ic = dwmac4_rd_set_tx_ic, | 431 | .set_tx_ic = dwmac4_rd_set_tx_ic, |
| 379 | .prepare_tx_desc = dwmac4_rd_prepare_tx_desc, | 432 | .prepare_tx_desc = dwmac4_rd_prepare_tx_desc, |
| 380 | .prepare_tso_tx_desc = dwmac4_rd_prepare_tso_tx_desc, | 433 | .prepare_tso_tx_desc = dwmac4_rd_prepare_tso_tx_desc, |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h index 0902a2edeaa9..9736c505211a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.h | |||
| @@ -59,10 +59,13 @@ | |||
| 59 | #define TDES3_CTXT_TCMSSV BIT(26) | 59 | #define TDES3_CTXT_TCMSSV BIT(26) |
| 60 | 60 | ||
| 61 | /* TDES3 Common */ | 61 | /* TDES3 Common */ |
| 62 | #define TDES3_RS1V BIT(26) | ||
| 63 | #define TDES3_RS1V_SHIFT 26 | ||
| 62 | #define TDES3_LAST_DESCRIPTOR BIT(28) | 64 | #define TDES3_LAST_DESCRIPTOR BIT(28) |
| 63 | #define TDES3_LAST_DESCRIPTOR_SHIFT 28 | 65 | #define TDES3_LAST_DESCRIPTOR_SHIFT 28 |
| 64 | #define TDES3_FIRST_DESCRIPTOR BIT(29) | 66 | #define TDES3_FIRST_DESCRIPTOR BIT(29) |
| 65 | #define TDES3_CONTEXT_TYPE BIT(30) | 67 | #define TDES3_CONTEXT_TYPE BIT(30) |
| 68 | #define TDES3_CONTEXT_TYPE_SHIFT 30 | ||
| 66 | 69 | ||
| 67 | /* TDS3 use for both format (read and write back) */ | 70 | /* TDS3 use for both format (read and write back) */ |
| 68 | #define TDES3_OWN BIT(31) | 71 | #define TDES3_OWN BIT(31) |
| @@ -117,6 +120,7 @@ | |||
| 117 | #define RDES3_LAST_DESCRIPTOR BIT(28) | 120 | #define RDES3_LAST_DESCRIPTOR BIT(28) |
| 118 | #define RDES3_FIRST_DESCRIPTOR BIT(29) | 121 | #define RDES3_FIRST_DESCRIPTOR BIT(29) |
| 119 | #define RDES3_CONTEXT_DESCRIPTOR BIT(30) | 122 | #define RDES3_CONTEXT_DESCRIPTOR BIT(30) |
| 123 | #define RDES3_CONTEXT_DESCRIPTOR_SHIFT 30 | ||
| 120 | 124 | ||
| 121 | /* RDES3 (read format) */ | 125 | /* RDES3 (read format) */ |
| 122 | #define RDES3_BUFFER1_VALID_ADDR BIT(24) | 126 | #define RDES3_BUFFER1_VALID_ADDR BIT(24) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index 38f19c99cf59..e75549327c34 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c | |||
| @@ -150,22 +150,30 @@ static void enh_desc_get_ext_status(void *data, struct stmmac_extra_stats *x, | |||
| 150 | x->ipv4_pkt_rcvd++; | 150 | x->ipv4_pkt_rcvd++; |
| 151 | if (rdes4 & ERDES4_IPV6_PKT_RCVD) | 151 | if (rdes4 & ERDES4_IPV6_PKT_RCVD) |
| 152 | x->ipv6_pkt_rcvd++; | 152 | x->ipv6_pkt_rcvd++; |
| 153 | if (message_type == RDES_EXT_SYNC) | 153 | |
| 154 | x->rx_msg_type_sync++; | 154 | if (message_type == RDES_EXT_NO_PTP) |
| 155 | x->no_ptp_rx_msg_type_ext++; | ||
| 156 | else if (message_type == RDES_EXT_SYNC) | ||
| 157 | x->ptp_rx_msg_type_sync++; | ||
| 155 | else if (message_type == RDES_EXT_FOLLOW_UP) | 158 | else if (message_type == RDES_EXT_FOLLOW_UP) |
| 156 | x->rx_msg_type_follow_up++; | 159 | x->ptp_rx_msg_type_follow_up++; |
| 157 | else if (message_type == RDES_EXT_DELAY_REQ) | 160 | else if (message_type == RDES_EXT_DELAY_REQ) |
| 158 | x->rx_msg_type_delay_req++; | 161 | x->ptp_rx_msg_type_delay_req++; |
| 159 | else if (message_type == RDES_EXT_DELAY_RESP) | 162 | else if (message_type == RDES_EXT_DELAY_RESP) |
| 160 | x->rx_msg_type_delay_resp++; | 163 | x->ptp_rx_msg_type_delay_resp++; |
| 161 | else if (message_type == RDES_EXT_PDELAY_REQ) | 164 | else if (message_type == RDES_EXT_PDELAY_REQ) |
| 162 | x->rx_msg_type_pdelay_req++; | 165 | x->ptp_rx_msg_type_pdelay_req++; |
| 163 | else if (message_type == RDES_EXT_PDELAY_RESP) | 166 | else if (message_type == RDES_EXT_PDELAY_RESP) |
| 164 | x->rx_msg_type_pdelay_resp++; | 167 | x->ptp_rx_msg_type_pdelay_resp++; |
| 165 | else if (message_type == RDES_EXT_PDELAY_FOLLOW_UP) | 168 | else if (message_type == RDES_EXT_PDELAY_FOLLOW_UP) |
| 166 | x->rx_msg_type_pdelay_follow_up++; | 169 | x->ptp_rx_msg_type_pdelay_follow_up++; |
| 167 | else | 170 | else if (message_type == RDES_PTP_ANNOUNCE) |
| 168 | x->rx_msg_type_ext_no_ptp++; | 171 | x->ptp_rx_msg_type_announce++; |
| 172 | else if (message_type == RDES_PTP_MANAGEMENT) | ||
| 173 | x->ptp_rx_msg_type_management++; | ||
| 174 | else if (message_type == RDES_PTP_PKT_RESERVED_TYPE) | ||
| 175 | x->ptp_rx_msg_pkt_reserved_type++; | ||
| 176 | |||
| 169 | if (rdes4 & ERDES4_PTP_FRAME_TYPE) | 177 | if (rdes4 & ERDES4_PTP_FRAME_TYPE) |
| 170 | x->ptp_frame_type++; | 178 | x->ptp_frame_type++; |
| 171 | if (rdes4 & ERDES4_PTP_VER) | 179 | if (rdes4 & ERDES4_PTP_VER) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b15fc55f1b96..4d2a759b8465 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h | |||
| @@ -129,6 +129,7 @@ struct stmmac_priv { | |||
| 129 | int irq_wake; | 129 | int irq_wake; |
| 130 | spinlock_t ptp_lock; | 130 | spinlock_t ptp_lock; |
| 131 | void __iomem *mmcaddr; | 131 | void __iomem *mmcaddr; |
| 132 | void __iomem *ptpaddr; | ||
| 132 | u32 rx_tail_addr; | 133 | u32 rx_tail_addr; |
| 133 | u32 tx_tail_addr; | 134 | u32 tx_tail_addr; |
| 134 | u32 mss; | 135 | u32 mss; |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 1e06173fc9d7..c5d0142adda2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | |||
| @@ -115,14 +115,17 @@ static const struct stmmac_stats stmmac_gstrings_stats[] = { | |||
| 115 | STMMAC_STAT(ip_csum_bypassed), | 115 | STMMAC_STAT(ip_csum_bypassed), |
| 116 | STMMAC_STAT(ipv4_pkt_rcvd), | 116 | STMMAC_STAT(ipv4_pkt_rcvd), |
| 117 | STMMAC_STAT(ipv6_pkt_rcvd), | 117 | STMMAC_STAT(ipv6_pkt_rcvd), |
| 118 | STMMAC_STAT(rx_msg_type_ext_no_ptp), | 118 | STMMAC_STAT(no_ptp_rx_msg_type_ext), |
| 119 | STMMAC_STAT(rx_msg_type_sync), | 119 | STMMAC_STAT(ptp_rx_msg_type_sync), |
| 120 | STMMAC_STAT(rx_msg_type_follow_up), | 120 | STMMAC_STAT(ptp_rx_msg_type_follow_up), |
| 121 | STMMAC_STAT(rx_msg_type_delay_req), | 121 | STMMAC_STAT(ptp_rx_msg_type_delay_req), |
| 122 | STMMAC_STAT(rx_msg_type_delay_resp), | 122 | STMMAC_STAT(ptp_rx_msg_type_delay_resp), |
| 123 | STMMAC_STAT(rx_msg_type_pdelay_req), | 123 | STMMAC_STAT(ptp_rx_msg_type_pdelay_req), |
| 124 | STMMAC_STAT(rx_msg_type_pdelay_resp), | 124 | STMMAC_STAT(ptp_rx_msg_type_pdelay_resp), |
| 125 | STMMAC_STAT(rx_msg_type_pdelay_follow_up), | 125 | STMMAC_STAT(ptp_rx_msg_type_pdelay_follow_up), |
| 126 | STMMAC_STAT(ptp_rx_msg_type_announce), | ||
| 127 | STMMAC_STAT(ptp_rx_msg_type_management), | ||
| 128 | STMMAC_STAT(ptp_rx_msg_pkt_reserved_type), | ||
| 126 | STMMAC_STAT(ptp_frame_type), | 129 | STMMAC_STAT(ptp_frame_type), |
| 127 | STMMAC_STAT(ptp_ver), | 130 | STMMAC_STAT(ptp_ver), |
| 128 | STMMAC_STAT(timestamp_dropped), | 131 | STMMAC_STAT(timestamp_dropped), |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index a77f68918010..10d6059b2f26 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | |||
| @@ -34,21 +34,29 @@ static void stmmac_config_hw_tstamping(void __iomem *ioaddr, u32 data) | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr, | 36 | static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr, |
| 37 | u32 ptp_clock) | 37 | u32 ptp_clock, int gmac4) |
| 38 | { | 38 | { |
| 39 | u32 value = readl(ioaddr + PTP_TCR); | 39 | u32 value = readl(ioaddr + PTP_TCR); |
| 40 | unsigned long data; | 40 | unsigned long data; |
| 41 | 41 | ||
| 42 | /* Convert the ptp_clock to nano second | 42 | /* For GMAC3.x, 4.x versions, convert the ptp_clock to nano second |
| 43 | * formula = (2/ptp_clock) * 1000000000 | 43 | * formula = (1/ptp_clock) * 1000000000 |
| 44 | * where, ptp_clock = 50MHz. | 44 | * where ptp_clock is 50MHz if fine method is used to update system |
| 45 | */ | 45 | */ |
| 46 | data = (2000000000ULL / ptp_clock); | 46 | if (value & PTP_TCR_TSCFUPDT) |
| 47 | data = (1000000000ULL / 50000000); | ||
| 48 | else | ||
| 49 | data = (1000000000ULL / ptp_clock); | ||
| 47 | 50 | ||
| 48 | /* 0.465ns accuracy */ | 51 | /* 0.465ns accuracy */ |
| 49 | if (!(value & PTP_TCR_TSCTRLSSR)) | 52 | if (!(value & PTP_TCR_TSCTRLSSR)) |
| 50 | data = (data * 1000) / 465; | 53 | data = (data * 1000) / 465; |
| 51 | 54 | ||
| 55 | data &= PTP_SSIR_SSINC_MASK; | ||
| 56 | |||
| 57 | if (gmac4) | ||
| 58 | data = data << GMAC4_PTP_SSIR_SSINC_SHIFT; | ||
| 59 | |||
| 52 | writel(data, ioaddr + PTP_SSIR); | 60 | writel(data, ioaddr + PTP_SSIR); |
| 53 | 61 | ||
| 54 | return data; | 62 | return data; |
| @@ -104,14 +112,30 @@ static int stmmac_config_addend(void __iomem *ioaddr, u32 addend) | |||
| 104 | } | 112 | } |
| 105 | 113 | ||
| 106 | static int stmmac_adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec, | 114 | static int stmmac_adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec, |
| 107 | int add_sub) | 115 | int add_sub, int gmac4) |
| 108 | { | 116 | { |
| 109 | u32 value; | 117 | u32 value; |
| 110 | int limit; | 118 | int limit; |
| 111 | 119 | ||
| 120 | if (add_sub) { | ||
| 121 | /* If the new sec value needs to be subtracted with | ||
| 122 | * the system time, then MAC_STSUR reg should be | ||
| 123 | * programmed with (2^32 – <new_sec_value>) | ||
| 124 | */ | ||
| 125 | if (gmac4) | ||
| 126 | sec = (100000000ULL - sec); | ||
| 127 | |||
| 128 | value = readl(ioaddr + PTP_TCR); | ||
| 129 | if (value & PTP_TCR_TSCTRLSSR) | ||
| 130 | nsec = (PTP_DIGITAL_ROLLOVER_MODE - nsec); | ||
| 131 | else | ||
| 132 | nsec = (PTP_BINARY_ROLLOVER_MODE - nsec); | ||
| 133 | } | ||
| 134 | |||
| 112 | writel(sec, ioaddr + PTP_STSUR); | 135 | writel(sec, ioaddr + PTP_STSUR); |
| 113 | writel(((add_sub << PTP_STNSUR_ADDSUB_SHIFT) | nsec), | 136 | value = (add_sub << PTP_STNSUR_ADDSUB_SHIFT) | nsec; |
| 114 | ioaddr + PTP_STNSUR); | 137 | writel(value, ioaddr + PTP_STNSUR); |
| 138 | |||
| 115 | /* issue command to initialize the system time value */ | 139 | /* issue command to initialize the system time value */ |
| 116 | value = readl(ioaddr + PTP_TCR); | 140 | value = readl(ioaddr + PTP_TCR); |
| 117 | value |= PTP_TCR_TSUPDT; | 141 | value |= PTP_TCR_TSUPDT; |
| @@ -134,8 +158,9 @@ static u64 stmmac_get_systime(void __iomem *ioaddr) | |||
| 134 | { | 158 | { |
| 135 | u64 ns; | 159 | u64 ns; |
| 136 | 160 | ||
| 161 | /* Get the TSSS value */ | ||
| 137 | ns = readl(ioaddr + PTP_STNSR); | 162 | ns = readl(ioaddr + PTP_STNSR); |
| 138 | /* convert sec time value to nanosecond */ | 163 | /* Get the TSS and convert sec time value to nanosecond */ |
| 139 | ns += readl(ioaddr + PTP_STSR) * 1000000000ULL; | 164 | ns += readl(ioaddr + PTP_STSR) * 1000000000ULL; |
| 140 | 165 | ||
| 141 | return ns; | 166 | return ns; |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e2c94ec4edd0..1f9ec02fa7f8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
| @@ -340,18 +340,17 @@ out: | |||
| 340 | 340 | ||
| 341 | /* stmmac_get_tx_hwtstamp - get HW TX timestamps | 341 | /* stmmac_get_tx_hwtstamp - get HW TX timestamps |
| 342 | * @priv: driver private structure | 342 | * @priv: driver private structure |
| 343 | * @entry : descriptor index to be used. | 343 | * @p : descriptor pointer |
| 344 | * @skb : the socket buffer | 344 | * @skb : the socket buffer |
| 345 | * Description : | 345 | * Description : |
| 346 | * This function will read timestamp from the descriptor & pass it to stack. | 346 | * This function will read timestamp from the descriptor & pass it to stack. |
| 347 | * and also perform some sanity checks. | 347 | * and also perform some sanity checks. |
| 348 | */ | 348 | */ |
| 349 | static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, | 349 | static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, |
| 350 | unsigned int entry, struct sk_buff *skb) | 350 | struct dma_desc *p, struct sk_buff *skb) |
| 351 | { | 351 | { |
| 352 | struct skb_shared_hwtstamps shhwtstamp; | 352 | struct skb_shared_hwtstamps shhwtstamp; |
| 353 | u64 ns; | 353 | u64 ns; |
| 354 | void *desc = NULL; | ||
| 355 | 354 | ||
| 356 | if (!priv->hwts_tx_en) | 355 | if (!priv->hwts_tx_en) |
| 357 | return; | 356 | return; |
| @@ -360,58 +359,55 @@ static void stmmac_get_tx_hwtstamp(struct stmmac_priv *priv, | |||
| 360 | if (likely(!skb || !(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS))) | 359 | if (likely(!skb || !(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS))) |
| 361 | return; | 360 | return; |
| 362 | 361 | ||
| 363 | if (priv->adv_ts) | ||
| 364 | desc = (priv->dma_etx + entry); | ||
| 365 | else | ||
| 366 | desc = (priv->dma_tx + entry); | ||
| 367 | |||
| 368 | /* check tx tstamp status */ | 362 | /* check tx tstamp status */ |
| 369 | if (!priv->hw->desc->get_tx_timestamp_status((struct dma_desc *)desc)) | 363 | if (!priv->hw->desc->get_tx_timestamp_status(p)) { |
| 370 | return; | 364 | /* get the valid tstamp */ |
| 365 | ns = priv->hw->desc->get_timestamp(p, priv->adv_ts); | ||
| 371 | 366 | ||
| 372 | /* get the valid tstamp */ | 367 | memset(&shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); |
| 373 | ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts); | 368 | shhwtstamp.hwtstamp = ns_to_ktime(ns); |
| 374 | 369 | ||
| 375 | memset(&shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); | 370 | netdev_info(priv->dev, "get valid TX hw timestamp %llu\n", ns); |
| 376 | shhwtstamp.hwtstamp = ns_to_ktime(ns); | 371 | /* pass tstamp to stack */ |
| 377 | /* pass tstamp to stack */ | 372 | skb_tstamp_tx(skb, &shhwtstamp); |
| 378 | skb_tstamp_tx(skb, &shhwtstamp); | 373 | } |
| 379 | 374 | ||
| 380 | return; | 375 | return; |
| 381 | } | 376 | } |
| 382 | 377 | ||
| 383 | /* stmmac_get_rx_hwtstamp - get HW RX timestamps | 378 | /* stmmac_get_rx_hwtstamp - get HW RX timestamps |
| 384 | * @priv: driver private structure | 379 | * @priv: driver private structure |
| 385 | * @entry : descriptor index to be used. | 380 | * @p : descriptor pointer |
| 381 | * @np : next descriptor pointer | ||
| 386 | * @skb : the socket buffer | 382 | * @skb : the socket buffer |
| 387 | * Description : | 383 | * Description : |
| 388 | * This function will read received packet's timestamp from the descriptor | 384 | * This function will read received packet's timestamp from the descriptor |
| 389 | * and pass it to stack. It also perform some sanity checks. | 385 | * and pass it to stack. It also perform some sanity checks. |
| 390 | */ | 386 | */ |
| 391 | static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, | 387 | static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, |
| 392 | unsigned int entry, struct sk_buff *skb) | 388 | struct dma_desc *np, struct sk_buff *skb) |
| 393 | { | 389 | { |
| 394 | struct skb_shared_hwtstamps *shhwtstamp = NULL; | 390 | struct skb_shared_hwtstamps *shhwtstamp = NULL; |
| 395 | u64 ns; | 391 | u64 ns; |
| 396 | void *desc = NULL; | ||
| 397 | 392 | ||
| 398 | if (!priv->hwts_rx_en) | 393 | if (!priv->hwts_rx_en) |
| 399 | return; | 394 | return; |
| 400 | 395 | ||
| 401 | if (priv->adv_ts) | 396 | /* Check if timestamp is available */ |
| 402 | desc = (priv->dma_erx + entry); | 397 | if (!priv->hw->desc->get_rx_timestamp_status(p, priv->adv_ts)) { |
| 403 | else | 398 | /* For GMAC4, the valid timestamp is from CTX next desc. */ |
| 404 | desc = (priv->dma_rx + entry); | 399 | if (priv->plat->has_gmac4) |
| 405 | 400 | ns = priv->hw->desc->get_timestamp(np, priv->adv_ts); | |
| 406 | /* exit if rx tstamp is not valid */ | 401 | else |
| 407 | if (!priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) | 402 | ns = priv->hw->desc->get_timestamp(p, priv->adv_ts); |
| 408 | return; | ||
| 409 | 403 | ||
| 410 | /* get valid tstamp */ | 404 | netdev_info(priv->dev, "get valid RX hw timestamp %llu\n", ns); |
| 411 | ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts); | 405 | shhwtstamp = skb_hwtstamps(skb); |
| 412 | shhwtstamp = skb_hwtstamps(skb); | 406 | memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); |
| 413 | memset(shhwtstamp, 0, sizeof(struct skb_shared_hwtstamps)); | 407 | shhwtstamp->hwtstamp = ns_to_ktime(ns); |
| 414 | shhwtstamp->hwtstamp = ns_to_ktime(ns); | 408 | } else { |
| 409 | netdev_err(priv->dev, "cannot get RX hw timestamp\n"); | ||
| 410 | } | ||
| 415 | } | 411 | } |
| 416 | 412 | ||
| 417 | /** | 413 | /** |
| @@ -598,17 +594,18 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) | |||
| 598 | priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON; | 594 | priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON; |
| 599 | 595 | ||
| 600 | if (!priv->hwts_tx_en && !priv->hwts_rx_en) | 596 | if (!priv->hwts_tx_en && !priv->hwts_rx_en) |
| 601 | priv->hw->ptp->config_hw_tstamping(priv->ioaddr, 0); | 597 | priv->hw->ptp->config_hw_tstamping(priv->ptpaddr, 0); |
| 602 | else { | 598 | else { |
| 603 | value = (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | PTP_TCR_TSCTRLSSR | | 599 | value = (PTP_TCR_TSENA | PTP_TCR_TSCFUPDT | PTP_TCR_TSCTRLSSR | |
| 604 | tstamp_all | ptp_v2 | ptp_over_ethernet | | 600 | tstamp_all | ptp_v2 | ptp_over_ethernet | |
| 605 | ptp_over_ipv6_udp | ptp_over_ipv4_udp | ts_event_en | | 601 | ptp_over_ipv6_udp | ptp_over_ipv4_udp | ts_event_en | |
| 606 | ts_master_en | snap_type_sel); | 602 | ts_master_en | snap_type_sel); |
| 607 | priv->hw->ptp->config_hw_tstamping(priv->ioaddr, value); | 603 | priv->hw->ptp->config_hw_tstamping(priv->ptpaddr, value); |
| 608 | 604 | ||
| 609 | /* program Sub Second Increment reg */ | 605 | /* program Sub Second Increment reg */ |
| 610 | sec_inc = priv->hw->ptp->config_sub_second_increment( | 606 | sec_inc = priv->hw->ptp->config_sub_second_increment( |
| 611 | priv->ioaddr, priv->clk_ptp_rate); | 607 | priv->ptpaddr, priv->clk_ptp_rate, |
| 608 | priv->plat->has_gmac4); | ||
| 612 | temp = div_u64(1000000000ULL, sec_inc); | 609 | temp = div_u64(1000000000ULL, sec_inc); |
| 613 | 610 | ||
| 614 | /* calculate default added value: | 611 | /* calculate default added value: |
| @@ -618,14 +615,14 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) | |||
| 618 | */ | 615 | */ |
| 619 | temp = (u64)(temp << 32); | 616 | temp = (u64)(temp << 32); |
| 620 | priv->default_addend = div_u64(temp, priv->clk_ptp_rate); | 617 | priv->default_addend = div_u64(temp, priv->clk_ptp_rate); |
| 621 | priv->hw->ptp->config_addend(priv->ioaddr, | 618 | priv->hw->ptp->config_addend(priv->ptpaddr, |
| 622 | priv->default_addend); | 619 | priv->default_addend); |
| 623 | 620 | ||
| 624 | /* initialize system time */ | 621 | /* initialize system time */ |
| 625 | ktime_get_real_ts64(&now); | 622 | ktime_get_real_ts64(&now); |
| 626 | 623 | ||
| 627 | /* lower 32 bits of tv_sec are safe until y2106 */ | 624 | /* lower 32 bits of tv_sec are safe until y2106 */ |
| 628 | priv->hw->ptp->init_systime(priv->ioaddr, (u32)now.tv_sec, | 625 | priv->hw->ptp->init_systime(priv->ptpaddr, (u32)now.tv_sec, |
| 629 | now.tv_nsec); | 626 | now.tv_nsec); |
| 630 | } | 627 | } |
| 631 | 628 | ||
| @@ -1340,7 +1337,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) | |||
| 1340 | priv->dev->stats.tx_packets++; | 1337 | priv->dev->stats.tx_packets++; |
| 1341 | priv->xstats.tx_pkt_n++; | 1338 | priv->xstats.tx_pkt_n++; |
| 1342 | } | 1339 | } |
| 1343 | stmmac_get_tx_hwtstamp(priv, entry, skb); | 1340 | stmmac_get_tx_hwtstamp(priv, p, skb); |
| 1344 | } | 1341 | } |
| 1345 | 1342 | ||
| 1346 | if (likely(priv->tx_skbuff_dma[entry].buf)) { | 1343 | if (likely(priv->tx_skbuff_dma[entry].buf)) { |
| @@ -1486,10 +1483,13 @@ static void stmmac_mmc_setup(struct stmmac_priv *priv) | |||
| 1486 | unsigned int mode = MMC_CNTRL_RESET_ON_READ | MMC_CNTRL_COUNTER_RESET | | 1483 | unsigned int mode = MMC_CNTRL_RESET_ON_READ | MMC_CNTRL_COUNTER_RESET | |
| 1487 | MMC_CNTRL_PRESET | MMC_CNTRL_FULL_HALF_PRESET; | 1484 | MMC_CNTRL_PRESET | MMC_CNTRL_FULL_HALF_PRESET; |
| 1488 | 1485 | ||
| 1489 | if (priv->synopsys_id >= DWMAC_CORE_4_00) | 1486 | if (priv->synopsys_id >= DWMAC_CORE_4_00) { |
| 1487 | priv->ptpaddr = priv->ioaddr + PTP_GMAC4_OFFSET; | ||
| 1490 | priv->mmcaddr = priv->ioaddr + MMC_GMAC4_OFFSET; | 1488 | priv->mmcaddr = priv->ioaddr + MMC_GMAC4_OFFSET; |
| 1491 | else | 1489 | } else { |
| 1490 | priv->ptpaddr = priv->ioaddr + PTP_GMAC3_X_OFFSET; | ||
| 1492 | priv->mmcaddr = priv->ioaddr + MMC_GMAC3_X_OFFSET; | 1491 | priv->mmcaddr = priv->ioaddr + MMC_GMAC3_X_OFFSET; |
| 1492 | } | ||
| 1493 | 1493 | ||
| 1494 | dwmac_mmc_intr_all_mask(priv->mmcaddr); | 1494 | dwmac_mmc_intr_all_mask(priv->mmcaddr); |
| 1495 | 1495 | ||
| @@ -2484,7 +2484,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) | |||
| 2484 | if (netif_msg_rx_status(priv)) { | 2484 | if (netif_msg_rx_status(priv)) { |
| 2485 | void *rx_head; | 2485 | void *rx_head; |
| 2486 | 2486 | ||
| 2487 | pr_debug("%s: descriptor ring:\n", __func__); | 2487 | pr_info(">>>>>> %s: descriptor ring:\n", __func__); |
| 2488 | if (priv->extend_desc) | 2488 | if (priv->extend_desc) |
| 2489 | rx_head = (void *)priv->dma_erx; | 2489 | rx_head = (void *)priv->dma_erx; |
| 2490 | else | 2490 | else |
| @@ -2495,6 +2495,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) | |||
| 2495 | while (count < limit) { | 2495 | while (count < limit) { |
| 2496 | int status; | 2496 | int status; |
| 2497 | struct dma_desc *p; | 2497 | struct dma_desc *p; |
| 2498 | struct dma_desc *np; | ||
| 2498 | 2499 | ||
| 2499 | if (priv->extend_desc) | 2500 | if (priv->extend_desc) |
| 2500 | p = (struct dma_desc *)(priv->dma_erx + entry); | 2501 | p = (struct dma_desc *)(priv->dma_erx + entry); |
| @@ -2514,9 +2515,11 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) | |||
| 2514 | next_entry = priv->cur_rx; | 2515 | next_entry = priv->cur_rx; |
| 2515 | 2516 | ||
| 2516 | if (priv->extend_desc) | 2517 | if (priv->extend_desc) |
| 2517 | prefetch(priv->dma_erx + next_entry); | 2518 | np = (struct dma_desc *)(priv->dma_erx + next_entry); |
| 2518 | else | 2519 | else |
| 2519 | prefetch(priv->dma_rx + next_entry); | 2520 | np = priv->dma_rx + next_entry; |
| 2521 | |||
| 2522 | prefetch(np); | ||
| 2520 | 2523 | ||
| 2521 | if ((priv->extend_desc) && (priv->hw->desc->rx_extended_status)) | 2524 | if ((priv->extend_desc) && (priv->hw->desc->rx_extended_status)) |
| 2522 | priv->hw->desc->rx_extended_status(&priv->dev->stats, | 2525 | priv->hw->desc->rx_extended_status(&priv->dev->stats, |
| @@ -2568,7 +2571,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) | |||
| 2568 | frame_len -= ETH_FCS_LEN; | 2571 | frame_len -= ETH_FCS_LEN; |
| 2569 | 2572 | ||
| 2570 | if (netif_msg_rx_status(priv)) { | 2573 | if (netif_msg_rx_status(priv)) { |
| 2571 | pr_debug("\tdesc: %p [entry %d] buff=0x%x\n", | 2574 | pr_info("\tdesc: %p [entry %d] buff=0x%x\n", |
| 2572 | p, entry, des); | 2575 | p, entry, des); |
| 2573 | if (frame_len > ETH_FRAME_LEN) | 2576 | if (frame_len > ETH_FRAME_LEN) |
| 2574 | pr_debug("\tframe size %d, COE: %d\n", | 2577 | pr_debug("\tframe size %d, COE: %d\n", |
| @@ -2625,13 +2628,13 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) | |||
| 2625 | DMA_FROM_DEVICE); | 2628 | DMA_FROM_DEVICE); |
| 2626 | } | 2629 | } |
| 2627 | 2630 | ||
| 2628 | stmmac_get_rx_hwtstamp(priv, entry, skb); | ||
| 2629 | |||
| 2630 | if (netif_msg_pktdata(priv)) { | 2631 | if (netif_msg_pktdata(priv)) { |
| 2631 | pr_debug("frame received (%dbytes)", frame_len); | 2632 | pr_debug("frame received (%dbytes)", frame_len); |
| 2632 | print_pkt(skb->data, frame_len); | 2633 | print_pkt(skb->data, frame_len); |
| 2633 | } | 2634 | } |
| 2634 | 2635 | ||
| 2636 | stmmac_get_rx_hwtstamp(priv, p, np, skb); | ||
| 2637 | |||
| 2635 | stmmac_rx_vlan(priv->dev, skb); | 2638 | stmmac_rx_vlan(priv->dev, skb); |
| 2636 | 2639 | ||
| 2637 | skb->protocol = eth_type_trans(skb, priv->dev); | 2640 | skb->protocol = eth_type_trans(skb, priv->dev); |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index 1477471f8d44..3eb281d1db08 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | |||
| @@ -54,7 +54,7 @@ static int stmmac_adjust_freq(struct ptp_clock_info *ptp, s32 ppb) | |||
| 54 | 54 | ||
| 55 | spin_lock_irqsave(&priv->ptp_lock, flags); | 55 | spin_lock_irqsave(&priv->ptp_lock, flags); |
| 56 | 56 | ||
| 57 | priv->hw->ptp->config_addend(priv->ioaddr, addend); | 57 | priv->hw->ptp->config_addend(priv->ptpaddr, addend); |
| 58 | 58 | ||
| 59 | spin_unlock_irqrestore(&priv->ptp_lock, flags); | 59 | spin_unlock_irqrestore(&priv->ptp_lock, flags); |
| 60 | 60 | ||
| @@ -89,7 +89,8 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta) | |||
| 89 | 89 | ||
| 90 | spin_lock_irqsave(&priv->ptp_lock, flags); | 90 | spin_lock_irqsave(&priv->ptp_lock, flags); |
| 91 | 91 | ||
| 92 | priv->hw->ptp->adjust_systime(priv->ioaddr, sec, nsec, neg_adj); | 92 | priv->hw->ptp->adjust_systime(priv->ptpaddr, sec, nsec, neg_adj, |
| 93 | priv->plat->has_gmac4); | ||
| 93 | 94 | ||
| 94 | spin_unlock_irqrestore(&priv->ptp_lock, flags); | 95 | spin_unlock_irqrestore(&priv->ptp_lock, flags); |
| 95 | 96 | ||
| @@ -114,7 +115,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) | |||
| 114 | 115 | ||
| 115 | spin_lock_irqsave(&priv->ptp_lock, flags); | 116 | spin_lock_irqsave(&priv->ptp_lock, flags); |
| 116 | 117 | ||
| 117 | ns = priv->hw->ptp->get_systime(priv->ioaddr); | 118 | ns = priv->hw->ptp->get_systime(priv->ptpaddr); |
| 118 | 119 | ||
| 119 | spin_unlock_irqrestore(&priv->ptp_lock, flags); | 120 | spin_unlock_irqrestore(&priv->ptp_lock, flags); |
| 120 | 121 | ||
| @@ -141,7 +142,7 @@ static int stmmac_set_time(struct ptp_clock_info *ptp, | |||
| 141 | 142 | ||
| 142 | spin_lock_irqsave(&priv->ptp_lock, flags); | 143 | spin_lock_irqsave(&priv->ptp_lock, flags); |
| 143 | 144 | ||
| 144 | priv->hw->ptp->init_systime(priv->ioaddr, ts->tv_sec, ts->tv_nsec); | 145 | priv->hw->ptp->init_systime(priv->ptpaddr, ts->tv_sec, ts->tv_nsec); |
| 145 | 146 | ||
| 146 | spin_unlock_irqrestore(&priv->ptp_lock, flags); | 147 | spin_unlock_irqrestore(&priv->ptp_lock, flags); |
| 147 | 148 | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h index 4535df37c227..c06938c47af5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h | |||
| @@ -22,51 +22,53 @@ | |||
| 22 | Author: Rayagond Kokatanur <rayagond@vayavyalabs.com> | 22 | Author: Rayagond Kokatanur <rayagond@vayavyalabs.com> |
| 23 | ******************************************************************************/ | 23 | ******************************************************************************/ |
| 24 | 24 | ||
| 25 | #ifndef __STMMAC_PTP_H__ | 25 | #ifndef __STMMAC_PTP_H__ |
| 26 | #define __STMMAC_PTP_H__ | 26 | #define __STMMAC_PTP_H__ |
| 27 | 27 | ||
| 28 | /* IEEE 1588 PTP register offsets */ | 28 | #define PTP_GMAC4_OFFSET 0xb00 |
| 29 | #define PTP_TCR 0x0700 /* Timestamp Control Reg */ | 29 | #define PTP_GMAC3_X_OFFSET 0x700 |
| 30 | #define PTP_SSIR 0x0704 /* Sub-Second Increment Reg */ | ||
| 31 | #define PTP_STSR 0x0708 /* System Time – Seconds Regr */ | ||
| 32 | #define PTP_STNSR 0x070C /* System Time – Nanoseconds Reg */ | ||
| 33 | #define PTP_STSUR 0x0710 /* System Time – Seconds Update Reg */ | ||
| 34 | #define PTP_STNSUR 0x0714 /* System Time – Nanoseconds Update Reg */ | ||
| 35 | #define PTP_TAR 0x0718 /* Timestamp Addend Reg */ | ||
| 36 | #define PTP_TTSR 0x071C /* Target Time Seconds Reg */ | ||
| 37 | #define PTP_TTNSR 0x0720 /* Target Time Nanoseconds Reg */ | ||
| 38 | #define PTP_STHWSR 0x0724 /* System Time - Higher Word Seconds Reg */ | ||
| 39 | #define PTP_TSR 0x0728 /* Timestamp Status */ | ||
| 40 | 30 | ||
| 41 | #define PTP_STNSUR_ADDSUB_SHIFT 31 | 31 | /* IEEE 1588 PTP register offsets */ |
| 32 | #define PTP_TCR 0x00 /* Timestamp Control Reg */ | ||
| 33 | #define PTP_SSIR 0x04 /* Sub-Second Increment Reg */ | ||
| 34 | #define PTP_STSR 0x08 /* System Time – Seconds Regr */ | ||
| 35 | #define PTP_STNSR 0x0c /* System Time – Nanoseconds Reg */ | ||
| 36 | #define PTP_STSUR 0x10 /* System Time – Seconds Update Reg */ | ||
| 37 | #define PTP_STNSUR 0x14 /* System Time – Nanoseconds Update Reg */ | ||
| 38 | #define PTP_TAR 0x18 /* Timestamp Addend Reg */ | ||
| 42 | 39 | ||
| 43 | /* PTP TCR defines */ | 40 | #define PTP_STNSUR_ADDSUB_SHIFT 31 |
| 44 | #define PTP_TCR_TSENA 0x00000001 /* Timestamp Enable */ | 41 | #define PTP_DIGITAL_ROLLOVER_MODE 0x3B9ACA00 /* 10e9-1 ns */ |
| 45 | #define PTP_TCR_TSCFUPDT 0x00000002 /* Timestamp Fine/Coarse Update */ | 42 | #define PTP_BINARY_ROLLOVER_MODE 0x80000000 /* ~0.466 ns */ |
| 46 | #define PTP_TCR_TSINIT 0x00000004 /* Timestamp Initialize */ | ||
| 47 | #define PTP_TCR_TSUPDT 0x00000008 /* Timestamp Update */ | ||
| 48 | /* Timestamp Interrupt Trigger Enable */ | ||
| 49 | #define PTP_TCR_TSTRIG 0x00000010 | ||
| 50 | #define PTP_TCR_TSADDREG 0x00000020 /* Addend Reg Update */ | ||
| 51 | #define PTP_TCR_TSENALL 0x00000100 /* Enable Timestamp for All Frames */ | ||
| 52 | /* Timestamp Digital or Binary Rollover Control */ | ||
| 53 | #define PTP_TCR_TSCTRLSSR 0x00000200 | ||
| 54 | 43 | ||
| 44 | /* PTP Timestamp control register defines */ | ||
| 45 | #define PTP_TCR_TSENA BIT(0) /* Timestamp Enable */ | ||
| 46 | #define PTP_TCR_TSCFUPDT BIT(1) /* Timestamp Fine/Coarse Update */ | ||
| 47 | #define PTP_TCR_TSINIT BIT(2) /* Timestamp Initialize */ | ||
| 48 | #define PTP_TCR_TSUPDT BIT(3) /* Timestamp Update */ | ||
| 49 | #define PTP_TCR_TSTRIG BIT(4) /* Timestamp Interrupt Trigger Enable */ | ||
| 50 | #define PTP_TCR_TSADDREG BIT(5) /* Addend Reg Update */ | ||
| 51 | #define PTP_TCR_TSENALL BIT(8) /* Enable Timestamp for All Frames */ | ||
| 52 | #define PTP_TCR_TSCTRLSSR BIT(9) /* Digital or Binary Rollover Control */ | ||
| 55 | /* Enable PTP packet Processing for Version 2 Format */ | 53 | /* Enable PTP packet Processing for Version 2 Format */ |
| 56 | #define PTP_TCR_TSVER2ENA 0x00000400 | 54 | #define PTP_TCR_TSVER2ENA BIT(10) |
| 57 | /* Enable Processing of PTP over Ethernet Frames */ | 55 | /* Enable Processing of PTP over Ethernet Frames */ |
| 58 | #define PTP_TCR_TSIPENA 0x00000800 | 56 | #define PTP_TCR_TSIPENA BIT(11) |
| 59 | /* Enable Processing of PTP Frames Sent over IPv6-UDP */ | 57 | /* Enable Processing of PTP Frames Sent over IPv6-UDP */ |
| 60 | #define PTP_TCR_TSIPV6ENA 0x00001000 | 58 | #define PTP_TCR_TSIPV6ENA BIT(12) |
| 61 | /* Enable Processing of PTP Frames Sent over IPv4-UDP */ | 59 | /* Enable Processing of PTP Frames Sent over IPv4-UDP */ |
| 62 | #define PTP_TCR_TSIPV4ENA 0x00002000 | 60 | #define PTP_TCR_TSIPV4ENA BIT(13) |
| 63 | /* Enable Timestamp Snapshot for Event Messages */ | 61 | /* Enable Timestamp Snapshot for Event Messages */ |
| 64 | #define PTP_TCR_TSEVNTENA 0x00004000 | 62 | #define PTP_TCR_TSEVNTENA BIT(14) |
| 65 | /* Enable Snapshot for Messages Relevant to Master */ | 63 | /* Enable Snapshot for Messages Relevant to Master */ |
| 66 | #define PTP_TCR_TSMSTRENA 0x00008000 | 64 | #define PTP_TCR_TSMSTRENA BIT(15) |
| 67 | /* Select PTP packets for Taking Snapshots */ | 65 | /* Select PTP packets for Taking Snapshots */ |
| 68 | #define PTP_TCR_SNAPTYPSEL_1 0x00010000 | 66 | #define PTP_TCR_SNAPTYPSEL_1 GENMASK(17, 16) |
| 69 | /* Enable MAC address for PTP Frame Filtering */ | 67 | /* Enable MAC address for PTP Frame Filtering */ |
| 70 | #define PTP_TCR_TSENMACADDR 0x00040000 | 68 | #define PTP_TCR_TSENMACADDR BIT(18) |
| 69 | |||
| 70 | /* SSIR defines */ | ||
| 71 | #define PTP_SSIR_SSINC_MASK 0xff | ||
| 72 | #define GMAC4_PTP_SSIR_SSINC_SHIFT 16 | ||
| 71 | 73 | ||
| 72 | #endif /* __STMMAC_PTP_H__ */ | 74 | #endif /* __STMMAC_PTP_H__ */ |
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index c6cff3d2ff05..58947aae31c7 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
| @@ -2375,8 +2375,11 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, | |||
| 2375 | * to the PHY is the Ethernet MAC DT node. | 2375 | * to the PHY is the Ethernet MAC DT node. |
| 2376 | */ | 2376 | */ |
| 2377 | ret = of_phy_register_fixed_link(slave_node); | 2377 | ret = of_phy_register_fixed_link(slave_node); |
| 2378 | if (ret) | 2378 | if (ret) { |
| 2379 | if (ret != -EPROBE_DEFER) | ||
| 2380 | dev_err(&pdev->dev, "failed to register fixed-link phy: %d\n", ret); | ||
| 2379 | return ret; | 2381 | return ret; |
| 2382 | } | ||
| 2380 | slave_data->phy_node = of_node_get(slave_node); | 2383 | slave_data->phy_node = of_node_get(slave_node); |
| 2381 | } else if (parp) { | 2384 | } else if (parp) { |
| 2382 | u32 phyid; | 2385 | u32 phyid; |
| @@ -2397,6 +2400,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, | |||
| 2397 | } | 2400 | } |
| 2398 | snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), | 2401 | snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), |
| 2399 | PHY_ID_FMT, mdio->name, phyid); | 2402 | PHY_ID_FMT, mdio->name, phyid); |
| 2403 | put_device(&mdio->dev); | ||
| 2400 | } else { | 2404 | } else { |
| 2401 | dev_err(&pdev->dev, | 2405 | dev_err(&pdev->dev, |
| 2402 | "No slave[%d] phy_id, phy-handle, or fixed-link property\n", | 2406 | "No slave[%d] phy_id, phy-handle, or fixed-link property\n", |
| @@ -2440,6 +2444,46 @@ no_phy_slave: | |||
| 2440 | return 0; | 2444 | return 0; |
| 2441 | } | 2445 | } |
| 2442 | 2446 | ||
| 2447 | static void cpsw_remove_dt(struct platform_device *pdev) | ||
| 2448 | { | ||
| 2449 | struct net_device *ndev = platform_get_drvdata(pdev); | ||
| 2450 | struct cpsw_common *cpsw = ndev_to_cpsw(ndev); | ||
| 2451 | struct cpsw_platform_data *data = &cpsw->data; | ||
| 2452 | struct device_node *node = pdev->dev.of_node; | ||
| 2453 | struct device_node *slave_node; | ||
| 2454 | int i = 0; | ||
| 2455 | |||
| 2456 | for_each_available_child_of_node(node, slave_node) { | ||
| 2457 | struct cpsw_slave_data *slave_data = &data->slave_data[i]; | ||
| 2458 | |||
| 2459 | if (strcmp(slave_node->name, "slave")) | ||
| 2460 | continue; | ||
| 2461 | |||
| 2462 | if (of_phy_is_fixed_link(slave_node)) { | ||
| 2463 | struct phy_device *phydev; | ||
| 2464 | |||
| 2465 | phydev = of_phy_find_device(slave_node); | ||
| 2466 | if (phydev) { | ||
| 2467 | fixed_phy_unregister(phydev); | ||
| 2468 | /* Put references taken by | ||
| 2469 | * of_phy_find_device() and | ||
| 2470 | * of_phy_register_fixed_link(). | ||
| 2471 | */ | ||
| 2472 | phy_device_free(phydev); | ||
| 2473 | phy_device_free(phydev); | ||
| 2474 | } | ||
| 2475 | } | ||
| 2476 | |||
| 2477 | of_node_put(slave_data->phy_node); | ||
| 2478 | |||
| 2479 | i++; | ||
| 2480 | if (i == data->slaves) | ||
| 2481 | break; | ||
| 2482 | } | ||
| 2483 | |||
| 2484 | of_platform_depopulate(&pdev->dev); | ||
| 2485 | } | ||
| 2486 | |||
| 2443 | static int cpsw_probe_dual_emac(struct cpsw_priv *priv) | 2487 | static int cpsw_probe_dual_emac(struct cpsw_priv *priv) |
| 2444 | { | 2488 | { |
| 2445 | struct cpsw_common *cpsw = priv->cpsw; | 2489 | struct cpsw_common *cpsw = priv->cpsw; |
| @@ -2547,6 +2591,9 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2547 | int irq; | 2591 | int irq; |
| 2548 | 2592 | ||
| 2549 | cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL); | 2593 | cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL); |
| 2594 | if (!cpsw) | ||
| 2595 | return -ENOMEM; | ||
| 2596 | |||
| 2550 | cpsw->dev = &pdev->dev; | 2597 | cpsw->dev = &pdev->dev; |
| 2551 | 2598 | ||
| 2552 | ndev = alloc_etherdev_mq(sizeof(struct cpsw_priv), CPSW_MAX_QUEUES); | 2599 | ndev = alloc_etherdev_mq(sizeof(struct cpsw_priv), CPSW_MAX_QUEUES); |
| @@ -2584,11 +2631,19 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2584 | /* Select default pin state */ | 2631 | /* Select default pin state */ |
| 2585 | pinctrl_pm_select_default_state(&pdev->dev); | 2632 | pinctrl_pm_select_default_state(&pdev->dev); |
| 2586 | 2633 | ||
| 2587 | if (cpsw_probe_dt(&cpsw->data, pdev)) { | 2634 | /* Need to enable clocks with runtime PM api to access module |
| 2588 | dev_err(&pdev->dev, "cpsw: platform data missing\n"); | 2635 | * registers |
| 2589 | ret = -ENODEV; | 2636 | */ |
| 2637 | ret = pm_runtime_get_sync(&pdev->dev); | ||
| 2638 | if (ret < 0) { | ||
| 2639 | pm_runtime_put_noidle(&pdev->dev); | ||
| 2590 | goto clean_runtime_disable_ret; | 2640 | goto clean_runtime_disable_ret; |
| 2591 | } | 2641 | } |
| 2642 | |||
| 2643 | ret = cpsw_probe_dt(&cpsw->data, pdev); | ||
| 2644 | if (ret) | ||
| 2645 | goto clean_dt_ret; | ||
| 2646 | |||
| 2592 | data = &cpsw->data; | 2647 | data = &cpsw->data; |
| 2593 | cpsw->rx_ch_num = 1; | 2648 | cpsw->rx_ch_num = 1; |
| 2594 | cpsw->tx_ch_num = 1; | 2649 | cpsw->tx_ch_num = 1; |
| @@ -2608,7 +2663,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2608 | GFP_KERNEL); | 2663 | GFP_KERNEL); |
| 2609 | if (!cpsw->slaves) { | 2664 | if (!cpsw->slaves) { |
| 2610 | ret = -ENOMEM; | 2665 | ret = -ENOMEM; |
| 2611 | goto clean_runtime_disable_ret; | 2666 | goto clean_dt_ret; |
| 2612 | } | 2667 | } |
| 2613 | for (i = 0; i < data->slaves; i++) | 2668 | for (i = 0; i < data->slaves; i++) |
| 2614 | cpsw->slaves[i].slave_num = i; | 2669 | cpsw->slaves[i].slave_num = i; |
| @@ -2620,7 +2675,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2620 | if (IS_ERR(clk)) { | 2675 | if (IS_ERR(clk)) { |
| 2621 | dev_err(priv->dev, "fck is not found\n"); | 2676 | dev_err(priv->dev, "fck is not found\n"); |
| 2622 | ret = -ENODEV; | 2677 | ret = -ENODEV; |
| 2623 | goto clean_runtime_disable_ret; | 2678 | goto clean_dt_ret; |
| 2624 | } | 2679 | } |
| 2625 | cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000; | 2680 | cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000; |
| 2626 | 2681 | ||
| @@ -2628,26 +2683,17 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2628 | ss_regs = devm_ioremap_resource(&pdev->dev, ss_res); | 2683 | ss_regs = devm_ioremap_resource(&pdev->dev, ss_res); |
| 2629 | if (IS_ERR(ss_regs)) { | 2684 | if (IS_ERR(ss_regs)) { |
| 2630 | ret = PTR_ERR(ss_regs); | 2685 | ret = PTR_ERR(ss_regs); |
| 2631 | goto clean_runtime_disable_ret; | 2686 | goto clean_dt_ret; |
| 2632 | } | 2687 | } |
| 2633 | cpsw->regs = ss_regs; | 2688 | cpsw->regs = ss_regs; |
| 2634 | 2689 | ||
| 2635 | /* Need to enable clocks with runtime PM api to access module | ||
| 2636 | * registers | ||
| 2637 | */ | ||
| 2638 | ret = pm_runtime_get_sync(&pdev->dev); | ||
| 2639 | if (ret < 0) { | ||
| 2640 | pm_runtime_put_noidle(&pdev->dev); | ||
| 2641 | goto clean_runtime_disable_ret; | ||
| 2642 | } | ||
| 2643 | cpsw->version = readl(&cpsw->regs->id_ver); | 2690 | cpsw->version = readl(&cpsw->regs->id_ver); |
| 2644 | pm_runtime_put_sync(&pdev->dev); | ||
| 2645 | 2691 | ||
| 2646 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 2692 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
| 2647 | cpsw->wr_regs = devm_ioremap_resource(&pdev->dev, res); | 2693 | cpsw->wr_regs = devm_ioremap_resource(&pdev->dev, res); |
| 2648 | if (IS_ERR(cpsw->wr_regs)) { | 2694 | if (IS_ERR(cpsw->wr_regs)) { |
| 2649 | ret = PTR_ERR(cpsw->wr_regs); | 2695 | ret = PTR_ERR(cpsw->wr_regs); |
| 2650 | goto clean_runtime_disable_ret; | 2696 | goto clean_dt_ret; |
| 2651 | } | 2697 | } |
| 2652 | 2698 | ||
| 2653 | memset(&dma_params, 0, sizeof(dma_params)); | 2699 | memset(&dma_params, 0, sizeof(dma_params)); |
| @@ -2684,7 +2730,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2684 | default: | 2730 | default: |
| 2685 | dev_err(priv->dev, "unknown version 0x%08x\n", cpsw->version); | 2731 | dev_err(priv->dev, "unknown version 0x%08x\n", cpsw->version); |
| 2686 | ret = -ENODEV; | 2732 | ret = -ENODEV; |
| 2687 | goto clean_runtime_disable_ret; | 2733 | goto clean_dt_ret; |
| 2688 | } | 2734 | } |
| 2689 | for (i = 0; i < cpsw->data.slaves; i++) { | 2735 | for (i = 0; i < cpsw->data.slaves; i++) { |
| 2690 | struct cpsw_slave *slave = &cpsw->slaves[i]; | 2736 | struct cpsw_slave *slave = &cpsw->slaves[i]; |
| @@ -2713,7 +2759,7 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2713 | if (!cpsw->dma) { | 2759 | if (!cpsw->dma) { |
| 2714 | dev_err(priv->dev, "error initializing dma\n"); | 2760 | dev_err(priv->dev, "error initializing dma\n"); |
| 2715 | ret = -ENOMEM; | 2761 | ret = -ENOMEM; |
| 2716 | goto clean_runtime_disable_ret; | 2762 | goto clean_dt_ret; |
| 2717 | } | 2763 | } |
| 2718 | 2764 | ||
| 2719 | cpsw->txch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0); | 2765 | cpsw->txch[0] = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0); |
| @@ -2811,16 +2857,23 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 2811 | ret = cpsw_probe_dual_emac(priv); | 2857 | ret = cpsw_probe_dual_emac(priv); |
| 2812 | if (ret) { | 2858 | if (ret) { |
| 2813 | cpsw_err(priv, probe, "error probe slave 2 emac interface\n"); | 2859 | cpsw_err(priv, probe, "error probe slave 2 emac interface\n"); |
| 2814 | goto clean_ale_ret; | 2860 | goto clean_unregister_netdev_ret; |
| 2815 | } | 2861 | } |
| 2816 | } | 2862 | } |
| 2817 | 2863 | ||
| 2864 | pm_runtime_put(&pdev->dev); | ||
| 2865 | |||
| 2818 | return 0; | 2866 | return 0; |
| 2819 | 2867 | ||
| 2868 | clean_unregister_netdev_ret: | ||
| 2869 | unregister_netdev(ndev); | ||
| 2820 | clean_ale_ret: | 2870 | clean_ale_ret: |
| 2821 | cpsw_ale_destroy(cpsw->ale); | 2871 | cpsw_ale_destroy(cpsw->ale); |
| 2822 | clean_dma_ret: | 2872 | clean_dma_ret: |
| 2823 | cpdma_ctlr_destroy(cpsw->dma); | 2873 | cpdma_ctlr_destroy(cpsw->dma); |
| 2874 | clean_dt_ret: | ||
| 2875 | cpsw_remove_dt(pdev); | ||
| 2876 | pm_runtime_put_sync(&pdev->dev); | ||
| 2824 | clean_runtime_disable_ret: | 2877 | clean_runtime_disable_ret: |
| 2825 | pm_runtime_disable(&pdev->dev); | 2878 | pm_runtime_disable(&pdev->dev); |
| 2826 | clean_ndev_ret: | 2879 | clean_ndev_ret: |
| @@ -2846,7 +2899,7 @@ static int cpsw_remove(struct platform_device *pdev) | |||
| 2846 | 2899 | ||
| 2847 | cpsw_ale_destroy(cpsw->ale); | 2900 | cpsw_ale_destroy(cpsw->ale); |
| 2848 | cpdma_ctlr_destroy(cpsw->dma); | 2901 | cpdma_ctlr_destroy(cpsw->dma); |
| 2849 | of_platform_depopulate(&pdev->dev); | 2902 | cpsw_remove_dt(pdev); |
| 2850 | pm_runtime_put_sync(&pdev->dev); | 2903 | pm_runtime_put_sync(&pdev->dev); |
| 2851 | pm_runtime_disable(&pdev->dev); | 2904 | pm_runtime_disable(&pdev->dev); |
| 2852 | if (cpsw->data.dual_emac) | 2905 | if (cpsw->data.dual_emac) |
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c index c649c101bbab..eb5167210681 100644 --- a/drivers/net/phy/fixed_phy.c +++ b/drivers/net/phy/fixed_phy.c | |||
| @@ -279,7 +279,7 @@ EXPORT_SYMBOL_GPL(fixed_phy_register); | |||
| 279 | void fixed_phy_unregister(struct phy_device *phy) | 279 | void fixed_phy_unregister(struct phy_device *phy) |
| 280 | { | 280 | { |
| 281 | phy_device_remove(phy); | 281 | phy_device_remove(phy); |
| 282 | 282 | of_node_put(phy->mdio.dev.of_node); | |
| 283 | fixed_phy_del(phy->mdio.addr); | 283 | fixed_phy_del(phy->mdio.addr); |
| 284 | } | 284 | } |
| 285 | EXPORT_SYMBOL_GPL(fixed_phy_unregister); | 285 | EXPORT_SYMBOL_GPL(fixed_phy_unregister); |
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c index 2e37eb337d48..24b4a09468dd 100644 --- a/drivers/net/phy/vitesse.c +++ b/drivers/net/phy/vitesse.c | |||
| @@ -62,6 +62,10 @@ | |||
| 62 | /* Vitesse Extended Page Access Register */ | 62 | /* Vitesse Extended Page Access Register */ |
| 63 | #define MII_VSC82X4_EXT_PAGE_ACCESS 0x1f | 63 | #define MII_VSC82X4_EXT_PAGE_ACCESS 0x1f |
| 64 | 64 | ||
| 65 | /* Vitesse VSC8601 Extended PHY Control Register 1 */ | ||
| 66 | #define MII_VSC8601_EPHY_CTL 0x17 | ||
| 67 | #define MII_VSC8601_EPHY_CTL_RGMII_SKEW (1 << 8) | ||
| 68 | |||
| 65 | #define PHY_ID_VSC8234 0x000fc620 | 69 | #define PHY_ID_VSC8234 0x000fc620 |
| 66 | #define PHY_ID_VSC8244 0x000fc6c0 | 70 | #define PHY_ID_VSC8244 0x000fc6c0 |
| 67 | #define PHY_ID_VSC8514 0x00070670 | 71 | #define PHY_ID_VSC8514 0x00070670 |
| @@ -111,6 +115,34 @@ static int vsc824x_config_init(struct phy_device *phydev) | |||
| 111 | return err; | 115 | return err; |
| 112 | } | 116 | } |
| 113 | 117 | ||
| 118 | /* This adds a skew for both TX and RX clocks, so the skew should only be | ||
| 119 | * applied to "rgmii-id" interfaces. It may not work as expected | ||
| 120 | * on "rgmii-txid", "rgmii-rxid" or "rgmii" interfaces. */ | ||
| 121 | static int vsc8601_add_skew(struct phy_device *phydev) | ||
| 122 | { | ||
| 123 | int ret; | ||
| 124 | |||
| 125 | ret = phy_read(phydev, MII_VSC8601_EPHY_CTL); | ||
| 126 | if (ret < 0) | ||
| 127 | return ret; | ||
| 128 | |||
| 129 | ret |= MII_VSC8601_EPHY_CTL_RGMII_SKEW; | ||
| 130 | return phy_write(phydev, MII_VSC8601_EPHY_CTL, ret); | ||
| 131 | } | ||
| 132 | |||
| 133 | static int vsc8601_config_init(struct phy_device *phydev) | ||
| 134 | { | ||
| 135 | int ret = 0; | ||
| 136 | |||
| 137 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) | ||
| 138 | ret = vsc8601_add_skew(phydev); | ||
| 139 | |||
| 140 | if (ret < 0) | ||
| 141 | return ret; | ||
| 142 | |||
| 143 | return genphy_config_init(phydev); | ||
| 144 | } | ||
| 145 | |||
| 114 | static int vsc824x_ack_interrupt(struct phy_device *phydev) | 146 | static int vsc824x_ack_interrupt(struct phy_device *phydev) |
| 115 | { | 147 | { |
| 116 | int err = 0; | 148 | int err = 0; |
| @@ -275,7 +307,7 @@ static struct phy_driver vsc82xx_driver[] = { | |||
| 275 | .phy_id_mask = 0x000ffff0, | 307 | .phy_id_mask = 0x000ffff0, |
| 276 | .features = PHY_GBIT_FEATURES, | 308 | .features = PHY_GBIT_FEATURES, |
| 277 | .flags = PHY_HAS_INTERRUPT, | 309 | .flags = PHY_HAS_INTERRUPT, |
| 278 | .config_init = &genphy_config_init, | 310 | .config_init = &vsc8601_config_init, |
| 279 | .config_aneg = &genphy_config_aneg, | 311 | .config_aneg = &genphy_config_aneg, |
| 280 | .read_status = &genphy_read_status, | 312 | .read_status = &genphy_read_status, |
| 281 | .ack_interrupt = &vsc824x_ack_interrupt, | 313 | .ack_interrupt = &vsc824x_ack_interrupt, |
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index fd8b1e62301f..7276d5a95bd0 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
| @@ -1497,6 +1497,11 @@ static void virtnet_free_queues(struct virtnet_info *vi) | |||
| 1497 | netif_napi_del(&vi->rq[i].napi); | 1497 | netif_napi_del(&vi->rq[i].napi); |
| 1498 | } | 1498 | } |
| 1499 | 1499 | ||
| 1500 | /* We called napi_hash_del() before netif_napi_del(), | ||
| 1501 | * we need to respect an RCU grace period before freeing vi->rq | ||
| 1502 | */ | ||
| 1503 | synchronize_net(); | ||
| 1504 | |||
| 1500 | kfree(vi->rq); | 1505 | kfree(vi->rq); |
| 1501 | kfree(vi->sq); | 1506 | kfree(vi->sq); |
| 1502 | } | 1507 | } |
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 431f13b4faf6..d3bad5779376 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
| @@ -826,7 +826,7 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw, | |||
| 826 | data->bcn_delta = do_div(delta, bcn_int); | 826 | data->bcn_delta = do_div(delta, bcn_int); |
| 827 | } else { | 827 | } else { |
| 828 | data->tsf_offset -= delta; | 828 | data->tsf_offset -= delta; |
| 829 | data->bcn_delta = -do_div(delta, bcn_int); | 829 | data->bcn_delta = -(s64)do_div(delta, bcn_int); |
| 830 | } | 830 | } |
| 831 | } | 831 | } |
| 832 | 832 | ||
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index b470f7e3521d..5a3145a02547 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
| @@ -292,6 +292,7 @@ struct phy_device *of_phy_find_device(struct device_node *phy_np) | |||
| 292 | mdiodev = to_mdio_device(d); | 292 | mdiodev = to_mdio_device(d); |
| 293 | if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) | 293 | if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) |
| 294 | return to_phy_device(d); | 294 | return to_phy_device(d); |
| 295 | put_device(d); | ||
| 295 | } | 296 | } |
| 296 | 297 | ||
| 297 | return NULL; | 298 | return NULL; |
| @@ -456,8 +457,11 @@ int of_phy_register_fixed_link(struct device_node *np) | |||
| 456 | status.link = 1; | 457 | status.link = 1; |
| 457 | status.duplex = of_property_read_bool(fixed_link_node, | 458 | status.duplex = of_property_read_bool(fixed_link_node, |
| 458 | "full-duplex"); | 459 | "full-duplex"); |
| 459 | if (of_property_read_u32(fixed_link_node, "speed", &status.speed)) | 460 | if (of_property_read_u32(fixed_link_node, "speed", |
| 461 | &status.speed)) { | ||
| 462 | of_node_put(fixed_link_node); | ||
| 460 | return -EINVAL; | 463 | return -EINVAL; |
| 464 | } | ||
| 461 | status.pause = of_property_read_bool(fixed_link_node, "pause"); | 465 | status.pause = of_property_read_bool(fixed_link_node, "pause"); |
| 462 | status.asym_pause = of_property_read_bool(fixed_link_node, | 466 | status.asym_pause = of_property_read_bool(fixed_link_node, |
| 463 | "asym-pause"); | 467 | "asym-pause"); |
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index 7035b997aaa5..6aaf425cebc3 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | * are obviously wrong for any sort of memory access. | 14 | * are obviously wrong for any sort of memory access. |
| 15 | */ | 15 | */ |
| 16 | #define BPF_REGISTER_MAX_RANGE (1024 * 1024 * 1024) | 16 | #define BPF_REGISTER_MAX_RANGE (1024 * 1024 * 1024) |
| 17 | #define BPF_REGISTER_MIN_RANGE -(1024 * 1024 * 1024) | 17 | #define BPF_REGISTER_MIN_RANGE -1 |
| 18 | 18 | ||
| 19 | struct bpf_reg_state { | 19 | struct bpf_reg_state { |
| 20 | enum bpf_reg_type type; | 20 | enum bpf_reg_type type; |
| @@ -22,7 +22,8 @@ struct bpf_reg_state { | |||
| 22 | * Used to determine if any memory access using this register will | 22 | * Used to determine if any memory access using this register will |
| 23 | * result in a bad access. | 23 | * result in a bad access. |
| 24 | */ | 24 | */ |
| 25 | u64 min_value, max_value; | 25 | s64 min_value; |
| 26 | u64 max_value; | ||
| 26 | union { | 27 | union { |
| 27 | /* valid when type == CONST_IMM | PTR_TO_STACK | UNKNOWN_VALUE */ | 28 | /* valid when type == CONST_IMM | PTR_TO_STACK | UNKNOWN_VALUE */ |
| 28 | s64 imm; | 29 | s64 imm; |
diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h index d15214d673b2..2a1abbf8da74 100644 --- a/include/net/gro_cells.h +++ b/include/net/gro_cells.h | |||
| @@ -68,6 +68,9 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de | |||
| 68 | struct gro_cell *cell = per_cpu_ptr(gcells->cells, i); | 68 | struct gro_cell *cell = per_cpu_ptr(gcells->cells, i); |
| 69 | 69 | ||
| 70 | __skb_queue_head_init(&cell->napi_skbs); | 70 | __skb_queue_head_init(&cell->napi_skbs); |
| 71 | |||
| 72 | set_bit(NAPI_STATE_NO_BUSY_POLL, &cell->napi.state); | ||
| 73 | |||
| 71 | netif_napi_add(dev, &cell->napi, gro_cell_poll, 64); | 74 | netif_napi_add(dev, &cell->napi, gro_cell_poll, 64); |
| 72 | napi_enable(&cell->napi); | 75 | napi_enable(&cell->napi); |
| 73 | } | 76 | } |
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index b9314b48e39f..f390c3bb05c5 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h | |||
| @@ -243,6 +243,7 @@ int fib_table_dump(struct fib_table *table, struct sk_buff *skb, | |||
| 243 | struct netlink_callback *cb); | 243 | struct netlink_callback *cb); |
| 244 | int fib_table_flush(struct net *net, struct fib_table *table); | 244 | int fib_table_flush(struct net *net, struct fib_table *table); |
| 245 | struct fib_table *fib_trie_unmerge(struct fib_table *main_tb); | 245 | struct fib_table *fib_trie_unmerge(struct fib_table *main_tb); |
| 246 | void fib_table_flush_external(struct fib_table *table); | ||
| 246 | void fib_free_table(struct fib_table *tb); | 247 | void fib_free_table(struct fib_table *tb); |
| 247 | 248 | ||
| 248 | #ifndef CONFIG_IP_MULTIPLE_TABLES | 249 | #ifndef CONFIG_IP_MULTIPLE_TABLES |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index fc4f757107df..0940598c002f 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
| @@ -170,7 +170,7 @@ static inline struct net *copy_net_ns(unsigned long flags, | |||
| 170 | extern struct list_head net_namespace_list; | 170 | extern struct list_head net_namespace_list; |
| 171 | 171 | ||
| 172 | struct net *get_net_ns_by_pid(pid_t pid); | 172 | struct net *get_net_ns_by_pid(pid_t pid); |
| 173 | struct net *get_net_ns_by_fd(int pid); | 173 | struct net *get_net_ns_by_fd(int fd); |
| 174 | 174 | ||
| 175 | #ifdef CONFIG_SYSCTL | 175 | #ifdef CONFIG_SYSCTL |
| 176 | void ipx_register_sysctl(void); | 176 | void ipx_register_sysctl(void); |
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 99a7e5b388f2..6a936159c6e0 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
| @@ -216,8 +216,8 @@ static void print_verifier_state(struct bpf_verifier_state *state) | |||
| 216 | reg->map_ptr->key_size, | 216 | reg->map_ptr->key_size, |
| 217 | reg->map_ptr->value_size); | 217 | reg->map_ptr->value_size); |
| 218 | if (reg->min_value != BPF_REGISTER_MIN_RANGE) | 218 | if (reg->min_value != BPF_REGISTER_MIN_RANGE) |
| 219 | verbose(",min_value=%llu", | 219 | verbose(",min_value=%lld", |
| 220 | (unsigned long long)reg->min_value); | 220 | (long long)reg->min_value); |
| 221 | if (reg->max_value != BPF_REGISTER_MAX_RANGE) | 221 | if (reg->max_value != BPF_REGISTER_MAX_RANGE) |
| 222 | verbose(",max_value=%llu", | 222 | verbose(",max_value=%llu", |
| 223 | (unsigned long long)reg->max_value); | 223 | (unsigned long long)reg->max_value); |
| @@ -758,7 +758,7 @@ static int check_mem_access(struct bpf_verifier_env *env, u32 regno, int off, | |||
| 758 | * index'es we need to make sure that whatever we use | 758 | * index'es we need to make sure that whatever we use |
| 759 | * will have a set floor within our range. | 759 | * will have a set floor within our range. |
| 760 | */ | 760 | */ |
| 761 | if ((s64)reg->min_value < 0) { | 761 | if (reg->min_value < 0) { |
| 762 | verbose("R%d min value is negative, either use unsigned index or do a if (index >=0) check.\n", | 762 | verbose("R%d min value is negative, either use unsigned index or do a if (index >=0) check.\n", |
| 763 | regno); | 763 | regno); |
| 764 | return -EACCES; | 764 | return -EACCES; |
| @@ -1468,7 +1468,8 @@ static void check_reg_overflow(struct bpf_reg_state *reg) | |||
| 1468 | { | 1468 | { |
| 1469 | if (reg->max_value > BPF_REGISTER_MAX_RANGE) | 1469 | if (reg->max_value > BPF_REGISTER_MAX_RANGE) |
| 1470 | reg->max_value = BPF_REGISTER_MAX_RANGE; | 1470 | reg->max_value = BPF_REGISTER_MAX_RANGE; |
| 1471 | if ((s64)reg->min_value < BPF_REGISTER_MIN_RANGE) | 1471 | if (reg->min_value < BPF_REGISTER_MIN_RANGE || |
| 1472 | reg->min_value > BPF_REGISTER_MAX_RANGE) | ||
| 1472 | reg->min_value = BPF_REGISTER_MIN_RANGE; | 1473 | reg->min_value = BPF_REGISTER_MIN_RANGE; |
| 1473 | } | 1474 | } |
| 1474 | 1475 | ||
| @@ -1476,7 +1477,8 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env, | |||
| 1476 | struct bpf_insn *insn) | 1477 | struct bpf_insn *insn) |
| 1477 | { | 1478 | { |
| 1478 | struct bpf_reg_state *regs = env->cur_state.regs, *dst_reg; | 1479 | struct bpf_reg_state *regs = env->cur_state.regs, *dst_reg; |
| 1479 | u64 min_val = BPF_REGISTER_MIN_RANGE, max_val = BPF_REGISTER_MAX_RANGE; | 1480 | s64 min_val = BPF_REGISTER_MIN_RANGE; |
| 1481 | u64 max_val = BPF_REGISTER_MAX_RANGE; | ||
| 1480 | bool min_set = false, max_set = false; | 1482 | bool min_set = false, max_set = false; |
| 1481 | u8 opcode = BPF_OP(insn->code); | 1483 | u8 opcode = BPF_OP(insn->code); |
| 1482 | 1484 | ||
| @@ -1512,22 +1514,43 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env, | |||
| 1512 | return; | 1514 | return; |
| 1513 | } | 1515 | } |
| 1514 | 1516 | ||
| 1517 | /* If one of our values was at the end of our ranges then we can't just | ||
| 1518 | * do our normal operations to the register, we need to set the values | ||
| 1519 | * to the min/max since they are undefined. | ||
| 1520 | */ | ||
| 1521 | if (min_val == BPF_REGISTER_MIN_RANGE) | ||
| 1522 | dst_reg->min_value = BPF_REGISTER_MIN_RANGE; | ||
| 1523 | if (max_val == BPF_REGISTER_MAX_RANGE) | ||
| 1524 | dst_reg->max_value = BPF_REGISTER_MAX_RANGE; | ||
| 1525 | |||
| 1515 | switch (opcode) { | 1526 | switch (opcode) { |
| 1516 | case BPF_ADD: | 1527 | case BPF_ADD: |
| 1517 | dst_reg->min_value += min_val; | 1528 | if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE) |
| 1518 | dst_reg->max_value += max_val; | 1529 | dst_reg->min_value += min_val; |
| 1530 | if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE) | ||
| 1531 | dst_reg->max_value += max_val; | ||
| 1519 | break; | 1532 | break; |
| 1520 | case BPF_SUB: | 1533 | case BPF_SUB: |
| 1521 | dst_reg->min_value -= min_val; | 1534 | if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE) |
| 1522 | dst_reg->max_value -= max_val; | 1535 | dst_reg->min_value -= min_val; |
| 1536 | if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE) | ||
| 1537 | dst_reg->max_value -= max_val; | ||
| 1523 | break; | 1538 | break; |
| 1524 | case BPF_MUL: | 1539 | case BPF_MUL: |
| 1525 | dst_reg->min_value *= min_val; | 1540 | if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE) |
| 1526 | dst_reg->max_value *= max_val; | 1541 | dst_reg->min_value *= min_val; |
| 1542 | if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE) | ||
| 1543 | dst_reg->max_value *= max_val; | ||
| 1527 | break; | 1544 | break; |
| 1528 | case BPF_AND: | 1545 | case BPF_AND: |
| 1529 | /* & is special since it could end up with 0 bits set. */ | 1546 | /* Disallow AND'ing of negative numbers, ain't nobody got time |
| 1530 | dst_reg->min_value &= min_val; | 1547 | * for that. Otherwise the minimum is 0 and the max is the max |
| 1548 | * value we could AND against. | ||
| 1549 | */ | ||
| 1550 | if (min_val < 0) | ||
| 1551 | dst_reg->min_value = BPF_REGISTER_MIN_RANGE; | ||
| 1552 | else | ||
| 1553 | dst_reg->min_value = 0; | ||
| 1531 | dst_reg->max_value = max_val; | 1554 | dst_reg->max_value = max_val; |
| 1532 | break; | 1555 | break; |
| 1533 | case BPF_LSH: | 1556 | case BPF_LSH: |
| @@ -1537,24 +1560,25 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env, | |||
| 1537 | */ | 1560 | */ |
| 1538 | if (min_val > ilog2(BPF_REGISTER_MAX_RANGE)) | 1561 | if (min_val > ilog2(BPF_REGISTER_MAX_RANGE)) |
| 1539 | dst_reg->min_value = BPF_REGISTER_MIN_RANGE; | 1562 | dst_reg->min_value = BPF_REGISTER_MIN_RANGE; |
| 1540 | else | 1563 | else if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE) |
| 1541 | dst_reg->min_value <<= min_val; | 1564 | dst_reg->min_value <<= min_val; |
| 1542 | 1565 | ||
| 1543 | if (max_val > ilog2(BPF_REGISTER_MAX_RANGE)) | 1566 | if (max_val > ilog2(BPF_REGISTER_MAX_RANGE)) |
| 1544 | dst_reg->max_value = BPF_REGISTER_MAX_RANGE; | 1567 | dst_reg->max_value = BPF_REGISTER_MAX_RANGE; |
| 1545 | else | 1568 | else if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE) |
| 1546 | dst_reg->max_value <<= max_val; | 1569 | dst_reg->max_value <<= max_val; |
| 1547 | break; | 1570 | break; |
| 1548 | case BPF_RSH: | 1571 | case BPF_RSH: |
| 1549 | dst_reg->min_value >>= min_val; | 1572 | /* RSH by a negative number is undefined, and the BPF_RSH is an |
| 1550 | dst_reg->max_value >>= max_val; | 1573 | * unsigned shift, so make the appropriate casts. |
| 1551 | break; | ||
| 1552 | case BPF_MOD: | ||
| 1553 | /* % is special since it is an unsigned modulus, so the floor | ||
| 1554 | * will always be 0. | ||
| 1555 | */ | 1574 | */ |
| 1556 | dst_reg->min_value = 0; | 1575 | if (min_val < 0 || dst_reg->min_value < 0) |
| 1557 | dst_reg->max_value = max_val - 1; | 1576 | dst_reg->min_value = BPF_REGISTER_MIN_RANGE; |
| 1577 | else | ||
| 1578 | dst_reg->min_value = | ||
| 1579 | (u64)(dst_reg->min_value) >> min_val; | ||
| 1580 | if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE) | ||
| 1581 | dst_reg->max_value >>= max_val; | ||
| 1558 | break; | 1582 | break; |
| 1559 | default: | 1583 | default: |
| 1560 | reset_reg_range_values(regs, insn->dst_reg); | 1584 | reset_reg_range_values(regs, insn->dst_reg); |
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index e034afbd1bb0..08ce36147c4c 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
| @@ -652,6 +652,7 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, | |||
| 652 | batadv_softif_destroy_sysfs(hard_iface->soft_iface); | 652 | batadv_softif_destroy_sysfs(hard_iface->soft_iface); |
| 653 | } | 653 | } |
| 654 | 654 | ||
| 655 | hard_iface->soft_iface = NULL; | ||
| 655 | batadv_hardif_put(hard_iface); | 656 | batadv_hardif_put(hard_iface); |
| 656 | 657 | ||
| 657 | out: | 658 | out: |
diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index 2333777f919d..8af1611b8ab2 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c | |||
| @@ -837,6 +837,7 @@ static int batadv_tp_send(void *arg) | |||
| 837 | primary_if = batadv_primary_if_get_selected(bat_priv); | 837 | primary_if = batadv_primary_if_get_selected(bat_priv); |
| 838 | if (unlikely(!primary_if)) { | 838 | if (unlikely(!primary_if)) { |
| 839 | err = BATADV_TP_REASON_DST_UNREACHABLE; | 839 | err = BATADV_TP_REASON_DST_UNREACHABLE; |
| 840 | tp_vars->reason = err; | ||
| 840 | goto out; | 841 | goto out; |
| 841 | } | 842 | } |
| 842 | 843 | ||
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index f61c0e02a413..7001da910c6b 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
| @@ -219,6 +219,8 @@ int peernet2id_alloc(struct net *net, struct net *peer) | |||
| 219 | bool alloc; | 219 | bool alloc; |
| 220 | int id; | 220 | int id; |
| 221 | 221 | ||
| 222 | if (atomic_read(&net->count) == 0) | ||
| 223 | return NETNSA_NSID_NOT_ASSIGNED; | ||
| 222 | spin_lock_irqsave(&net->nsid_lock, flags); | 224 | spin_lock_irqsave(&net->nsid_lock, flags); |
| 223 | alloc = atomic_read(&peer->count) == 0 ? false : true; | 225 | alloc = atomic_read(&peer->count) == 0 ? false : true; |
| 224 | id = __peernet2id_alloc(net, peer, &alloc); | 226 | id = __peernet2id_alloc(net, peer, &alloc); |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index db313ec7af32..a99917b5de33 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
| @@ -840,18 +840,20 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev, | |||
| 840 | if (dev->dev.parent && dev_is_pci(dev->dev.parent) && | 840 | if (dev->dev.parent && dev_is_pci(dev->dev.parent) && |
| 841 | (ext_filter_mask & RTEXT_FILTER_VF)) { | 841 | (ext_filter_mask & RTEXT_FILTER_VF)) { |
| 842 | int num_vfs = dev_num_vf(dev->dev.parent); | 842 | int num_vfs = dev_num_vf(dev->dev.parent); |
| 843 | size_t size = nla_total_size(sizeof(struct nlattr)); | 843 | size_t size = nla_total_size(0); |
| 844 | size += nla_total_size(num_vfs * sizeof(struct nlattr)); | ||
| 845 | size += num_vfs * | 844 | size += num_vfs * |
| 846 | (nla_total_size(sizeof(struct ifla_vf_mac)) + | 845 | (nla_total_size(0) + |
| 847 | nla_total_size(MAX_VLAN_LIST_LEN * | 846 | nla_total_size(sizeof(struct ifla_vf_mac)) + |
| 848 | sizeof(struct nlattr)) + | 847 | nla_total_size(sizeof(struct ifla_vf_vlan)) + |
| 848 | nla_total_size(0) + /* nest IFLA_VF_VLAN_LIST */ | ||
| 849 | nla_total_size(MAX_VLAN_LIST_LEN * | 849 | nla_total_size(MAX_VLAN_LIST_LEN * |
| 850 | sizeof(struct ifla_vf_vlan_info)) + | 850 | sizeof(struct ifla_vf_vlan_info)) + |
| 851 | nla_total_size(sizeof(struct ifla_vf_spoofchk)) + | 851 | nla_total_size(sizeof(struct ifla_vf_spoofchk)) + |
| 852 | nla_total_size(sizeof(struct ifla_vf_tx_rate)) + | ||
| 852 | nla_total_size(sizeof(struct ifla_vf_rate)) + | 853 | nla_total_size(sizeof(struct ifla_vf_rate)) + |
| 853 | nla_total_size(sizeof(struct ifla_vf_link_state)) + | 854 | nla_total_size(sizeof(struct ifla_vf_link_state)) + |
| 854 | nla_total_size(sizeof(struct ifla_vf_rss_query_en)) + | 855 | nla_total_size(sizeof(struct ifla_vf_rss_query_en)) + |
| 856 | nla_total_size(0) + /* nest IFLA_VF_STATS */ | ||
| 855 | /* IFLA_VF_STATS_RX_PACKETS */ | 857 | /* IFLA_VF_STATS_RX_PACKETS */ |
| 856 | nla_total_size_64bit(sizeof(__u64)) + | 858 | nla_total_size_64bit(sizeof(__u64)) + |
| 857 | /* IFLA_VF_STATS_TX_PACKETS */ | 859 | /* IFLA_VF_STATS_TX_PACKETS */ |
| @@ -899,7 +901,8 @@ static size_t rtnl_port_size(const struct net_device *dev, | |||
| 899 | 901 | ||
| 900 | static size_t rtnl_xdp_size(const struct net_device *dev) | 902 | static size_t rtnl_xdp_size(const struct net_device *dev) |
| 901 | { | 903 | { |
| 902 | size_t xdp_size = nla_total_size(1); /* XDP_ATTACHED */ | 904 | size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP */ |
| 905 | nla_total_size(1); /* XDP_ATTACHED */ | ||
| 903 | 906 | ||
| 904 | if (!dev->netdev_ops->ndo_xdp) | 907 | if (!dev->netdev_ops->ndo_xdp) |
| 905 | return 0; | 908 | return 0; |
| @@ -1606,7 +1609,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | |||
| 1606 | head = &net->dev_index_head[h]; | 1609 | head = &net->dev_index_head[h]; |
| 1607 | hlist_for_each_entry(dev, head, index_hlist) { | 1610 | hlist_for_each_entry(dev, head, index_hlist) { |
| 1608 | if (link_dump_filtered(dev, master_idx, kind_ops)) | 1611 | if (link_dump_filtered(dev, master_idx, kind_ops)) |
| 1609 | continue; | 1612 | goto cont; |
| 1610 | if (idx < s_idx) | 1613 | if (idx < s_idx) |
| 1611 | goto cont; | 1614 | goto cont; |
| 1612 | err = rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, | 1615 | err = rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, |
| @@ -2849,7 +2852,10 @@ nla_put_failure: | |||
| 2849 | 2852 | ||
| 2850 | static inline size_t rtnl_fdb_nlmsg_size(void) | 2853 | static inline size_t rtnl_fdb_nlmsg_size(void) |
| 2851 | { | 2854 | { |
| 2852 | return NLMSG_ALIGN(sizeof(struct ndmsg)) + nla_total_size(ETH_ALEN); | 2855 | return NLMSG_ALIGN(sizeof(struct ndmsg)) + |
| 2856 | nla_total_size(ETH_ALEN) + /* NDA_LLADDR */ | ||
| 2857 | nla_total_size(sizeof(u16)) + /* NDA_VLAN */ | ||
| 2858 | 0; | ||
| 2853 | } | 2859 | } |
| 2854 | 2860 | ||
| 2855 | static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type, | 2861 | static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type, |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index c3b80478226e..161fc0f0d752 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
| @@ -151,7 +151,7 @@ static void fib_replace_table(struct net *net, struct fib_table *old, | |||
| 151 | 151 | ||
| 152 | int fib_unmerge(struct net *net) | 152 | int fib_unmerge(struct net *net) |
| 153 | { | 153 | { |
| 154 | struct fib_table *old, *new; | 154 | struct fib_table *old, *new, *main_table; |
| 155 | 155 | ||
| 156 | /* attempt to fetch local table if it has been allocated */ | 156 | /* attempt to fetch local table if it has been allocated */ |
| 157 | old = fib_get_table(net, RT_TABLE_LOCAL); | 157 | old = fib_get_table(net, RT_TABLE_LOCAL); |
| @@ -162,11 +162,21 @@ int fib_unmerge(struct net *net) | |||
| 162 | if (!new) | 162 | if (!new) |
| 163 | return -ENOMEM; | 163 | return -ENOMEM; |
| 164 | 164 | ||
| 165 | /* table is already unmerged */ | ||
| 166 | if (new == old) | ||
| 167 | return 0; | ||
| 168 | |||
| 165 | /* replace merged table with clean table */ | 169 | /* replace merged table with clean table */ |
| 166 | if (new != old) { | 170 | fib_replace_table(net, old, new); |
| 167 | fib_replace_table(net, old, new); | 171 | fib_free_table(old); |
| 168 | fib_free_table(old); | 172 | |
| 169 | } | 173 | /* attempt to fetch main table if it has been allocated */ |
| 174 | main_table = fib_get_table(net, RT_TABLE_MAIN); | ||
| 175 | if (!main_table) | ||
| 176 | return 0; | ||
| 177 | |||
| 178 | /* flush local entries from main table */ | ||
| 179 | fib_table_flush_external(main_table); | ||
| 170 | 180 | ||
| 171 | return 0; | 181 | return 0; |
| 172 | } | 182 | } |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 4cff74d4133f..026f309c51e9 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
| @@ -1743,8 +1743,10 @@ struct fib_table *fib_trie_unmerge(struct fib_table *oldtb) | |||
| 1743 | local_l = fib_find_node(lt, &local_tp, l->key); | 1743 | local_l = fib_find_node(lt, &local_tp, l->key); |
| 1744 | 1744 | ||
| 1745 | if (fib_insert_alias(lt, local_tp, local_l, new_fa, | 1745 | if (fib_insert_alias(lt, local_tp, local_l, new_fa, |
| 1746 | NULL, l->key)) | 1746 | NULL, l->key)) { |
| 1747 | kmem_cache_free(fn_alias_kmem, new_fa); | ||
| 1747 | goto out; | 1748 | goto out; |
| 1749 | } | ||
| 1748 | } | 1750 | } |
| 1749 | 1751 | ||
| 1750 | /* stop loop if key wrapped back to 0 */ | 1752 | /* stop loop if key wrapped back to 0 */ |
| @@ -1760,6 +1762,71 @@ out: | |||
| 1760 | return NULL; | 1762 | return NULL; |
| 1761 | } | 1763 | } |
| 1762 | 1764 | ||
| 1765 | /* Caller must hold RTNL */ | ||
| 1766 | void fib_table_flush_external(struct fib_table *tb) | ||
| 1767 | { | ||
| 1768 | struct trie *t = (struct trie *)tb->tb_data; | ||
| 1769 | struct key_vector *pn = t->kv; | ||
| 1770 | unsigned long cindex = 1; | ||
| 1771 | struct hlist_node *tmp; | ||
| 1772 | struct fib_alias *fa; | ||
| 1773 | |||
| 1774 | /* walk trie in reverse order */ | ||
| 1775 | for (;;) { | ||
| 1776 | unsigned char slen = 0; | ||
| 1777 | struct key_vector *n; | ||
| 1778 | |||
| 1779 | if (!(cindex--)) { | ||
| 1780 | t_key pkey = pn->key; | ||
| 1781 | |||
| 1782 | /* cannot resize the trie vector */ | ||
| 1783 | if (IS_TRIE(pn)) | ||
| 1784 | break; | ||
| 1785 | |||
| 1786 | /* resize completed node */ | ||
| 1787 | pn = resize(t, pn); | ||
| 1788 | cindex = get_index(pkey, pn); | ||
| 1789 | |||
| 1790 | continue; | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | /* grab the next available node */ | ||
| 1794 | n = get_child(pn, cindex); | ||
| 1795 | if (!n) | ||
| 1796 | continue; | ||
| 1797 | |||
| 1798 | if (IS_TNODE(n)) { | ||
| 1799 | /* record pn and cindex for leaf walking */ | ||
| 1800 | pn = n; | ||
| 1801 | cindex = 1ul << n->bits; | ||
| 1802 | |||
| 1803 | continue; | ||
| 1804 | } | ||
| 1805 | |||
| 1806 | hlist_for_each_entry_safe(fa, tmp, &n->leaf, fa_list) { | ||
| 1807 | /* if alias was cloned to local then we just | ||
| 1808 | * need to remove the local copy from main | ||
| 1809 | */ | ||
| 1810 | if (tb->tb_id != fa->tb_id) { | ||
| 1811 | hlist_del_rcu(&fa->fa_list); | ||
| 1812 | alias_free_mem_rcu(fa); | ||
| 1813 | continue; | ||
| 1814 | } | ||
| 1815 | |||
| 1816 | /* record local slen */ | ||
| 1817 | slen = fa->fa_slen; | ||
| 1818 | } | ||
| 1819 | |||
| 1820 | /* update leaf slen */ | ||
| 1821 | n->slen = slen; | ||
| 1822 | |||
| 1823 | if (hlist_empty(&n->leaf)) { | ||
| 1824 | put_child_root(pn, n->key, NULL); | ||
| 1825 | node_free(n); | ||
| 1826 | } | ||
| 1827 | } | ||
| 1828 | } | ||
| 1829 | |||
| 1763 | /* Caller must hold RTNL. */ | 1830 | /* Caller must hold RTNL. */ |
| 1764 | int fib_table_flush(struct net *net, struct fib_table *tb) | 1831 | int fib_table_flush(struct net *net, struct fib_table *tb) |
| 1765 | { | 1832 | { |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 606cc3e85d2b..15db786d50ed 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
| @@ -162,7 +162,7 @@ static int unsolicited_report_interval(struct in_device *in_dev) | |||
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im); | 164 | static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im); |
| 165 | static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr); | 165 | static void igmpv3_del_delrec(struct in_device *in_dev, struct ip_mc_list *im); |
| 166 | static void igmpv3_clear_delrec(struct in_device *in_dev); | 166 | static void igmpv3_clear_delrec(struct in_device *in_dev); |
| 167 | static int sf_setstate(struct ip_mc_list *pmc); | 167 | static int sf_setstate(struct ip_mc_list *pmc); |
| 168 | static void sf_markstate(struct ip_mc_list *pmc); | 168 | static void sf_markstate(struct ip_mc_list *pmc); |
| @@ -1130,10 +1130,15 @@ static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im) | |||
| 1130 | spin_unlock_bh(&in_dev->mc_tomb_lock); | 1130 | spin_unlock_bh(&in_dev->mc_tomb_lock); |
| 1131 | } | 1131 | } |
| 1132 | 1132 | ||
| 1133 | static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr) | 1133 | /* |
| 1134 | * restore ip_mc_list deleted records | ||
| 1135 | */ | ||
| 1136 | static void igmpv3_del_delrec(struct in_device *in_dev, struct ip_mc_list *im) | ||
| 1134 | { | 1137 | { |
| 1135 | struct ip_mc_list *pmc, *pmc_prev; | 1138 | struct ip_mc_list *pmc, *pmc_prev; |
| 1136 | struct ip_sf_list *psf, *psf_next; | 1139 | struct ip_sf_list *psf; |
| 1140 | struct net *net = dev_net(in_dev->dev); | ||
| 1141 | __be32 multiaddr = im->multiaddr; | ||
| 1137 | 1142 | ||
| 1138 | spin_lock_bh(&in_dev->mc_tomb_lock); | 1143 | spin_lock_bh(&in_dev->mc_tomb_lock); |
| 1139 | pmc_prev = NULL; | 1144 | pmc_prev = NULL; |
| @@ -1149,16 +1154,26 @@ static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr) | |||
| 1149 | in_dev->mc_tomb = pmc->next; | 1154 | in_dev->mc_tomb = pmc->next; |
| 1150 | } | 1155 | } |
| 1151 | spin_unlock_bh(&in_dev->mc_tomb_lock); | 1156 | spin_unlock_bh(&in_dev->mc_tomb_lock); |
| 1157 | |||
| 1158 | spin_lock_bh(&im->lock); | ||
| 1152 | if (pmc) { | 1159 | if (pmc) { |
| 1153 | for (psf = pmc->tomb; psf; psf = psf_next) { | 1160 | im->interface = pmc->interface; |
| 1154 | psf_next = psf->sf_next; | 1161 | im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; |
| 1155 | kfree(psf); | 1162 | im->sfmode = pmc->sfmode; |
| 1163 | if (pmc->sfmode == MCAST_INCLUDE) { | ||
| 1164 | im->tomb = pmc->tomb; | ||
| 1165 | im->sources = pmc->sources; | ||
| 1166 | for (psf = im->sources; psf; psf = psf->sf_next) | ||
| 1167 | psf->sf_crcount = im->crcount; | ||
| 1156 | } | 1168 | } |
| 1157 | in_dev_put(pmc->interface); | 1169 | in_dev_put(pmc->interface); |
| 1158 | kfree(pmc); | ||
| 1159 | } | 1170 | } |
| 1171 | spin_unlock_bh(&im->lock); | ||
| 1160 | } | 1172 | } |
| 1161 | 1173 | ||
| 1174 | /* | ||
| 1175 | * flush ip_mc_list deleted records | ||
| 1176 | */ | ||
| 1162 | static void igmpv3_clear_delrec(struct in_device *in_dev) | 1177 | static void igmpv3_clear_delrec(struct in_device *in_dev) |
| 1163 | { | 1178 | { |
| 1164 | struct ip_mc_list *pmc, *nextpmc; | 1179 | struct ip_mc_list *pmc, *nextpmc; |
| @@ -1366,7 +1381,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) | |||
| 1366 | ip_mc_hash_add(in_dev, im); | 1381 | ip_mc_hash_add(in_dev, im); |
| 1367 | 1382 | ||
| 1368 | #ifdef CONFIG_IP_MULTICAST | 1383 | #ifdef CONFIG_IP_MULTICAST |
| 1369 | igmpv3_del_delrec(in_dev, im->multiaddr); | 1384 | igmpv3_del_delrec(in_dev, im); |
| 1370 | #endif | 1385 | #endif |
| 1371 | igmp_group_added(im); | 1386 | igmp_group_added(im); |
| 1372 | if (!in_dev->dead) | 1387 | if (!in_dev->dead) |
| @@ -1626,8 +1641,12 @@ void ip_mc_remap(struct in_device *in_dev) | |||
| 1626 | 1641 | ||
| 1627 | ASSERT_RTNL(); | 1642 | ASSERT_RTNL(); |
| 1628 | 1643 | ||
| 1629 | for_each_pmc_rtnl(in_dev, pmc) | 1644 | for_each_pmc_rtnl(in_dev, pmc) { |
| 1645 | #ifdef CONFIG_IP_MULTICAST | ||
| 1646 | igmpv3_del_delrec(in_dev, pmc); | ||
| 1647 | #endif | ||
| 1630 | igmp_group_added(pmc); | 1648 | igmp_group_added(pmc); |
| 1649 | } | ||
| 1631 | } | 1650 | } |
| 1632 | 1651 | ||
| 1633 | /* Device going down */ | 1652 | /* Device going down */ |
| @@ -1648,7 +1667,6 @@ void ip_mc_down(struct in_device *in_dev) | |||
| 1648 | in_dev->mr_gq_running = 0; | 1667 | in_dev->mr_gq_running = 0; |
| 1649 | if (del_timer(&in_dev->mr_gq_timer)) | 1668 | if (del_timer(&in_dev->mr_gq_timer)) |
| 1650 | __in_dev_put(in_dev); | 1669 | __in_dev_put(in_dev); |
| 1651 | igmpv3_clear_delrec(in_dev); | ||
| 1652 | #endif | 1670 | #endif |
| 1653 | 1671 | ||
| 1654 | ip_mc_dec_group(in_dev, IGMP_ALL_HOSTS); | 1672 | ip_mc_dec_group(in_dev, IGMP_ALL_HOSTS); |
| @@ -1688,8 +1706,12 @@ void ip_mc_up(struct in_device *in_dev) | |||
| 1688 | #endif | 1706 | #endif |
| 1689 | ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); | 1707 | ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); |
| 1690 | 1708 | ||
| 1691 | for_each_pmc_rtnl(in_dev, pmc) | 1709 | for_each_pmc_rtnl(in_dev, pmc) { |
| 1710 | #ifdef CONFIG_IP_MULTICAST | ||
| 1711 | igmpv3_del_delrec(in_dev, pmc); | ||
| 1712 | #endif | ||
| 1692 | igmp_group_added(pmc); | 1713 | igmp_group_added(pmc); |
| 1714 | } | ||
| 1693 | } | 1715 | } |
| 1694 | 1716 | ||
| 1695 | /* | 1717 | /* |
| @@ -1704,13 +1726,13 @@ void ip_mc_destroy_dev(struct in_device *in_dev) | |||
| 1704 | 1726 | ||
| 1705 | /* Deactivate timers */ | 1727 | /* Deactivate timers */ |
| 1706 | ip_mc_down(in_dev); | 1728 | ip_mc_down(in_dev); |
| 1729 | #ifdef CONFIG_IP_MULTICAST | ||
| 1730 | igmpv3_clear_delrec(in_dev); | ||
| 1731 | #endif | ||
| 1707 | 1732 | ||
| 1708 | while ((i = rtnl_dereference(in_dev->mc_list)) != NULL) { | 1733 | while ((i = rtnl_dereference(in_dev->mc_list)) != NULL) { |
| 1709 | in_dev->mc_list = i->next_rcu; | 1734 | in_dev->mc_list = i->next_rcu; |
| 1710 | in_dev->mc_count--; | 1735 | in_dev->mc_count--; |
| 1711 | |||
| 1712 | /* We've dropped the groups in ip_mc_down already */ | ||
| 1713 | ip_mc_clear_src(i); | ||
| 1714 | ip_ma_put(i); | 1736 | ip_ma_put(i); |
| 1715 | } | 1737 | } |
| 1716 | } | 1738 | } |
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index 1294af4e0127..f9038d6b109e 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c | |||
| @@ -200,8 +200,10 @@ static void tcp_reinit_congestion_control(struct sock *sk, | |||
| 200 | icsk->icsk_ca_ops = ca; | 200 | icsk->icsk_ca_ops = ca; |
| 201 | icsk->icsk_ca_setsockopt = 1; | 201 | icsk->icsk_ca_setsockopt = 1; |
| 202 | 202 | ||
| 203 | if (sk->sk_state != TCP_CLOSE) | 203 | if (sk->sk_state != TCP_CLOSE) { |
| 204 | memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv)); | ||
| 204 | tcp_init_congestion_control(sk); | 205 | tcp_init_congestion_control(sk); |
| 206 | } | ||
| 205 | } | 207 | } |
| 206 | 208 | ||
| 207 | /* Manage refcounts on socket close. */ | 209 | /* Manage refcounts on socket close. */ |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index d123d68f4d1d..0de9d5d2b9ae 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -1652,10 +1652,10 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb, | |||
| 1652 | 1652 | ||
| 1653 | if (use_hash2) { | 1653 | if (use_hash2) { |
| 1654 | hash2_any = udp4_portaddr_hash(net, htonl(INADDR_ANY), hnum) & | 1654 | hash2_any = udp4_portaddr_hash(net, htonl(INADDR_ANY), hnum) & |
| 1655 | udp_table.mask; | 1655 | udptable->mask; |
| 1656 | hash2 = udp4_portaddr_hash(net, daddr, hnum) & udp_table.mask; | 1656 | hash2 = udp4_portaddr_hash(net, daddr, hnum) & udptable->mask; |
| 1657 | start_lookup: | 1657 | start_lookup: |
| 1658 | hslot = &udp_table.hash2[hash2]; | 1658 | hslot = &udptable->hash2[hash2]; |
| 1659 | offset = offsetof(typeof(*sk), __sk_common.skc_portaddr_node); | 1659 | offset = offsetof(typeof(*sk), __sk_common.skc_portaddr_node); |
| 1660 | } | 1660 | } |
| 1661 | 1661 | ||
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 87784560dc46..0a4759b89da2 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
| @@ -1034,6 +1034,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield, | |||
| 1034 | int mtu; | 1034 | int mtu; |
| 1035 | unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen; | 1035 | unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen; |
| 1036 | unsigned int max_headroom = psh_hlen; | 1036 | unsigned int max_headroom = psh_hlen; |
| 1037 | bool use_cache = false; | ||
| 1037 | u8 hop_limit; | 1038 | u8 hop_limit; |
| 1038 | int err = -1; | 1039 | int err = -1; |
| 1039 | 1040 | ||
| @@ -1066,7 +1067,15 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield, | |||
| 1066 | 1067 | ||
| 1067 | memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr)); | 1068 | memcpy(&fl6->daddr, addr6, sizeof(fl6->daddr)); |
| 1068 | neigh_release(neigh); | 1069 | neigh_release(neigh); |
| 1069 | } else if (!fl6->flowi6_mark) | 1070 | } else if (!(t->parms.flags & |
| 1071 | (IP6_TNL_F_USE_ORIG_TCLASS | IP6_TNL_F_USE_ORIG_FWMARK))) { | ||
| 1072 | /* enable the cache only only if the routing decision does | ||
| 1073 | * not depend on the current inner header value | ||
| 1074 | */ | ||
| 1075 | use_cache = true; | ||
| 1076 | } | ||
| 1077 | |||
| 1078 | if (use_cache) | ||
| 1070 | dst = dst_cache_get(&t->dst_cache); | 1079 | dst = dst_cache_get(&t->dst_cache); |
| 1071 | 1080 | ||
| 1072 | if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr)) | 1081 | if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr)) |
| @@ -1150,7 +1159,7 @@ route_lookup: | |||
| 1150 | if (t->encap.type != TUNNEL_ENCAP_NONE) | 1159 | if (t->encap.type != TUNNEL_ENCAP_NONE) |
| 1151 | goto tx_err_dst_release; | 1160 | goto tx_err_dst_release; |
| 1152 | } else { | 1161 | } else { |
| 1153 | if (!fl6->flowi6_mark && ndst) | 1162 | if (use_cache && ndst) |
| 1154 | dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr); | 1163 | dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr); |
| 1155 | } | 1164 | } |
| 1156 | skb_dst_set(skb, dst); | 1165 | skb_dst_set(skb, dst); |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index b2ef061e6836..e5056d4873d1 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
| @@ -706,10 +706,10 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb, | |||
| 706 | 706 | ||
| 707 | if (use_hash2) { | 707 | if (use_hash2) { |
| 708 | hash2_any = udp6_portaddr_hash(net, &in6addr_any, hnum) & | 708 | hash2_any = udp6_portaddr_hash(net, &in6addr_any, hnum) & |
| 709 | udp_table.mask; | 709 | udptable->mask; |
| 710 | hash2 = udp6_portaddr_hash(net, daddr, hnum) & udp_table.mask; | 710 | hash2 = udp6_portaddr_hash(net, daddr, hnum) & udptable->mask; |
| 711 | start_lookup: | 711 | start_lookup: |
| 712 | hslot = &udp_table.hash2[hash2]; | 712 | hslot = &udptable->hash2[hash2]; |
| 713 | offset = offsetof(typeof(*sk), __sk_common.skc_portaddr_node); | 713 | offset = offsetof(typeof(*sk), __sk_common.skc_portaddr_node); |
| 714 | } | 714 | } |
| 715 | 715 | ||
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c index 965f7e344cef..3dc97b4f982b 100644 --- a/net/l2tp/l2tp_eth.c +++ b/net/l2tp/l2tp_eth.c | |||
| @@ -97,7 +97,7 @@ static int l2tp_eth_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 97 | unsigned int len = skb->len; | 97 | unsigned int len = skb->len; |
| 98 | int ret = l2tp_xmit_skb(session, skb, session->hdr_len); | 98 | int ret = l2tp_xmit_skb(session, skb, session->hdr_len); |
| 99 | 99 | ||
| 100 | if (likely(ret == NET_XMIT_SUCCESS)) { | 100 | if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) { |
| 101 | atomic_long_add(len, &priv->tx_bytes); | 101 | atomic_long_add(len, &priv->tx_bytes); |
| 102 | atomic_long_inc(&priv->tx_packets); | 102 | atomic_long_inc(&priv->tx_packets); |
| 103 | } else { | 103 | } else { |
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index fce25afb652a..982f6c44ea01 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c | |||
| @@ -251,8 +251,6 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
| 251 | int ret; | 251 | int ret; |
| 252 | int chk_addr_ret; | 252 | int chk_addr_ret; |
| 253 | 253 | ||
| 254 | if (!sock_flag(sk, SOCK_ZAPPED)) | ||
| 255 | return -EINVAL; | ||
| 256 | if (addr_len < sizeof(struct sockaddr_l2tpip)) | 254 | if (addr_len < sizeof(struct sockaddr_l2tpip)) |
| 257 | return -EINVAL; | 255 | return -EINVAL; |
| 258 | if (addr->l2tp_family != AF_INET) | 256 | if (addr->l2tp_family != AF_INET) |
| @@ -267,6 +265,9 @@ static int l2tp_ip_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
| 267 | read_unlock_bh(&l2tp_ip_lock); | 265 | read_unlock_bh(&l2tp_ip_lock); |
| 268 | 266 | ||
| 269 | lock_sock(sk); | 267 | lock_sock(sk); |
| 268 | if (!sock_flag(sk, SOCK_ZAPPED)) | ||
| 269 | goto out; | ||
| 270 | |||
| 270 | if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_l2tpip)) | 271 | if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_l2tpip)) |
| 271 | goto out; | 272 | goto out; |
| 272 | 273 | ||
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index ad3468c32b53..9978d01ba0ba 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c | |||
| @@ -269,8 +269,6 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
| 269 | int addr_type; | 269 | int addr_type; |
| 270 | int err; | 270 | int err; |
| 271 | 271 | ||
| 272 | if (!sock_flag(sk, SOCK_ZAPPED)) | ||
| 273 | return -EINVAL; | ||
| 274 | if (addr->l2tp_family != AF_INET6) | 272 | if (addr->l2tp_family != AF_INET6) |
| 275 | return -EINVAL; | 273 | return -EINVAL; |
| 276 | if (addr_len < sizeof(*addr)) | 274 | if (addr_len < sizeof(*addr)) |
| @@ -296,6 +294,9 @@ static int l2tp_ip6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
| 296 | lock_sock(sk); | 294 | lock_sock(sk); |
| 297 | 295 | ||
| 298 | err = -EINVAL; | 296 | err = -EINVAL; |
| 297 | if (!sock_flag(sk, SOCK_ZAPPED)) | ||
| 298 | goto out_unlock; | ||
| 299 | |||
| 299 | if (sk->sk_state != TCP_CLOSE) | 300 | if (sk->sk_state != TCP_CLOSE) |
| 300 | goto out_unlock; | 301 | goto out_unlock; |
| 301 | 302 | ||
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 78e9ecbc96e6..8e05032689f0 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c | |||
| @@ -688,7 +688,7 @@ static void __sta_info_recalc_tim(struct sta_info *sta, bool ignore_pending) | |||
| 688 | } | 688 | } |
| 689 | 689 | ||
| 690 | /* No need to do anything if the driver does all */ | 690 | /* No need to do anything if the driver does all */ |
| 691 | if (!local->ops->set_tim) | 691 | if (ieee80211_hw_check(&local->hw, AP_LINK_PS)) |
| 692 | return; | 692 | return; |
| 693 | 693 | ||
| 694 | if (sta->dead) | 694 | if (sta->dead) |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 1c56abc49627..bd5f4be89435 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
| @@ -1501,7 +1501,6 @@ static bool ieee80211_queue_skb(struct ieee80211_local *local, | |||
| 1501 | struct sta_info *sta, | 1501 | struct sta_info *sta, |
| 1502 | struct sk_buff *skb) | 1502 | struct sk_buff *skb) |
| 1503 | { | 1503 | { |
| 1504 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
| 1505 | struct fq *fq = &local->fq; | 1504 | struct fq *fq = &local->fq; |
| 1506 | struct ieee80211_vif *vif; | 1505 | struct ieee80211_vif *vif; |
| 1507 | struct txq_info *txqi; | 1506 | struct txq_info *txqi; |
| @@ -1526,8 +1525,6 @@ static bool ieee80211_queue_skb(struct ieee80211_local *local, | |||
| 1526 | if (!txqi) | 1525 | if (!txqi) |
| 1527 | return false; | 1526 | return false; |
| 1528 | 1527 | ||
| 1529 | info->control.vif = vif; | ||
| 1530 | |||
| 1531 | spin_lock_bh(&fq->lock); | 1528 | spin_lock_bh(&fq->lock); |
| 1532 | ieee80211_txq_enqueue(local, txqi, skb); | 1529 | ieee80211_txq_enqueue(local, txqi, skb); |
| 1533 | spin_unlock_bh(&fq->lock); | 1530 | spin_unlock_bh(&fq->lock); |
| @@ -3213,7 +3210,6 @@ static void ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata, | |||
| 3213 | 3210 | ||
| 3214 | if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { | 3211 | if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { |
| 3215 | tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; | 3212 | tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; |
| 3216 | *ieee80211_get_qos_ctl(hdr) = tid; | ||
| 3217 | hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); | 3213 | hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid); |
| 3218 | } else { | 3214 | } else { |
| 3219 | info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; | 3215 | info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; |
| @@ -3338,6 +3334,11 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, | |||
| 3338 | (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0); | 3334 | (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0); |
| 3339 | info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT; | 3335 | info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT; |
| 3340 | 3336 | ||
| 3337 | if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { | ||
| 3338 | tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; | ||
| 3339 | *ieee80211_get_qos_ctl(hdr) = tid; | ||
| 3340 | } | ||
| 3341 | |||
| 3341 | __skb_queue_head_init(&tx.skbs); | 3342 | __skb_queue_head_init(&tx.skbs); |
| 3342 | 3343 | ||
| 3343 | tx.flags = IEEE80211_TX_UNICAST; | 3344 | tx.flags = IEEE80211_TX_UNICAST; |
| @@ -3426,6 +3427,11 @@ begin: | |||
| 3426 | goto begin; | 3427 | goto begin; |
| 3427 | } | 3428 | } |
| 3428 | 3429 | ||
| 3430 | if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags)) | ||
| 3431 | info->flags |= IEEE80211_TX_CTL_AMPDU; | ||
| 3432 | else | ||
| 3433 | info->flags &= ~IEEE80211_TX_CTL_AMPDU; | ||
| 3434 | |||
| 3429 | if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { | 3435 | if (info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) { |
| 3430 | struct sta_info *sta = container_of(txq->sta, struct sta_info, | 3436 | struct sta_info *sta = container_of(txq->sta, struct sta_info, |
| 3431 | sta); | 3437 | sta); |
diff --git a/net/mac80211/vht.c b/net/mac80211/vht.c index ee715764a828..6832bf6ab69f 100644 --- a/net/mac80211/vht.c +++ b/net/mac80211/vht.c | |||
| @@ -270,6 +270,22 @@ ieee80211_vht_cap_ie_to_sta_vht_cap(struct ieee80211_sub_if_data *sdata, | |||
| 270 | vht_cap->vht_mcs.tx_mcs_map |= cpu_to_le16(peer_tx << i * 2); | 270 | vht_cap->vht_mcs.tx_mcs_map |= cpu_to_le16(peer_tx << i * 2); |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | /* | ||
| 274 | * This is a workaround for VHT-enabled STAs which break the spec | ||
| 275 | * and have the VHT-MCS Rx map filled in with value 3 for all eight | ||
| 276 | * spacial streams, an example is AR9462. | ||
| 277 | * | ||
| 278 | * As per spec, in section 22.1.1 Introduction to the VHT PHY | ||
| 279 | * A VHT STA shall support at least single spactial stream VHT-MCSs | ||
| 280 | * 0 to 7 (transmit and receive) in all supported channel widths. | ||
| 281 | */ | ||
| 282 | if (vht_cap->vht_mcs.rx_mcs_map == cpu_to_le16(0xFFFF)) { | ||
| 283 | vht_cap->vht_supported = false; | ||
| 284 | sdata_info(sdata, "Ignoring VHT IE from %pM due to invalid rx_mcs_map\n", | ||
| 285 | sta->addr); | ||
| 286 | return; | ||
| 287 | } | ||
| 288 | |||
| 273 | /* finally set up the bandwidth */ | 289 | /* finally set up the bandwidth */ |
| 274 | switch (vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { | 290 | switch (vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK) { |
| 275 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: | 291 | case IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ: |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 2b2a7974e4bb..8e93d4afe5ea 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
| @@ -112,7 +112,7 @@ static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb, | |||
| 112 | 112 | ||
| 113 | for (it_chain = chain; (tp = rtnl_dereference(*it_chain)) != NULL; | 113 | for (it_chain = chain; (tp = rtnl_dereference(*it_chain)) != NULL; |
| 114 | it_chain = &tp->next) | 114 | it_chain = &tp->next) |
| 115 | tfilter_notify(net, oskb, n, tp, 0, event, false); | 115 | tfilter_notify(net, oskb, n, tp, n->nlmsg_flags, event, false); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | /* Select new prio value from the range, managed by kernel. */ | 118 | /* Select new prio value from the range, managed by kernel. */ |
| @@ -430,7 +430,8 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb, | |||
| 430 | if (!skb) | 430 | if (!skb) |
| 431 | return -ENOBUFS; | 431 | return -ENOBUFS; |
| 432 | 432 | ||
| 433 | if (tcf_fill_node(net, skb, tp, fh, portid, n->nlmsg_seq, 0, event) <= 0) { | 433 | if (tcf_fill_node(net, skb, tp, fh, portid, n->nlmsg_seq, |
| 434 | n->nlmsg_flags, event) <= 0) { | ||
| 434 | kfree_skb(skb); | 435 | kfree_skb(skb); |
| 435 | return -EINVAL; | 436 | return -EINVAL; |
| 436 | } | 437 | } |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index f9f5f3c3dab5..db32777ab591 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * net/tipc/socket.c: TIPC socket API | 2 | * net/tipc/socket.c: TIPC socket API |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2001-2007, 2012-2015, Ericsson AB | 4 | * Copyright (c) 2001-2007, 2012-2016, Ericsson AB |
| 5 | * Copyright (c) 2004-2008, 2010-2013, Wind River Systems | 5 | * Copyright (c) 2004-2008, 2010-2013, Wind River Systems |
| 6 | * All rights reserved. | 6 | * All rights reserved. |
| 7 | * | 7 | * |
| @@ -129,54 +129,8 @@ static const struct proto_ops packet_ops; | |||
| 129 | static const struct proto_ops stream_ops; | 129 | static const struct proto_ops stream_ops; |
| 130 | static const struct proto_ops msg_ops; | 130 | static const struct proto_ops msg_ops; |
| 131 | static struct proto tipc_proto; | 131 | static struct proto tipc_proto; |
| 132 | |||
| 133 | static const struct rhashtable_params tsk_rht_params; | 132 | static const struct rhashtable_params tsk_rht_params; |
| 134 | 133 | ||
| 135 | /* | ||
| 136 | * Revised TIPC socket locking policy: | ||
| 137 | * | ||
| 138 | * Most socket operations take the standard socket lock when they start | ||
| 139 | * and hold it until they finish (or until they need to sleep). Acquiring | ||
| 140 | * this lock grants the owner exclusive access to the fields of the socket | ||
| 141 | * data structures, with the exception of the backlog queue. A few socket | ||
| 142 | * operations can be done without taking the socket lock because they only | ||
| 143 | * read socket information that never changes during the life of the socket. | ||
| 144 | * | ||
| 145 | * Socket operations may acquire the lock for the associated TIPC port if they | ||
| 146 | * need to perform an operation on the port. If any routine needs to acquire | ||
| 147 | * both the socket lock and the port lock it must take the socket lock first | ||
| 148 | * to avoid the risk of deadlock. | ||
| 149 | * | ||
| 150 | * The dispatcher handling incoming messages cannot grab the socket lock in | ||
| 151 | * the standard fashion, since invoked it runs at the BH level and cannot block. | ||
| 152 | * Instead, it checks to see if the socket lock is currently owned by someone, | ||
| 153 | * and either handles the message itself or adds it to the socket's backlog | ||
| 154 | * queue; in the latter case the queued message is processed once the process | ||
| 155 | * owning the socket lock releases it. | ||
| 156 | * | ||
| 157 | * NOTE: Releasing the socket lock while an operation is sleeping overcomes | ||
| 158 | * the problem of a blocked socket operation preventing any other operations | ||
| 159 | * from occurring. However, applications must be careful if they have | ||
| 160 | * multiple threads trying to send (or receive) on the same socket, as these | ||
| 161 | * operations might interfere with each other. For example, doing a connect | ||
| 162 | * and a receive at the same time might allow the receive to consume the | ||
| 163 | * ACK message meant for the connect. While additional work could be done | ||
| 164 | * to try and overcome this, it doesn't seem to be worthwhile at the present. | ||
| 165 | * | ||
| 166 | * NOTE: Releasing the socket lock while an operation is sleeping also ensures | ||
| 167 | * that another operation that must be performed in a non-blocking manner is | ||
| 168 | * not delayed for very long because the lock has already been taken. | ||
| 169 | * | ||
| 170 | * NOTE: This code assumes that certain fields of a port/socket pair are | ||
| 171 | * constant over its lifetime; such fields can be examined without taking | ||
| 172 | * the socket lock and/or port lock, and do not need to be re-read even | ||
| 173 | * after resuming processing after waiting. These fields include: | ||
| 174 | * - socket type | ||
| 175 | * - pointer to socket sk structure (aka tipc_sock structure) | ||
| 176 | * - pointer to port structure | ||
| 177 | * - port reference | ||
| 178 | */ | ||
| 179 | |||
| 180 | static u32 tsk_own_node(struct tipc_sock *tsk) | 134 | static u32 tsk_own_node(struct tipc_sock *tsk) |
| 181 | { | 135 | { |
| 182 | return msg_prevnode(&tsk->phdr); | 136 | return msg_prevnode(&tsk->phdr); |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 5d1c14a2f268..2358f2690ec5 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
| @@ -2199,7 +2199,8 @@ out: | |||
| 2199 | * Sleep until more data has arrived. But check for races.. | 2199 | * Sleep until more data has arrived. But check for races.. |
| 2200 | */ | 2200 | */ |
| 2201 | static long unix_stream_data_wait(struct sock *sk, long timeo, | 2201 | static long unix_stream_data_wait(struct sock *sk, long timeo, |
| 2202 | struct sk_buff *last, unsigned int last_len) | 2202 | struct sk_buff *last, unsigned int last_len, |
| 2203 | bool freezable) | ||
| 2203 | { | 2204 | { |
| 2204 | struct sk_buff *tail; | 2205 | struct sk_buff *tail; |
| 2205 | DEFINE_WAIT(wait); | 2206 | DEFINE_WAIT(wait); |
| @@ -2220,7 +2221,10 @@ static long unix_stream_data_wait(struct sock *sk, long timeo, | |||
| 2220 | 2221 | ||
| 2221 | sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); | 2222 | sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); |
| 2222 | unix_state_unlock(sk); | 2223 | unix_state_unlock(sk); |
| 2223 | timeo = freezable_schedule_timeout(timeo); | 2224 | if (freezable) |
| 2225 | timeo = freezable_schedule_timeout(timeo); | ||
| 2226 | else | ||
| 2227 | timeo = schedule_timeout(timeo); | ||
| 2224 | unix_state_lock(sk); | 2228 | unix_state_lock(sk); |
| 2225 | 2229 | ||
| 2226 | if (sock_flag(sk, SOCK_DEAD)) | 2230 | if (sock_flag(sk, SOCK_DEAD)) |
| @@ -2250,7 +2254,8 @@ struct unix_stream_read_state { | |||
| 2250 | unsigned int splice_flags; | 2254 | unsigned int splice_flags; |
| 2251 | }; | 2255 | }; |
| 2252 | 2256 | ||
| 2253 | static int unix_stream_read_generic(struct unix_stream_read_state *state) | 2257 | static int unix_stream_read_generic(struct unix_stream_read_state *state, |
| 2258 | bool freezable) | ||
| 2254 | { | 2259 | { |
| 2255 | struct scm_cookie scm; | 2260 | struct scm_cookie scm; |
| 2256 | struct socket *sock = state->socket; | 2261 | struct socket *sock = state->socket; |
| @@ -2330,7 +2335,7 @@ again: | |||
| 2330 | mutex_unlock(&u->iolock); | 2335 | mutex_unlock(&u->iolock); |
| 2331 | 2336 | ||
| 2332 | timeo = unix_stream_data_wait(sk, timeo, last, | 2337 | timeo = unix_stream_data_wait(sk, timeo, last, |
| 2333 | last_len); | 2338 | last_len, freezable); |
| 2334 | 2339 | ||
| 2335 | if (signal_pending(current)) { | 2340 | if (signal_pending(current)) { |
| 2336 | err = sock_intr_errno(timeo); | 2341 | err = sock_intr_errno(timeo); |
| @@ -2472,7 +2477,7 @@ static int unix_stream_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 2472 | .flags = flags | 2477 | .flags = flags |
| 2473 | }; | 2478 | }; |
| 2474 | 2479 | ||
| 2475 | return unix_stream_read_generic(&state); | 2480 | return unix_stream_read_generic(&state, true); |
| 2476 | } | 2481 | } |
| 2477 | 2482 | ||
| 2478 | static int unix_stream_splice_actor(struct sk_buff *skb, | 2483 | static int unix_stream_splice_actor(struct sk_buff *skb, |
| @@ -2503,7 +2508,7 @@ static ssize_t unix_stream_splice_read(struct socket *sock, loff_t *ppos, | |||
| 2503 | flags & SPLICE_F_NONBLOCK) | 2508 | flags & SPLICE_F_NONBLOCK) |
| 2504 | state.flags = MSG_DONTWAIT; | 2509 | state.flags = MSG_DONTWAIT; |
| 2505 | 2510 | ||
| 2506 | return unix_stream_read_generic(&state); | 2511 | return unix_stream_read_generic(&state, false); |
| 2507 | } | 2512 | } |
| 2508 | 2513 | ||
| 2509 | static int unix_shutdown(struct socket *sock, int mode) | 2514 | static int unix_shutdown(struct socket *sock, int mode) |
diff --git a/net/wireless/core.h b/net/wireless/core.h index 08d2e948c9ad..f0c0c8a48c92 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
| @@ -71,6 +71,7 @@ struct cfg80211_registered_device { | |||
| 71 | struct list_head bss_list; | 71 | struct list_head bss_list; |
| 72 | struct rb_root bss_tree; | 72 | struct rb_root bss_tree; |
| 73 | u32 bss_generation; | 73 | u32 bss_generation; |
| 74 | u32 bss_entries; | ||
| 74 | struct cfg80211_scan_request *scan_req; /* protected by RTNL */ | 75 | struct cfg80211_scan_request *scan_req; /* protected by RTNL */ |
| 75 | struct sk_buff *scan_msg; | 76 | struct sk_buff *scan_msg; |
| 76 | struct cfg80211_sched_scan_request __rcu *sched_scan_req; | 77 | struct cfg80211_sched_scan_request __rcu *sched_scan_req; |
diff --git a/net/wireless/scan.c b/net/wireless/scan.c index b5bd58d0f731..35ad69fd0838 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c | |||
| @@ -57,6 +57,19 @@ | |||
| 57 | * also linked into the probe response struct. | 57 | * also linked into the probe response struct. |
| 58 | */ | 58 | */ |
| 59 | 59 | ||
| 60 | /* | ||
| 61 | * Limit the number of BSS entries stored in mac80211. Each one is | ||
| 62 | * a bit over 4k at most, so this limits to roughly 4-5M of memory. | ||
| 63 | * If somebody wants to really attack this though, they'd likely | ||
| 64 | * use small beacons, and only one type of frame, limiting each of | ||
| 65 | * the entries to a much smaller size (in order to generate more | ||
| 66 | * entries in total, so overhead is bigger.) | ||
| 67 | */ | ||
| 68 | static int bss_entries_limit = 1000; | ||
| 69 | module_param(bss_entries_limit, int, 0644); | ||
| 70 | MODULE_PARM_DESC(bss_entries_limit, | ||
| 71 | "limit to number of scan BSS entries (per wiphy, default 1000)"); | ||
| 72 | |||
| 60 | #define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ) | 73 | #define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ) |
| 61 | 74 | ||
| 62 | static void bss_free(struct cfg80211_internal_bss *bss) | 75 | static void bss_free(struct cfg80211_internal_bss *bss) |
| @@ -137,6 +150,10 @@ static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *rdev, | |||
| 137 | 150 | ||
| 138 | list_del_init(&bss->list); | 151 | list_del_init(&bss->list); |
| 139 | rb_erase(&bss->rbn, &rdev->bss_tree); | 152 | rb_erase(&bss->rbn, &rdev->bss_tree); |
| 153 | rdev->bss_entries--; | ||
| 154 | WARN_ONCE((rdev->bss_entries == 0) ^ list_empty(&rdev->bss_list), | ||
| 155 | "rdev bss entries[%d]/list[empty:%d] corruption\n", | ||
| 156 | rdev->bss_entries, list_empty(&rdev->bss_list)); | ||
| 140 | bss_ref_put(rdev, bss); | 157 | bss_ref_put(rdev, bss); |
| 141 | return true; | 158 | return true; |
| 142 | } | 159 | } |
| @@ -163,6 +180,40 @@ static void __cfg80211_bss_expire(struct cfg80211_registered_device *rdev, | |||
| 163 | rdev->bss_generation++; | 180 | rdev->bss_generation++; |
| 164 | } | 181 | } |
| 165 | 182 | ||
| 183 | static bool cfg80211_bss_expire_oldest(struct cfg80211_registered_device *rdev) | ||
| 184 | { | ||
| 185 | struct cfg80211_internal_bss *bss, *oldest = NULL; | ||
| 186 | bool ret; | ||
| 187 | |||
| 188 | lockdep_assert_held(&rdev->bss_lock); | ||
| 189 | |||
| 190 | list_for_each_entry(bss, &rdev->bss_list, list) { | ||
| 191 | if (atomic_read(&bss->hold)) | ||
| 192 | continue; | ||
| 193 | |||
| 194 | if (!list_empty(&bss->hidden_list) && | ||
| 195 | !bss->pub.hidden_beacon_bss) | ||
| 196 | continue; | ||
| 197 | |||
| 198 | if (oldest && time_before(oldest->ts, bss->ts)) | ||
| 199 | continue; | ||
| 200 | oldest = bss; | ||
| 201 | } | ||
| 202 | |||
| 203 | if (WARN_ON(!oldest)) | ||
| 204 | return false; | ||
| 205 | |||
| 206 | /* | ||
| 207 | * The callers make sure to increase rdev->bss_generation if anything | ||
| 208 | * gets removed (and a new entry added), so there's no need to also do | ||
| 209 | * it here. | ||
| 210 | */ | ||
| 211 | |||
| 212 | ret = __cfg80211_unlink_bss(rdev, oldest); | ||
| 213 | WARN_ON(!ret); | ||
| 214 | return ret; | ||
| 215 | } | ||
| 216 | |||
| 166 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, | 217 | void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, |
| 167 | bool send_message) | 218 | bool send_message) |
| 168 | { | 219 | { |
| @@ -689,6 +740,7 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev, | |||
| 689 | const u8 *ie; | 740 | const u8 *ie; |
| 690 | int i, ssidlen; | 741 | int i, ssidlen; |
| 691 | u8 fold = 0; | 742 | u8 fold = 0; |
| 743 | u32 n_entries = 0; | ||
| 692 | 744 | ||
| 693 | ies = rcu_access_pointer(new->pub.beacon_ies); | 745 | ies = rcu_access_pointer(new->pub.beacon_ies); |
| 694 | if (WARN_ON(!ies)) | 746 | if (WARN_ON(!ies)) |
| @@ -712,6 +764,12 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev, | |||
| 712 | /* This is the bad part ... */ | 764 | /* This is the bad part ... */ |
| 713 | 765 | ||
| 714 | list_for_each_entry(bss, &rdev->bss_list, list) { | 766 | list_for_each_entry(bss, &rdev->bss_list, list) { |
| 767 | /* | ||
| 768 | * we're iterating all the entries anyway, so take the | ||
| 769 | * opportunity to validate the list length accounting | ||
| 770 | */ | ||
| 771 | n_entries++; | ||
| 772 | |||
| 715 | if (!ether_addr_equal(bss->pub.bssid, new->pub.bssid)) | 773 | if (!ether_addr_equal(bss->pub.bssid, new->pub.bssid)) |
| 716 | continue; | 774 | continue; |
| 717 | if (bss->pub.channel != new->pub.channel) | 775 | if (bss->pub.channel != new->pub.channel) |
| @@ -740,6 +798,10 @@ static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev, | |||
| 740 | new->pub.beacon_ies); | 798 | new->pub.beacon_ies); |
| 741 | } | 799 | } |
| 742 | 800 | ||
| 801 | WARN_ONCE(n_entries != rdev->bss_entries, | ||
| 802 | "rdev bss entries[%d]/list[len:%d] corruption\n", | ||
| 803 | rdev->bss_entries, n_entries); | ||
| 804 | |||
| 743 | return true; | 805 | return true; |
| 744 | } | 806 | } |
| 745 | 807 | ||
| @@ -894,7 +956,14 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev, | |||
| 894 | } | 956 | } |
| 895 | } | 957 | } |
| 896 | 958 | ||
| 959 | if (rdev->bss_entries >= bss_entries_limit && | ||
| 960 | !cfg80211_bss_expire_oldest(rdev)) { | ||
| 961 | kfree(new); | ||
| 962 | goto drop; | ||
| 963 | } | ||
| 964 | |||
| 897 | list_add_tail(&new->list, &rdev->bss_list); | 965 | list_add_tail(&new->list, &rdev->bss_list); |
| 966 | rdev->bss_entries++; | ||
| 898 | rb_insert_bss(rdev, new); | 967 | rb_insert_bss(rdev, new); |
| 899 | found = new; | 968 | found = new; |
| 900 | } | 969 | } |
diff --git a/net/wireless/util.c b/net/wireless/util.c index 5ea12afc7706..659b507b347d 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
| @@ -1158,7 +1158,8 @@ static u32 cfg80211_calculate_bitrate_vht(struct rate_info *rate) | |||
| 1158 | 58500000, | 1158 | 58500000, |
| 1159 | 65000000, | 1159 | 65000000, |
| 1160 | 78000000, | 1160 | 78000000, |
| 1161 | 0, | 1161 | /* not in the spec, but some devices use this: */ |
| 1162 | 86500000, | ||
| 1162 | }, | 1163 | }, |
| 1163 | { 13500000, | 1164 | { 13500000, |
| 1164 | 27000000, | 1165 | 27000000, |
