Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller:

1) Fix double SKB free in bluetooth 6lowpan layer, from Jukka Rissanen.

2) Fix receive checksum handling in enic driver, from Govindarajulu
Varadarajan.

3) Fix NAPI poll list corruption in virtio_net and caif_virtio, from
Herbert Xu. Also, add code to detect drivers that have this mistake
in the future.

4) Fix doorbell endianness handling in mlx4 driver, from Amir Vadai.

5) Don't clobber IP6CB() before xfrm6_policy_check() is called in TCP
input path,f rom Nicolas Dichtel.

6) Fix MPLS action validation in openvswitch, from Pravin B Shelar.

7) Fix double SKB free in vxlan driver, also from Pravin.

8) When we scrub a packet, which happens when we are switching the
context of the packet (namespace, etc.), we should reset the
secmark. From Thomas Graf.

9) ->ndo_gso_check() needs to do more than return true/false, it also
has to allow the driver to clear netdev feature bits in order for
the caller to be able to proceed properly. From Jesse Gross.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (62 commits)
genetlink: A genl_bind() to an out-of-range multicast group should not WARN().
netlink/genetlink: pass network namespace to bind/unbind
ne2k-pci: Add pci_disable_device in error handling
bonding: change error message to debug message in __bond_release_one()
genetlink: pass multicast bind/unbind to families
netlink: call unbind when releasing socket
netlink: update listeners directly when removing socket
genetlink: pass only network namespace to genl_has_listeners()
netlink: rename netlink_unbind() to netlink_undo_bind()
net: Generalize ndo_gso_check to ndo_features_check
net: incorrect use of init_completion fixup
neigh: remove next ptr from struct neigh_table
net: xilinx: Remove unnecessary temac_property in the driver
net: phy: micrel: use generic config_init for KSZ8021/KSZ8031
net/core: Handle csum for CHECKSUM_COMPLETE VXLAN forwarding
openvswitch: fix odd_ptr_err.cocci warnings
Bluetooth: Fix accepting connections when not using mgmt
Bluetooth: Fix controller configuration with HCI_QUIRK_INVALID_BDADDR
brcmfmac: Do not crash if platform data is not populated
ipw2200: select CFG80211_WEXT
...

+627 -1392
+1 -1
drivers/net/bonding/bond_main.c
··· 1648 1648 /* slave is not a slave or master is not master of this slave */ 1649 1649 if (!(slave_dev->flags & IFF_SLAVE) || 1650 1650 !netdev_has_upper_dev(slave_dev, bond_dev)) { 1651 - netdev_err(bond_dev, "cannot release %s\n", 1651 + netdev_dbg(bond_dev, "cannot release %s\n", 1652 1652 slave_dev->name); 1653 1653 return -EINVAL; 1654 1654 }
-2
drivers/net/caif/caif_virtio.c
··· 257 257 struct vringh_kiov *riov = &cfv->ctx.riov; 258 258 unsigned int skb_len; 259 259 260 - again: 261 260 do { 262 261 skb = NULL; 263 262 ··· 321 322 napi_schedule_prep(napi)) { 322 323 vringh_notify_disable_kern(cfv->vr_rx); 323 324 __napi_schedule(napi); 324 - goto again; 325 325 } 326 326 break; 327 327
+4 -2
drivers/net/ethernet/8390/ne2k-pci.c
··· 246 246 247 247 if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) { 248 248 dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n"); 249 - return -ENODEV; 249 + goto err_out; 250 250 } 251 251 252 252 if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) { 253 253 dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n", 254 254 NE_IO_EXTENT, ioaddr); 255 - return -EBUSY; 255 + goto err_out; 256 256 } 257 257 258 258 reg0 = inb(ioaddr); ··· 392 392 free_netdev (dev); 393 393 err_out_free_res: 394 394 release_region (ioaddr, NE_IO_EXTENT); 395 + err_out: 396 + pci_disable_device(pdev); 395 397 return -ENODEV; 396 398 } 397 399
-12
drivers/net/ethernet/Kconfig
··· 156 156 source "drivers/net/ethernet/renesas/Kconfig" 157 157 source "drivers/net/ethernet/rdc/Kconfig" 158 158 source "drivers/net/ethernet/rocker/Kconfig" 159 - 160 - config S6GMAC 161 - tristate "S6105 GMAC ethernet support" 162 - depends on XTENSA_VARIANT_S6000 163 - select PHYLIB 164 - ---help--- 165 - This driver supports the on chip ethernet device on the 166 - S6105 xtensa processor. 167 - 168 - To compile this driver as a module, choose M here. The module 169 - will be called s6gmac. 170 - 171 159 source "drivers/net/ethernet/samsung/Kconfig" 172 160 source "drivers/net/ethernet/seeq/Kconfig" 173 161 source "drivers/net/ethernet/silan/Kconfig"
-1
drivers/net/ethernet/Makefile
··· 66 66 obj-$(CONFIG_SH_ETH) += renesas/ 67 67 obj-$(CONFIG_NET_VENDOR_RDC) += rdc/ 68 68 obj-$(CONFIG_NET_VENDOR_ROCKER) += rocker/ 69 - obj-$(CONFIG_S6GMAC) += s6gmac.o 70 69 obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/ 71 70 obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/ 72 71 obj-$(CONFIG_NET_VENDOR_SILAN) += silan/
+5 -3
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 12553 12553 return 0; 12554 12554 } 12555 12555 12556 - static bool bnx2x_gso_check(struct sk_buff *skb, struct net_device *dev) 12556 + static netdev_features_t bnx2x_features_check(struct sk_buff *skb, 12557 + struct net_device *dev, 12558 + netdev_features_t features) 12557 12559 { 12558 - return vxlan_gso_check(skb); 12560 + return vxlan_features_check(skb, features); 12559 12561 } 12560 12562 12561 12563 static const struct net_device_ops bnx2x_netdev_ops = { ··· 12591 12589 #endif 12592 12590 .ndo_get_phys_port_id = bnx2x_get_phys_port_id, 12593 12591 .ndo_set_vf_link_state = bnx2x_set_vf_link_state, 12594 - .ndo_gso_check = bnx2x_gso_check, 12592 + .ndo_features_check = bnx2x_features_check, 12595 12593 }; 12596 12594 12597 12595 static int bnx2x_set_coherency_mask(struct bnx2x *bp)
+17 -17
drivers/net/ethernet/broadcom/tg3.c
··· 17800 17800 goto err_out_apeunmap; 17801 17801 } 17802 17802 17803 - /* 17804 - * Reset chip in case UNDI or EFI driver did not shutdown 17805 - * DMA self test will enable WDMAC and we'll see (spurious) 17806 - * pending DMA on the PCI bus at that point. 17807 - */ 17808 - if ((tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE) || 17809 - (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 17810 - tw32(MEMARB_MODE, MEMARB_MODE_ENABLE); 17811 - tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 17812 - } 17813 - 17814 - err = tg3_test_dma(tp); 17815 - if (err) { 17816 - dev_err(&pdev->dev, "DMA engine test failed, aborting\n"); 17817 - goto err_out_apeunmap; 17818 - } 17819 - 17820 17803 intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW; 17821 17804 rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW; 17822 17805 sndmbx = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW; ··· 17842 17859 sndmbx -= 0x4; 17843 17860 else 17844 17861 sndmbx += 0xc; 17862 + } 17863 + 17864 + /* 17865 + * Reset chip in case UNDI or EFI driver did not shutdown 17866 + * DMA self test will enable WDMAC and we'll see (spurious) 17867 + * pending DMA on the PCI bus at that point. 17868 + */ 17869 + if ((tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE) || 17870 + (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 17871 + tw32(MEMARB_MODE, MEMARB_MODE_ENABLE); 17872 + tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 17873 + } 17874 + 17875 + err = tg3_test_dma(tp); 17876 + if (err) { 17877 + dev_err(&pdev->dev, "DMA engine test failed, aborting\n"); 17878 + goto err_out_apeunmap; 17845 17879 } 17846 17880 17847 17881 tg3_init_coal(tp);
+1 -1
drivers/net/ethernet/brocade/bna/bnad_debugfs.c
··· 172 172 173 173 /* Retrieve flash partition info */ 174 174 fcomp.comp_status = 0; 175 - init_completion(&fcomp.comp); 175 + reinit_completion(&fcomp.comp); 176 176 spin_lock_irqsave(&bnad->bna_lock, flags); 177 177 ret = bfa_nw_flash_get_attr(&bnad->bna.flash, &drvinfo->flash_attr, 178 178 bnad_cb_completion, &fcomp);
+4
drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
··· 96 96 s16 xact_addr_filt; /* index of our MAC address filter */ 97 97 u16 rss_size; /* size of VI's RSS table slice */ 98 98 u8 pidx; /* index into adapter port[] */ 99 + s8 mdio_addr; 100 + u8 port_type; /* firmware port type */ 101 + u8 mod_type; /* firmware module type */ 99 102 u8 port_id; /* physical port ID */ 100 103 u8 nqsets; /* # of "Queue Sets" */ 101 104 u8 first_qset; /* index of first "Queue Set" */ ··· 525 522 * is "contracted" to provide for the common code. 526 523 */ 527 524 void t4vf_os_link_changed(struct adapter *, int, int); 525 + void t4vf_os_portmod_changed(struct adapter *, int); 528 526 529 527 /* 530 528 * SGE function prototype declarations.
+126 -14
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
··· 44 44 #include <linux/etherdevice.h> 45 45 #include <linux/debugfs.h> 46 46 #include <linux/ethtool.h> 47 + #include <linux/mdio.h> 47 48 48 49 #include "t4vf_common.h" 49 50 #include "t4vf_defs.h" ··· 208 207 netif_carrier_off(dev); 209 208 netdev_info(dev, "link down\n"); 210 209 } 210 + } 211 + 212 + /* 213 + * THe port module type has changed on the indicated "port" (Virtual 214 + * Interface). 215 + */ 216 + void t4vf_os_portmod_changed(struct adapter *adapter, int pidx) 217 + { 218 + static const char * const mod_str[] = { 219 + NULL, "LR", "SR", "ER", "passive DA", "active DA", "LRM" 220 + }; 221 + const struct net_device *dev = adapter->port[pidx]; 222 + const struct port_info *pi = netdev_priv(dev); 223 + 224 + if (pi->mod_type == FW_PORT_MOD_TYPE_NONE) 225 + dev_info(adapter->pdev_dev, "%s: port module unplugged\n", 226 + dev->name); 227 + else if (pi->mod_type < ARRAY_SIZE(mod_str)) 228 + dev_info(adapter->pdev_dev, "%s: %s port module inserted\n", 229 + dev->name, mod_str[pi->mod_type]); 230 + else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED) 231 + dev_info(adapter->pdev_dev, "%s: unsupported optical port " 232 + "module inserted\n", dev->name); 233 + else if (pi->mod_type == FW_PORT_MOD_TYPE_UNKNOWN) 234 + dev_info(adapter->pdev_dev, "%s: unknown port module inserted," 235 + "forcing TWINAX\n", dev->name); 236 + else if (pi->mod_type == FW_PORT_MOD_TYPE_ERROR) 237 + dev_info(adapter->pdev_dev, "%s: transceiver module error\n", 238 + dev->name); 239 + else 240 + dev_info(adapter->pdev_dev, "%s: unknown module type %d " 241 + "inserted\n", dev->name, pi->mod_type); 211 242 } 212 243 213 244 /* ··· 1226 1193 * state of the port to which we're linked. 1227 1194 */ 1228 1195 1229 - /* 1230 - * Return current port link settings. 1231 - */ 1232 - static int cxgb4vf_get_settings(struct net_device *dev, 1233 - struct ethtool_cmd *cmd) 1196 + static unsigned int t4vf_from_fw_linkcaps(enum fw_port_type type, 1197 + unsigned int caps) 1234 1198 { 1235 - const struct port_info *pi = netdev_priv(dev); 1199 + unsigned int v = 0; 1236 1200 1237 - cmd->supported = pi->link_cfg.supported; 1238 - cmd->advertising = pi->link_cfg.advertising; 1201 + if (type == FW_PORT_TYPE_BT_SGMII || type == FW_PORT_TYPE_BT_XFI || 1202 + type == FW_PORT_TYPE_BT_XAUI) { 1203 + v |= SUPPORTED_TP; 1204 + if (caps & FW_PORT_CAP_SPEED_100M) 1205 + v |= SUPPORTED_100baseT_Full; 1206 + if (caps & FW_PORT_CAP_SPEED_1G) 1207 + v |= SUPPORTED_1000baseT_Full; 1208 + if (caps & FW_PORT_CAP_SPEED_10G) 1209 + v |= SUPPORTED_10000baseT_Full; 1210 + } else if (type == FW_PORT_TYPE_KX4 || type == FW_PORT_TYPE_KX) { 1211 + v |= SUPPORTED_Backplane; 1212 + if (caps & FW_PORT_CAP_SPEED_1G) 1213 + v |= SUPPORTED_1000baseKX_Full; 1214 + if (caps & FW_PORT_CAP_SPEED_10G) 1215 + v |= SUPPORTED_10000baseKX4_Full; 1216 + } else if (type == FW_PORT_TYPE_KR) 1217 + v |= SUPPORTED_Backplane | SUPPORTED_10000baseKR_Full; 1218 + else if (type == FW_PORT_TYPE_BP_AP) 1219 + v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC | 1220 + SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full; 1221 + else if (type == FW_PORT_TYPE_BP4_AP) 1222 + v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC | 1223 + SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full | 1224 + SUPPORTED_10000baseKX4_Full; 1225 + else if (type == FW_PORT_TYPE_FIBER_XFI || 1226 + type == FW_PORT_TYPE_FIBER_XAUI || 1227 + type == FW_PORT_TYPE_SFP || 1228 + type == FW_PORT_TYPE_QSFP_10G || 1229 + type == FW_PORT_TYPE_QSA) { 1230 + v |= SUPPORTED_FIBRE; 1231 + if (caps & FW_PORT_CAP_SPEED_1G) 1232 + v |= SUPPORTED_1000baseT_Full; 1233 + if (caps & FW_PORT_CAP_SPEED_10G) 1234 + v |= SUPPORTED_10000baseT_Full; 1235 + } else if (type == FW_PORT_TYPE_BP40_BA || 1236 + type == FW_PORT_TYPE_QSFP) { 1237 + v |= SUPPORTED_40000baseSR4_Full; 1238 + v |= SUPPORTED_FIBRE; 1239 + } 1240 + 1241 + if (caps & FW_PORT_CAP_ANEG) 1242 + v |= SUPPORTED_Autoneg; 1243 + return v; 1244 + } 1245 + 1246 + static int cxgb4vf_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1247 + { 1248 + const struct port_info *p = netdev_priv(dev); 1249 + 1250 + if (p->port_type == FW_PORT_TYPE_BT_SGMII || 1251 + p->port_type == FW_PORT_TYPE_BT_XFI || 1252 + p->port_type == FW_PORT_TYPE_BT_XAUI) 1253 + cmd->port = PORT_TP; 1254 + else if (p->port_type == FW_PORT_TYPE_FIBER_XFI || 1255 + p->port_type == FW_PORT_TYPE_FIBER_XAUI) 1256 + cmd->port = PORT_FIBRE; 1257 + else if (p->port_type == FW_PORT_TYPE_SFP || 1258 + p->port_type == FW_PORT_TYPE_QSFP_10G || 1259 + p->port_type == FW_PORT_TYPE_QSA || 1260 + p->port_type == FW_PORT_TYPE_QSFP) { 1261 + if (p->mod_type == FW_PORT_MOD_TYPE_LR || 1262 + p->mod_type == FW_PORT_MOD_TYPE_SR || 1263 + p->mod_type == FW_PORT_MOD_TYPE_ER || 1264 + p->mod_type == FW_PORT_MOD_TYPE_LRM) 1265 + cmd->port = PORT_FIBRE; 1266 + else if (p->mod_type == FW_PORT_MOD_TYPE_TWINAX_PASSIVE || 1267 + p->mod_type == FW_PORT_MOD_TYPE_TWINAX_ACTIVE) 1268 + cmd->port = PORT_DA; 1269 + else 1270 + cmd->port = PORT_OTHER; 1271 + } else 1272 + cmd->port = PORT_OTHER; 1273 + 1274 + if (p->mdio_addr >= 0) { 1275 + cmd->phy_address = p->mdio_addr; 1276 + cmd->transceiver = XCVR_EXTERNAL; 1277 + cmd->mdio_support = p->port_type == FW_PORT_TYPE_BT_SGMII ? 1278 + MDIO_SUPPORTS_C22 : MDIO_SUPPORTS_C45; 1279 + } else { 1280 + cmd->phy_address = 0; /* not really, but no better option */ 1281 + cmd->transceiver = XCVR_INTERNAL; 1282 + cmd->mdio_support = 0; 1283 + } 1284 + 1285 + cmd->supported = t4vf_from_fw_linkcaps(p->port_type, 1286 + p->link_cfg.supported); 1287 + cmd->advertising = t4vf_from_fw_linkcaps(p->port_type, 1288 + p->link_cfg.advertising); 1239 1289 ethtool_cmd_speed_set(cmd, 1240 - netif_carrier_ok(dev) ? pi->link_cfg.speed : -1); 1290 + netif_carrier_ok(dev) ? p->link_cfg.speed : 0); 1241 1291 cmd->duplex = DUPLEX_FULL; 1242 - 1243 - cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; 1244 - cmd->phy_address = pi->port_id; 1245 - cmd->transceiver = XCVR_EXTERNAL; 1246 - cmd->autoneg = pi->link_cfg.autoneg; 1292 + cmd->autoneg = p->link_cfg.autoneg; 1247 1293 cmd->maxtxpkt = 0; 1248 1294 cmd->maxrxpkt = 0; 1249 1295 return 0;
+1 -1
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
··· 230 230 231 231 static inline bool is_10g_port(const struct link_config *lc) 232 232 { 233 - return (lc->supported & SUPPORTED_10000baseT_Full) != 0; 233 + return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0; 234 234 } 235 235 236 236 static inline bool is_x_10g_port(const struct link_config *lc)
+29 -25
drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
··· 245 245 return a & 0x3f; 246 246 } 247 247 248 + #define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\ 249 + FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_SPEED_40G | \ 250 + FW_PORT_CAP_SPEED_100G | FW_PORT_CAP_ANEG) 251 + 248 252 /** 249 253 * init_link_config - initialize a link's SW state 250 254 * @lc: structure holding the link state ··· 263 259 lc->requested_speed = 0; 264 260 lc->speed = 0; 265 261 lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX; 266 - if (lc->supported & SUPPORTED_Autoneg) { 267 - lc->advertising = lc->supported; 262 + if (lc->supported & FW_PORT_CAP_ANEG) { 263 + lc->advertising = lc->supported & ADVERT_MASK; 268 264 lc->autoneg = AUTONEG_ENABLE; 269 265 lc->requested_fc |= PAUSE_AUTONEG; 270 266 } else { ··· 284 280 struct fw_vi_cmd vi_cmd, vi_rpl; 285 281 struct fw_port_cmd port_cmd, port_rpl; 286 282 int v; 287 - u32 word; 288 283 289 284 /* 290 285 * Execute a VI Read command to get our Virtual Interface information ··· 322 319 if (v) 323 320 return v; 324 321 325 - v = 0; 326 - word = be16_to_cpu(port_rpl.u.info.pcap); 327 - if (word & FW_PORT_CAP_SPEED_100M) 328 - v |= SUPPORTED_100baseT_Full; 329 - if (word & FW_PORT_CAP_SPEED_1G) 330 - v |= SUPPORTED_1000baseT_Full; 331 - if (word & FW_PORT_CAP_SPEED_10G) 332 - v |= SUPPORTED_10000baseT_Full; 333 - if (word & FW_PORT_CAP_SPEED_40G) 334 - v |= SUPPORTED_40000baseSR4_Full; 335 - if (word & FW_PORT_CAP_ANEG) 336 - v |= SUPPORTED_Autoneg; 337 - init_link_config(&pi->link_cfg, v); 322 + v = be32_to_cpu(port_rpl.u.info.lstatus_to_modtype); 323 + pi->port_type = FW_PORT_CMD_PTYPE_G(v); 324 + pi->mod_type = FW_PORT_MOD_TYPE_NA; 325 + 326 + init_link_config(&pi->link_cfg, be16_to_cpu(port_rpl.u.info.pcap)); 338 327 339 328 return 0; 340 329 } ··· 1486 1491 */ 1487 1492 const struct fw_port_cmd *port_cmd = 1488 1493 (const struct fw_port_cmd *)rpl; 1489 - u32 word; 1494 + u32 stat, mod; 1490 1495 int action, port_id, link_ok, speed, fc, pidx; 1491 1496 1492 1497 /* ··· 1504 1509 port_id = FW_PORT_CMD_PORTID_G( 1505 1510 be32_to_cpu(port_cmd->op_to_portid)); 1506 1511 1507 - word = be32_to_cpu(port_cmd->u.info.lstatus_to_modtype); 1508 - link_ok = (word & FW_PORT_CMD_LSTATUS_F) != 0; 1512 + stat = be32_to_cpu(port_cmd->u.info.lstatus_to_modtype); 1513 + link_ok = (stat & FW_PORT_CMD_LSTATUS_F) != 0; 1509 1514 speed = 0; 1510 1515 fc = 0; 1511 - if (word & FW_PORT_CMD_RXPAUSE_F) 1516 + if (stat & FW_PORT_CMD_RXPAUSE_F) 1512 1517 fc |= PAUSE_RX; 1513 - if (word & FW_PORT_CMD_TXPAUSE_F) 1518 + if (stat & FW_PORT_CMD_TXPAUSE_F) 1514 1519 fc |= PAUSE_TX; 1515 - if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_100M)) 1520 + if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_100M)) 1516 1521 speed = 100; 1517 - else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_1G)) 1522 + else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_1G)) 1518 1523 speed = 1000; 1519 - else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_10G)) 1524 + else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_10G)) 1520 1525 speed = 10000; 1521 - else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_40G)) 1526 + else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_40G)) 1522 1527 speed = 40000; 1523 1528 1524 1529 /* ··· 1535 1540 continue; 1536 1541 1537 1542 lc = &pi->link_cfg; 1543 + 1544 + mod = FW_PORT_CMD_MODTYPE_G(stat); 1545 + if (mod != pi->mod_type) { 1546 + pi->mod_type = mod; 1547 + t4vf_os_portmod_changed(adapter, pidx); 1548 + } 1549 + 1538 1550 if (link_ok != lc->link_ok || speed != lc->speed || 1539 1551 fc != lc->fc) { 1540 1552 /* something changed */ 1541 1553 lc->link_ok = link_ok; 1542 1554 lc->speed = speed; 1543 1555 lc->fc = fc; 1556 + lc->supported = 1557 + be16_to_cpu(port_cmd->u.info.pcap); 1544 1558 t4vf_os_link_changed(adapter, pidx, link_ok); 1545 1559 } 1546 1560 }
+8 -4
drivers/net/ethernet/cisco/enic/enic_main.c
··· 1060 1060 PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3); 1061 1061 } 1062 1062 1063 - if ((netdev->features & NETIF_F_RXCSUM) && !csum_not_calc) { 1064 - skb->csum = htons(checksum); 1065 - skb->ip_summed = CHECKSUM_COMPLETE; 1066 - } 1063 + /* Hardware does not provide whole packet checksum. It only 1064 + * provides pseudo checksum. Since hw validates the packet 1065 + * checksum but not provide us the checksum value. use 1066 + * CHECSUM_UNNECESSARY. 1067 + */ 1068 + if ((netdev->features & NETIF_F_RXCSUM) && tcp_udp_csum_ok && 1069 + ipv4_csum_ok) 1070 + skb->ip_summed = CHECKSUM_UNNECESSARY; 1067 1071 1068 1072 if (vlan_stripped) 1069 1073 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci);
+5 -3
drivers/net/ethernet/emulex/benet/be_main.c
··· 4459 4459 adapter->vxlan_port_count--; 4460 4460 } 4461 4461 4462 - static bool be_gso_check(struct sk_buff *skb, struct net_device *dev) 4462 + static netdev_features_t be_features_check(struct sk_buff *skb, 4463 + struct net_device *dev, 4464 + netdev_features_t features) 4463 4465 { 4464 - return vxlan_gso_check(skb); 4466 + return vxlan_features_check(skb, features); 4465 4467 } 4466 4468 #endif 4467 4469 ··· 4494 4492 #ifdef CONFIG_BE2NET_VXLAN 4495 4493 .ndo_add_vxlan_port = be_add_vxlan_port, 4496 4494 .ndo_del_vxlan_port = be_del_vxlan_port, 4497 - .ndo_gso_check = be_gso_check, 4495 + .ndo_features_check = be_features_check, 4498 4496 #endif 4499 4497 }; 4500 4498
+6 -4
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
··· 2365 2365 queue_work(priv->mdev->workqueue, &priv->vxlan_del_task); 2366 2366 } 2367 2367 2368 - static bool mlx4_en_gso_check(struct sk_buff *skb, struct net_device *dev) 2368 + static netdev_features_t mlx4_en_features_check(struct sk_buff *skb, 2369 + struct net_device *dev, 2370 + netdev_features_t features) 2369 2371 { 2370 - return vxlan_gso_check(skb); 2372 + return vxlan_features_check(skb, features); 2371 2373 } 2372 2374 #endif 2373 2375 ··· 2402 2400 #ifdef CONFIG_MLX4_EN_VXLAN 2403 2401 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port, 2404 2402 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, 2405 - .ndo_gso_check = mlx4_en_gso_check, 2403 + .ndo_features_check = mlx4_en_features_check, 2406 2404 #endif 2407 2405 }; 2408 2406 ··· 2436 2434 #ifdef CONFIG_MLX4_EN_VXLAN 2437 2435 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port, 2438 2436 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, 2439 - .ndo_gso_check = mlx4_en_gso_check, 2437 + .ndo_features_check = mlx4_en_features_check, 2440 2438 #endif 2441 2439 }; 2442 2440
+11 -1
drivers/net/ethernet/mellanox/mlx4/en_tx.c
··· 962 962 tx_desc->ctrl.owner_opcode = op_own; 963 963 if (send_doorbell) { 964 964 wmb(); 965 - iowrite32(ring->doorbell_qpn, 965 + /* Since there is no iowrite*_native() that writes the 966 + * value as is, without byteswapping - using the one 967 + * the doesn't do byteswapping in the relevant arch 968 + * endianness. 969 + */ 970 + #if defined(__LITTLE_ENDIAN) 971 + iowrite32( 972 + #else 973 + iowrite32be( 974 + #endif 975 + ring->doorbell_qpn, 966 976 ring->bf.uar->map + MLX4_SEND_DOORBELL); 967 977 } else { 968 978 ring->xmit_more++;
-6
drivers/net/ethernet/micrel/ksz884x.c
··· 2303 2303 2304 2304 /* Spanning Tree */ 2305 2305 2306 - static inline void port_cfg_dis_learn(struct ksz_hw *hw, int p, int set) 2307 - { 2308 - port_cfg(hw, p, 2309 - KS8842_PORT_CTRL_2_OFFSET, PORT_LEARN_DISABLE, set); 2310 - } 2311 - 2312 2306 static inline void port_cfg_rx(struct ksz_hw *hw, int p, int set) 2313 2307 { 2314 2308 port_cfg(hw, p,
+5 -3
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
··· 505 505 adapter->flags |= QLCNIC_DEL_VXLAN_PORT; 506 506 } 507 507 508 - static bool qlcnic_gso_check(struct sk_buff *skb, struct net_device *dev) 508 + static netdev_features_t qlcnic_features_check(struct sk_buff *skb, 509 + struct net_device *dev, 510 + netdev_features_t features) 509 511 { 510 - return vxlan_gso_check(skb); 512 + return vxlan_features_check(skb, features); 511 513 } 512 514 #endif 513 515 ··· 534 532 #ifdef CONFIG_QLCNIC_VXLAN 535 533 .ndo_add_vxlan_port = qlcnic_add_vxlan_port, 536 534 .ndo_del_vxlan_port = qlcnic_del_vxlan_port, 537 - .ndo_gso_check = qlcnic_gso_check, 535 + .ndo_features_check = qlcnic_features_check, 538 536 #endif 539 537 #ifdef CONFIG_NET_POLL_CONTROLLER 540 538 .ndo_poll_controller = qlcnic_poll_controller,
+3 -1
drivers/net/ethernet/realtek/8139too.c
··· 787 787 if (rc) 788 788 goto err_out; 789 789 790 + disable_dev_on_err = 1; 790 791 rc = pci_request_regions (pdev, DRV_NAME); 791 792 if (rc) 792 793 goto err_out; 793 - disable_dev_on_err = 1; 794 794 795 795 pci_set_master (pdev); 796 796 ··· 1110 1110 return 0; 1111 1111 1112 1112 err_out: 1113 + netif_napi_del(&tp->napi); 1113 1114 __rtl8139_cleanup_dev (dev); 1114 1115 pci_disable_device (pdev); 1115 1116 return i; ··· 1125 1124 assert (dev != NULL); 1126 1125 1127 1126 cancel_delayed_work_sync(&tp->thread); 1127 + netif_napi_del(&tp->napi); 1128 1128 1129 1129 unregister_netdev (dev); 1130 1130
-1058
drivers/net/ethernet/s6gmac.c
··· 1 - /* 2 - * Ethernet driver for S6105 on chip network device 3 - * (c)2008 emlix GmbH http://www.emlix.com 4 - * Authors: Oskar Schirmer <oskar@scara.com> 5 - * Daniel Gloeckner <dg@emlix.com> 6 - * 7 - * This program is free software; you can redistribute it and/or 8 - * modify it under the terms of the GNU General Public License 9 - * as published by the Free Software Foundation; either version 10 - * 2 of the License, or (at your option) any later version. 11 - */ 12 - #include <linux/kernel.h> 13 - #include <linux/module.h> 14 - #include <linux/interrupt.h> 15 - #include <linux/types.h> 16 - #include <linux/delay.h> 17 - #include <linux/spinlock.h> 18 - #include <linux/netdevice.h> 19 - #include <linux/etherdevice.h> 20 - #include <linux/if.h> 21 - #include <linux/stddef.h> 22 - #include <linux/mii.h> 23 - #include <linux/phy.h> 24 - #include <linux/platform_device.h> 25 - #include <variant/hardware.h> 26 - #include <variant/dmac.h> 27 - 28 - #define DRV_NAME "s6gmac" 29 - #define DRV_PRMT DRV_NAME ": " 30 - 31 - 32 - /* register declarations */ 33 - 34 - #define S6_GMAC_MACCONF1 0x000 35 - #define S6_GMAC_MACCONF1_TXENA 0 36 - #define S6_GMAC_MACCONF1_SYNCTX 1 37 - #define S6_GMAC_MACCONF1_RXENA 2 38 - #define S6_GMAC_MACCONF1_SYNCRX 3 39 - #define S6_GMAC_MACCONF1_TXFLOWCTRL 4 40 - #define S6_GMAC_MACCONF1_RXFLOWCTRL 5 41 - #define S6_GMAC_MACCONF1_LOOPBACK 8 42 - #define S6_GMAC_MACCONF1_RESTXFUNC 16 43 - #define S6_GMAC_MACCONF1_RESRXFUNC 17 44 - #define S6_GMAC_MACCONF1_RESTXMACCTRL 18 45 - #define S6_GMAC_MACCONF1_RESRXMACCTRL 19 46 - #define S6_GMAC_MACCONF1_SIMULRES 30 47 - #define S6_GMAC_MACCONF1_SOFTRES 31 48 - #define S6_GMAC_MACCONF2 0x004 49 - #define S6_GMAC_MACCONF2_FULL 0 50 - #define S6_GMAC_MACCONF2_CRCENA 1 51 - #define S6_GMAC_MACCONF2_PADCRCENA 2 52 - #define S6_GMAC_MACCONF2_LENGTHFCHK 4 53 - #define S6_GMAC_MACCONF2_HUGEFRAMENA 5 54 - #define S6_GMAC_MACCONF2_IFMODE 8 55 - #define S6_GMAC_MACCONF2_IFMODE_NIBBLE 1 56 - #define S6_GMAC_MACCONF2_IFMODE_BYTE 2 57 - #define S6_GMAC_MACCONF2_IFMODE_MASK 3 58 - #define S6_GMAC_MACCONF2_PREAMBLELEN 12 59 - #define S6_GMAC_MACCONF2_PREAMBLELEN_MASK 0x0F 60 - #define S6_GMAC_MACIPGIFG 0x008 61 - #define S6_GMAC_MACIPGIFG_B2BINTERPGAP 0 62 - #define S6_GMAC_MACIPGIFG_B2BINTERPGAP_MASK 0x7F 63 - #define S6_GMAC_MACIPGIFG_MINIFGENFORCE 8 64 - #define S6_GMAC_MACIPGIFG_B2BINTERPGAP2 16 65 - #define S6_GMAC_MACIPGIFG_B2BINTERPGAP1 24 66 - #define S6_GMAC_MACHALFDUPLEX 0x00C 67 - #define S6_GMAC_MACHALFDUPLEX_COLLISWIN 0 68 - #define S6_GMAC_MACHALFDUPLEX_COLLISWIN_MASK 0x3F 69 - #define S6_GMAC_MACHALFDUPLEX_RETXMAX 12 70 - #define S6_GMAC_MACHALFDUPLEX_RETXMAX_MASK 0x0F 71 - #define S6_GMAC_MACHALFDUPLEX_EXCESSDEF 16 72 - #define S6_GMAC_MACHALFDUPLEX_NOBACKOFF 17 73 - #define S6_GMAC_MACHALFDUPLEX_BPNOBCKOF 18 74 - #define S6_GMAC_MACHALFDUPLEX_ALTBEBENA 19 75 - #define S6_GMAC_MACHALFDUPLEX_ALTBEBTRN 20 76 - #define S6_GMAC_MACHALFDUPLEX_ALTBEBTR_MASK 0x0F 77 - #define S6_GMAC_MACMAXFRAMELEN 0x010 78 - #define S6_GMAC_MACMIICONF 0x020 79 - #define S6_GMAC_MACMIICONF_CSEL 0 80 - #define S6_GMAC_MACMIICONF_CSEL_DIV10 0 81 - #define S6_GMAC_MACMIICONF_CSEL_DIV12 1 82 - #define S6_GMAC_MACMIICONF_CSEL_DIV14 2 83 - #define S6_GMAC_MACMIICONF_CSEL_DIV18 3 84 - #define S6_GMAC_MACMIICONF_CSEL_DIV24 4 85 - #define S6_GMAC_MACMIICONF_CSEL_DIV34 5 86 - #define S6_GMAC_MACMIICONF_CSEL_DIV68 6 87 - #define S6_GMAC_MACMIICONF_CSEL_DIV168 7 88 - #define S6_GMAC_MACMIICONF_CSEL_MASK 7 89 - #define S6_GMAC_MACMIICONF_PREAMBLESUPR 4 90 - #define S6_GMAC_MACMIICONF_SCANAUTOINCR 5 91 - #define S6_GMAC_MACMIICMD 0x024 92 - #define S6_GMAC_MACMIICMD_READ 0 93 - #define S6_GMAC_MACMIICMD_SCAN 1 94 - #define S6_GMAC_MACMIIADDR 0x028 95 - #define S6_GMAC_MACMIIADDR_REG 0 96 - #define S6_GMAC_MACMIIADDR_REG_MASK 0x1F 97 - #define S6_GMAC_MACMIIADDR_PHY 8 98 - #define S6_GMAC_MACMIIADDR_PHY_MASK 0x1F 99 - #define S6_GMAC_MACMIICTRL 0x02C 100 - #define S6_GMAC_MACMIISTAT 0x030 101 - #define S6_GMAC_MACMIIINDI 0x034 102 - #define S6_GMAC_MACMIIINDI_BUSY 0 103 - #define S6_GMAC_MACMIIINDI_SCAN 1 104 - #define S6_GMAC_MACMIIINDI_INVAL 2 105 - #define S6_GMAC_MACINTERFSTAT 0x03C 106 - #define S6_GMAC_MACINTERFSTAT_LINKFAIL 3 107 - #define S6_GMAC_MACINTERFSTAT_EXCESSDEF 9 108 - #define S6_GMAC_MACSTATADDR1 0x040 109 - #define S6_GMAC_MACSTATADDR2 0x044 110 - 111 - #define S6_GMAC_FIFOCONF0 0x048 112 - #define S6_GMAC_FIFOCONF0_HSTRSTWT 0 113 - #define S6_GMAC_FIFOCONF0_HSTRSTSR 1 114 - #define S6_GMAC_FIFOCONF0_HSTRSTFR 2 115 - #define S6_GMAC_FIFOCONF0_HSTRSTST 3 116 - #define S6_GMAC_FIFOCONF0_HSTRSTFT 4 117 - #define S6_GMAC_FIFOCONF0_WTMENREQ 8 118 - #define S6_GMAC_FIFOCONF0_SRFENREQ 9 119 - #define S6_GMAC_FIFOCONF0_FRFENREQ 10 120 - #define S6_GMAC_FIFOCONF0_STFENREQ 11 121 - #define S6_GMAC_FIFOCONF0_FTFENREQ 12 122 - #define S6_GMAC_FIFOCONF0_WTMENRPLY 16 123 - #define S6_GMAC_FIFOCONF0_SRFENRPLY 17 124 - #define S6_GMAC_FIFOCONF0_FRFENRPLY 18 125 - #define S6_GMAC_FIFOCONF0_STFENRPLY 19 126 - #define S6_GMAC_FIFOCONF0_FTFENRPLY 20 127 - #define S6_GMAC_FIFOCONF1 0x04C 128 - #define S6_GMAC_FIFOCONF2 0x050 129 - #define S6_GMAC_FIFOCONF2_CFGLWM 0 130 - #define S6_GMAC_FIFOCONF2_CFGHWM 16 131 - #define S6_GMAC_FIFOCONF3 0x054 132 - #define S6_GMAC_FIFOCONF3_CFGFTTH 0 133 - #define S6_GMAC_FIFOCONF3_CFGHWMFT 16 134 - #define S6_GMAC_FIFOCONF4 0x058 135 - #define S6_GMAC_FIFOCONF_RSV_PREVDROP 0 136 - #define S6_GMAC_FIFOCONF_RSV_RUNT 1 137 - #define S6_GMAC_FIFOCONF_RSV_FALSECAR 2 138 - #define S6_GMAC_FIFOCONF_RSV_CODEERR 3 139 - #define S6_GMAC_FIFOCONF_RSV_CRCERR 4 140 - #define S6_GMAC_FIFOCONF_RSV_LENGTHERR 5 141 - #define S6_GMAC_FIFOCONF_RSV_LENRANGE 6 142 - #define S6_GMAC_FIFOCONF_RSV_OK 7 143 - #define S6_GMAC_FIFOCONF_RSV_MULTICAST 8 144 - #define S6_GMAC_FIFOCONF_RSV_BROADCAST 9 145 - #define S6_GMAC_FIFOCONF_RSV_DRIBBLE 10 146 - #define S6_GMAC_FIFOCONF_RSV_CTRLFRAME 11 147 - #define S6_GMAC_FIFOCONF_RSV_PAUSECTRL 12 148 - #define S6_GMAC_FIFOCONF_RSV_UNOPCODE 13 149 - #define S6_GMAC_FIFOCONF_RSV_VLANTAG 14 150 - #define S6_GMAC_FIFOCONF_RSV_LONGEVENT 15 151 - #define S6_GMAC_FIFOCONF_RSV_TRUNCATED 16 152 - #define S6_GMAC_FIFOCONF_RSV_MASK 0x3FFFF 153 - #define S6_GMAC_FIFOCONF5 0x05C 154 - #define S6_GMAC_FIFOCONF5_DROPLT64 18 155 - #define S6_GMAC_FIFOCONF5_CFGBYTM 19 156 - #define S6_GMAC_FIFOCONF5_RXDROPSIZE 20 157 - #define S6_GMAC_FIFOCONF5_RXDROPSIZE_MASK 0xF 158 - 159 - #define S6_GMAC_STAT_REGS 0x080 160 - #define S6_GMAC_STAT_SIZE_MIN 12 161 - #define S6_GMAC_STATTR64 0x080 162 - #define S6_GMAC_STATTR64_SIZE 18 163 - #define S6_GMAC_STATTR127 0x084 164 - #define S6_GMAC_STATTR127_SIZE 18 165 - #define S6_GMAC_STATTR255 0x088 166 - #define S6_GMAC_STATTR255_SIZE 18 167 - #define S6_GMAC_STATTR511 0x08C 168 - #define S6_GMAC_STATTR511_SIZE 18 169 - #define S6_GMAC_STATTR1K 0x090 170 - #define S6_GMAC_STATTR1K_SIZE 18 171 - #define S6_GMAC_STATTRMAX 0x094 172 - #define S6_GMAC_STATTRMAX_SIZE 18 173 - #define S6_GMAC_STATTRMGV 0x098 174 - #define S6_GMAC_STATTRMGV_SIZE 18 175 - #define S6_GMAC_STATRBYT 0x09C 176 - #define S6_GMAC_STATRBYT_SIZE 24 177 - #define S6_GMAC_STATRPKT 0x0A0 178 - #define S6_GMAC_STATRPKT_SIZE 18 179 - #define S6_GMAC_STATRFCS 0x0A4 180 - #define S6_GMAC_STATRFCS_SIZE 12 181 - #define S6_GMAC_STATRMCA 0x0A8 182 - #define S6_GMAC_STATRMCA_SIZE 18 183 - #define S6_GMAC_STATRBCA 0x0AC 184 - #define S6_GMAC_STATRBCA_SIZE 22 185 - #define S6_GMAC_STATRXCF 0x0B0 186 - #define S6_GMAC_STATRXCF_SIZE 18 187 - #define S6_GMAC_STATRXPF 0x0B4 188 - #define S6_GMAC_STATRXPF_SIZE 12 189 - #define S6_GMAC_STATRXUO 0x0B8 190 - #define S6_GMAC_STATRXUO_SIZE 12 191 - #define S6_GMAC_STATRALN 0x0BC 192 - #define S6_GMAC_STATRALN_SIZE 12 193 - #define S6_GMAC_STATRFLR 0x0C0 194 - #define S6_GMAC_STATRFLR_SIZE 16 195 - #define S6_GMAC_STATRCDE 0x0C4 196 - #define S6_GMAC_STATRCDE_SIZE 12 197 - #define S6_GMAC_STATRCSE 0x0C8 198 - #define S6_GMAC_STATRCSE_SIZE 12 199 - #define S6_GMAC_STATRUND 0x0CC 200 - #define S6_GMAC_STATRUND_SIZE 12 201 - #define S6_GMAC_STATROVR 0x0D0 202 - #define S6_GMAC_STATROVR_SIZE 12 203 - #define S6_GMAC_STATRFRG 0x0D4 204 - #define S6_GMAC_STATRFRG_SIZE 12 205 - #define S6_GMAC_STATRJBR 0x0D8 206 - #define S6_GMAC_STATRJBR_SIZE 12 207 - #define S6_GMAC_STATRDRP 0x0DC 208 - #define S6_GMAC_STATRDRP_SIZE 12 209 - #define S6_GMAC_STATTBYT 0x0E0 210 - #define S6_GMAC_STATTBYT_SIZE 24 211 - #define S6_GMAC_STATTPKT 0x0E4 212 - #define S6_GMAC_STATTPKT_SIZE 18 213 - #define S6_GMAC_STATTMCA 0x0E8 214 - #define S6_GMAC_STATTMCA_SIZE 18 215 - #define S6_GMAC_STATTBCA 0x0EC 216 - #define S6_GMAC_STATTBCA_SIZE 18 217 - #define S6_GMAC_STATTXPF 0x0F0 218 - #define S6_GMAC_STATTXPF_SIZE 12 219 - #define S6_GMAC_STATTDFR 0x0F4 220 - #define S6_GMAC_STATTDFR_SIZE 12 221 - #define S6_GMAC_STATTEDF 0x0F8 222 - #define S6_GMAC_STATTEDF_SIZE 12 223 - #define S6_GMAC_STATTSCL 0x0FC 224 - #define S6_GMAC_STATTSCL_SIZE 12 225 - #define S6_GMAC_STATTMCL 0x100 226 - #define S6_GMAC_STATTMCL_SIZE 12 227 - #define S6_GMAC_STATTLCL 0x104 228 - #define S6_GMAC_STATTLCL_SIZE 12 229 - #define S6_GMAC_STATTXCL 0x108 230 - #define S6_GMAC_STATTXCL_SIZE 12 231 - #define S6_GMAC_STATTNCL 0x10C 232 - #define S6_GMAC_STATTNCL_SIZE 13 233 - #define S6_GMAC_STATTPFH 0x110 234 - #define S6_GMAC_STATTPFH_SIZE 12 235 - #define S6_GMAC_STATTDRP 0x114 236 - #define S6_GMAC_STATTDRP_SIZE 12 237 - #define S6_GMAC_STATTJBR 0x118 238 - #define S6_GMAC_STATTJBR_SIZE 12 239 - #define S6_GMAC_STATTFCS 0x11C 240 - #define S6_GMAC_STATTFCS_SIZE 12 241 - #define S6_GMAC_STATTXCF 0x120 242 - #define S6_GMAC_STATTXCF_SIZE 12 243 - #define S6_GMAC_STATTOVR 0x124 244 - #define S6_GMAC_STATTOVR_SIZE 12 245 - #define S6_GMAC_STATTUND 0x128 246 - #define S6_GMAC_STATTUND_SIZE 12 247 - #define S6_GMAC_STATTFRG 0x12C 248 - #define S6_GMAC_STATTFRG_SIZE 12 249 - #define S6_GMAC_STATCARRY(n) (0x130 + 4*(n)) 250 - #define S6_GMAC_STATCARRYMSK(n) (0x138 + 4*(n)) 251 - #define S6_GMAC_STATCARRY1_RDRP 0 252 - #define S6_GMAC_STATCARRY1_RJBR 1 253 - #define S6_GMAC_STATCARRY1_RFRG 2 254 - #define S6_GMAC_STATCARRY1_ROVR 3 255 - #define S6_GMAC_STATCARRY1_RUND 4 256 - #define S6_GMAC_STATCARRY1_RCSE 5 257 - #define S6_GMAC_STATCARRY1_RCDE 6 258 - #define S6_GMAC_STATCARRY1_RFLR 7 259 - #define S6_GMAC_STATCARRY1_RALN 8 260 - #define S6_GMAC_STATCARRY1_RXUO 9 261 - #define S6_GMAC_STATCARRY1_RXPF 10 262 - #define S6_GMAC_STATCARRY1_RXCF 11 263 - #define S6_GMAC_STATCARRY1_RBCA 12 264 - #define S6_GMAC_STATCARRY1_RMCA 13 265 - #define S6_GMAC_STATCARRY1_RFCS 14 266 - #define S6_GMAC_STATCARRY1_RPKT 15 267 - #define S6_GMAC_STATCARRY1_RBYT 16 268 - #define S6_GMAC_STATCARRY1_TRMGV 25 269 - #define S6_GMAC_STATCARRY1_TRMAX 26 270 - #define S6_GMAC_STATCARRY1_TR1K 27 271 - #define S6_GMAC_STATCARRY1_TR511 28 272 - #define S6_GMAC_STATCARRY1_TR255 29 273 - #define S6_GMAC_STATCARRY1_TR127 30 274 - #define S6_GMAC_STATCARRY1_TR64 31 275 - #define S6_GMAC_STATCARRY2_TDRP 0 276 - #define S6_GMAC_STATCARRY2_TPFH 1 277 - #define S6_GMAC_STATCARRY2_TNCL 2 278 - #define S6_GMAC_STATCARRY2_TXCL 3 279 - #define S6_GMAC_STATCARRY2_TLCL 4 280 - #define S6_GMAC_STATCARRY2_TMCL 5 281 - #define S6_GMAC_STATCARRY2_TSCL 6 282 - #define S6_GMAC_STATCARRY2_TEDF 7 283 - #define S6_GMAC_STATCARRY2_TDFR 8 284 - #define S6_GMAC_STATCARRY2_TXPF 9 285 - #define S6_GMAC_STATCARRY2_TBCA 10 286 - #define S6_GMAC_STATCARRY2_TMCA 11 287 - #define S6_GMAC_STATCARRY2_TPKT 12 288 - #define S6_GMAC_STATCARRY2_TBYT 13 289 - #define S6_GMAC_STATCARRY2_TFRG 14 290 - #define S6_GMAC_STATCARRY2_TUND 15 291 - #define S6_GMAC_STATCARRY2_TOVR 16 292 - #define S6_GMAC_STATCARRY2_TXCF 17 293 - #define S6_GMAC_STATCARRY2_TFCS 18 294 - #define S6_GMAC_STATCARRY2_TJBR 19 295 - 296 - #define S6_GMAC_HOST_PBLKCTRL 0x140 297 - #define S6_GMAC_HOST_PBLKCTRL_TXENA 0 298 - #define S6_GMAC_HOST_PBLKCTRL_RXENA 1 299 - #define S6_GMAC_HOST_PBLKCTRL_TXSRES 2 300 - #define S6_GMAC_HOST_PBLKCTRL_RXSRES 3 301 - #define S6_GMAC_HOST_PBLKCTRL_TXBSIZ 8 302 - #define S6_GMAC_HOST_PBLKCTRL_RXBSIZ 12 303 - #define S6_GMAC_HOST_PBLKCTRL_SIZ_16 4 304 - #define S6_GMAC_HOST_PBLKCTRL_SIZ_32 5 305 - #define S6_GMAC_HOST_PBLKCTRL_SIZ_64 6 306 - #define S6_GMAC_HOST_PBLKCTRL_SIZ_128 7 307 - #define S6_GMAC_HOST_PBLKCTRL_SIZ_MASK 0xF 308 - #define S6_GMAC_HOST_PBLKCTRL_STATENA 16 309 - #define S6_GMAC_HOST_PBLKCTRL_STATAUTOZ 17 310 - #define S6_GMAC_HOST_PBLKCTRL_STATCLEAR 18 311 - #define S6_GMAC_HOST_PBLKCTRL_RGMII 19 312 - #define S6_GMAC_HOST_INTMASK 0x144 313 - #define S6_GMAC_HOST_INTSTAT 0x148 314 - #define S6_GMAC_HOST_INT_TXBURSTOVER 3 315 - #define S6_GMAC_HOST_INT_TXPREWOVER 4 316 - #define S6_GMAC_HOST_INT_RXBURSTUNDER 5 317 - #define S6_GMAC_HOST_INT_RXPOSTRFULL 6 318 - #define S6_GMAC_HOST_INT_RXPOSTRUNDER 7 319 - #define S6_GMAC_HOST_RXFIFOHWM 0x14C 320 - #define S6_GMAC_HOST_CTRLFRAMXP 0x150 321 - #define S6_GMAC_HOST_DSTADDRLO(n) (0x160 + 8*(n)) 322 - #define S6_GMAC_HOST_DSTADDRHI(n) (0x164 + 8*(n)) 323 - #define S6_GMAC_HOST_DSTMASKLO(n) (0x180 + 8*(n)) 324 - #define S6_GMAC_HOST_DSTMASKHI(n) (0x184 + 8*(n)) 325 - 326 - #define S6_GMAC_BURST_PREWR 0x1B0 327 - #define S6_GMAC_BURST_PREWR_LEN 0 328 - #define S6_GMAC_BURST_PREWR_LEN_MASK ((1 << 20) - 1) 329 - #define S6_GMAC_BURST_PREWR_CFE 20 330 - #define S6_GMAC_BURST_PREWR_PPE 21 331 - #define S6_GMAC_BURST_PREWR_FCS 22 332 - #define S6_GMAC_BURST_PREWR_PAD 23 333 - #define S6_GMAC_BURST_POSTRD 0x1D0 334 - #define S6_GMAC_BURST_POSTRD_LEN 0 335 - #define S6_GMAC_BURST_POSTRD_LEN_MASK ((1 << 20) - 1) 336 - #define S6_GMAC_BURST_POSTRD_DROP 20 337 - 338 - 339 - /* data handling */ 340 - 341 - #define S6_NUM_TX_SKB 8 /* must be larger than TX fifo size */ 342 - #define S6_NUM_RX_SKB 16 343 - #define S6_MAX_FRLEN 1536 344 - 345 - struct s6gmac { 346 - u32 reg; 347 - u32 tx_dma; 348 - u32 rx_dma; 349 - u32 io; 350 - u8 tx_chan; 351 - u8 rx_chan; 352 - spinlock_t lock; 353 - u8 tx_skb_i, tx_skb_o; 354 - u8 rx_skb_i, rx_skb_o; 355 - struct sk_buff *tx_skb[S6_NUM_TX_SKB]; 356 - struct sk_buff *rx_skb[S6_NUM_RX_SKB]; 357 - unsigned long carry[sizeof(struct net_device_stats) / sizeof(long)]; 358 - unsigned long stats[sizeof(struct net_device_stats) / sizeof(long)]; 359 - struct phy_device *phydev; 360 - struct { 361 - struct mii_bus *bus; 362 - int irq[PHY_MAX_ADDR]; 363 - } mii; 364 - struct { 365 - unsigned int mbit; 366 - u8 giga; 367 - u8 isup; 368 - u8 full; 369 - } link; 370 - }; 371 - 372 - static void s6gmac_rx_fillfifo(struct net_device *dev) 373 - { 374 - struct s6gmac *pd = netdev_priv(dev); 375 - struct sk_buff *skb; 376 - while ((((u8)(pd->rx_skb_i - pd->rx_skb_o)) < S6_NUM_RX_SKB) && 377 - (!s6dmac_fifo_full(pd->rx_dma, pd->rx_chan)) && 378 - (skb = netdev_alloc_skb(dev, S6_MAX_FRLEN + 2))) { 379 - pd->rx_skb[(pd->rx_skb_i++) % S6_NUM_RX_SKB] = skb; 380 - s6dmac_put_fifo_cache(pd->rx_dma, pd->rx_chan, 381 - pd->io, (u32)skb->data, S6_MAX_FRLEN); 382 - } 383 - } 384 - 385 - static void s6gmac_rx_interrupt(struct net_device *dev) 386 - { 387 - struct s6gmac *pd = netdev_priv(dev); 388 - u32 pfx; 389 - struct sk_buff *skb; 390 - while (((u8)(pd->rx_skb_i - pd->rx_skb_o)) > 391 - s6dmac_pending_count(pd->rx_dma, pd->rx_chan)) { 392 - skb = pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB]; 393 - pfx = readl(pd->reg + S6_GMAC_BURST_POSTRD); 394 - if (pfx & (1 << S6_GMAC_BURST_POSTRD_DROP)) { 395 - dev_kfree_skb_irq(skb); 396 - } else { 397 - skb_put(skb, (pfx >> S6_GMAC_BURST_POSTRD_LEN) 398 - & S6_GMAC_BURST_POSTRD_LEN_MASK); 399 - skb->protocol = eth_type_trans(skb, dev); 400 - skb->ip_summed = CHECKSUM_UNNECESSARY; 401 - netif_rx(skb); 402 - } 403 - } 404 - } 405 - 406 - static void s6gmac_tx_interrupt(struct net_device *dev) 407 - { 408 - struct s6gmac *pd = netdev_priv(dev); 409 - while (((u8)(pd->tx_skb_i - pd->tx_skb_o)) > 410 - s6dmac_pending_count(pd->tx_dma, pd->tx_chan)) { 411 - dev_kfree_skb_irq(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]); 412 - } 413 - if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan)) 414 - netif_wake_queue(dev); 415 - } 416 - 417 - struct s6gmac_statinf { 418 - unsigned reg_size : 4; /* 0: unused */ 419 - unsigned reg_off : 6; 420 - unsigned net_index : 6; 421 - }; 422 - 423 - #define S6_STATS_B (8 * sizeof(u32)) 424 - #define S6_STATS_C(b, r, f) [b] = { \ 425 - BUILD_BUG_ON_ZERO(r##_SIZE < S6_GMAC_STAT_SIZE_MIN) + \ 426 - BUILD_BUG_ON_ZERO((r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1)) \ 427 - >= (1<<4)) + \ 428 - r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1), \ 429 - BUILD_BUG_ON_ZERO(((unsigned)((r - S6_GMAC_STAT_REGS) / sizeof(u32))) \ 430 - >= ((1<<6)-1)) + \ 431 - (r - S6_GMAC_STAT_REGS) / sizeof(u32), \ 432 - BUILD_BUG_ON_ZERO((offsetof(struct net_device_stats, f)) \ 433 - % sizeof(unsigned long)) + \ 434 - BUILD_BUG_ON_ZERO((((unsigned)(offsetof(struct net_device_stats, f)) \ 435 - / sizeof(unsigned long)) >= (1<<6))) + \ 436 - BUILD_BUG_ON_ZERO((sizeof(((struct net_device_stats *)0)->f) \ 437 - != sizeof(unsigned long))) + \ 438 - (offsetof(struct net_device_stats, f)) / sizeof(unsigned long)}, 439 - 440 - static const struct s6gmac_statinf statinf[2][S6_STATS_B] = { { 441 - S6_STATS_C(S6_GMAC_STATCARRY1_RBYT, S6_GMAC_STATRBYT, rx_bytes) 442 - S6_STATS_C(S6_GMAC_STATCARRY1_RPKT, S6_GMAC_STATRPKT, rx_packets) 443 - S6_STATS_C(S6_GMAC_STATCARRY1_RFCS, S6_GMAC_STATRFCS, rx_crc_errors) 444 - S6_STATS_C(S6_GMAC_STATCARRY1_RMCA, S6_GMAC_STATRMCA, multicast) 445 - S6_STATS_C(S6_GMAC_STATCARRY1_RALN, S6_GMAC_STATRALN, rx_frame_errors) 446 - S6_STATS_C(S6_GMAC_STATCARRY1_RFLR, S6_GMAC_STATRFLR, rx_length_errors) 447 - S6_STATS_C(S6_GMAC_STATCARRY1_RCDE, S6_GMAC_STATRCDE, rx_missed_errors) 448 - S6_STATS_C(S6_GMAC_STATCARRY1_RUND, S6_GMAC_STATRUND, rx_length_errors) 449 - S6_STATS_C(S6_GMAC_STATCARRY1_ROVR, S6_GMAC_STATROVR, rx_length_errors) 450 - S6_STATS_C(S6_GMAC_STATCARRY1_RFRG, S6_GMAC_STATRFRG, rx_crc_errors) 451 - S6_STATS_C(S6_GMAC_STATCARRY1_RJBR, S6_GMAC_STATRJBR, rx_crc_errors) 452 - S6_STATS_C(S6_GMAC_STATCARRY1_RDRP, S6_GMAC_STATRDRP, rx_dropped) 453 - }, { 454 - S6_STATS_C(S6_GMAC_STATCARRY2_TBYT, S6_GMAC_STATTBYT, tx_bytes) 455 - S6_STATS_C(S6_GMAC_STATCARRY2_TPKT, S6_GMAC_STATTPKT, tx_packets) 456 - S6_STATS_C(S6_GMAC_STATCARRY2_TEDF, S6_GMAC_STATTEDF, tx_aborted_errors) 457 - S6_STATS_C(S6_GMAC_STATCARRY2_TXCL, S6_GMAC_STATTXCL, tx_aborted_errors) 458 - S6_STATS_C(S6_GMAC_STATCARRY2_TNCL, S6_GMAC_STATTNCL, collisions) 459 - S6_STATS_C(S6_GMAC_STATCARRY2_TDRP, S6_GMAC_STATTDRP, tx_dropped) 460 - S6_STATS_C(S6_GMAC_STATCARRY2_TJBR, S6_GMAC_STATTJBR, tx_errors) 461 - S6_STATS_C(S6_GMAC_STATCARRY2_TFCS, S6_GMAC_STATTFCS, tx_errors) 462 - S6_STATS_C(S6_GMAC_STATCARRY2_TOVR, S6_GMAC_STATTOVR, tx_errors) 463 - S6_STATS_C(S6_GMAC_STATCARRY2_TUND, S6_GMAC_STATTUND, tx_errors) 464 - S6_STATS_C(S6_GMAC_STATCARRY2_TFRG, S6_GMAC_STATTFRG, tx_errors) 465 - } }; 466 - 467 - static void s6gmac_stats_collect(struct s6gmac *pd, 468 - const struct s6gmac_statinf *inf) 469 - { 470 - int b; 471 - for (b = 0; b < S6_STATS_B; b++) { 472 - if (inf[b].reg_size) { 473 - pd->stats[inf[b].net_index] += 474 - readl(pd->reg + S6_GMAC_STAT_REGS 475 - + sizeof(u32) * inf[b].reg_off); 476 - } 477 - } 478 - } 479 - 480 - static void s6gmac_stats_carry(struct s6gmac *pd, 481 - const struct s6gmac_statinf *inf, u32 mask) 482 - { 483 - int b; 484 - while (mask) { 485 - b = fls(mask) - 1; 486 - mask &= ~(1 << b); 487 - pd->carry[inf[b].net_index] += (1 << inf[b].reg_size); 488 - } 489 - } 490 - 491 - static inline u32 s6gmac_stats_pending(struct s6gmac *pd, int carry) 492 - { 493 - int r = readl(pd->reg + S6_GMAC_STATCARRY(carry)) & 494 - ~readl(pd->reg + S6_GMAC_STATCARRYMSK(carry)); 495 - return r; 496 - } 497 - 498 - static inline void s6gmac_stats_interrupt(struct s6gmac *pd, int carry) 499 - { 500 - u32 mask; 501 - mask = s6gmac_stats_pending(pd, carry); 502 - if (mask) { 503 - writel(mask, pd->reg + S6_GMAC_STATCARRY(carry)); 504 - s6gmac_stats_carry(pd, &statinf[carry][0], mask); 505 - } 506 - } 507 - 508 - static irqreturn_t s6gmac_interrupt(int irq, void *dev_id) 509 - { 510 - struct net_device *dev = (struct net_device *)dev_id; 511 - struct s6gmac *pd = netdev_priv(dev); 512 - if (!dev) 513 - return IRQ_NONE; 514 - spin_lock(&pd->lock); 515 - if (s6dmac_termcnt_irq(pd->rx_dma, pd->rx_chan)) 516 - s6gmac_rx_interrupt(dev); 517 - s6gmac_rx_fillfifo(dev); 518 - if (s6dmac_termcnt_irq(pd->tx_dma, pd->tx_chan)) 519 - s6gmac_tx_interrupt(dev); 520 - s6gmac_stats_interrupt(pd, 0); 521 - s6gmac_stats_interrupt(pd, 1); 522 - spin_unlock(&pd->lock); 523 - return IRQ_HANDLED; 524 - } 525 - 526 - static inline void s6gmac_set_dstaddr(struct s6gmac *pd, int n, 527 - u32 addrlo, u32 addrhi, u32 masklo, u32 maskhi) 528 - { 529 - writel(addrlo, pd->reg + S6_GMAC_HOST_DSTADDRLO(n)); 530 - writel(addrhi, pd->reg + S6_GMAC_HOST_DSTADDRHI(n)); 531 - writel(masklo, pd->reg + S6_GMAC_HOST_DSTMASKLO(n)); 532 - writel(maskhi, pd->reg + S6_GMAC_HOST_DSTMASKHI(n)); 533 - } 534 - 535 - static inline void s6gmac_stop_device(struct net_device *dev) 536 - { 537 - struct s6gmac *pd = netdev_priv(dev); 538 - writel(0, pd->reg + S6_GMAC_MACCONF1); 539 - } 540 - 541 - static inline void s6gmac_init_device(struct net_device *dev) 542 - { 543 - struct s6gmac *pd = netdev_priv(dev); 544 - int is_rgmii = !!(pd->phydev->supported 545 - & (SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Half)); 546 - #if 0 547 - writel(1 << S6_GMAC_MACCONF1_SYNCTX | 548 - 1 << S6_GMAC_MACCONF1_SYNCRX | 549 - 1 << S6_GMAC_MACCONF1_TXFLOWCTRL | 550 - 1 << S6_GMAC_MACCONF1_RXFLOWCTRL | 551 - 1 << S6_GMAC_MACCONF1_RESTXFUNC | 552 - 1 << S6_GMAC_MACCONF1_RESRXFUNC | 553 - 1 << S6_GMAC_MACCONF1_RESTXMACCTRL | 554 - 1 << S6_GMAC_MACCONF1_RESRXMACCTRL, 555 - pd->reg + S6_GMAC_MACCONF1); 556 - #endif 557 - writel(1 << S6_GMAC_MACCONF1_SOFTRES, pd->reg + S6_GMAC_MACCONF1); 558 - udelay(1000); 559 - writel(1 << S6_GMAC_MACCONF1_TXENA | 1 << S6_GMAC_MACCONF1_RXENA, 560 - pd->reg + S6_GMAC_MACCONF1); 561 - writel(1 << S6_GMAC_HOST_PBLKCTRL_TXSRES | 562 - 1 << S6_GMAC_HOST_PBLKCTRL_RXSRES, 563 - pd->reg + S6_GMAC_HOST_PBLKCTRL); 564 - writel(S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_TXBSIZ | 565 - S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_RXBSIZ | 566 - 1 << S6_GMAC_HOST_PBLKCTRL_STATENA | 567 - 1 << S6_GMAC_HOST_PBLKCTRL_STATCLEAR | 568 - is_rgmii << S6_GMAC_HOST_PBLKCTRL_RGMII, 569 - pd->reg + S6_GMAC_HOST_PBLKCTRL); 570 - writel(1 << S6_GMAC_MACCONF1_TXENA | 571 - 1 << S6_GMAC_MACCONF1_RXENA | 572 - (dev->flags & IFF_LOOPBACK ? 1 : 0) 573 - << S6_GMAC_MACCONF1_LOOPBACK, 574 - pd->reg + S6_GMAC_MACCONF1); 575 - writel(dev->mtu && (dev->mtu < (S6_MAX_FRLEN - ETH_HLEN-ETH_FCS_LEN)) ? 576 - dev->mtu+ETH_HLEN+ETH_FCS_LEN : S6_MAX_FRLEN, 577 - pd->reg + S6_GMAC_MACMAXFRAMELEN); 578 - writel((pd->link.full ? 1 : 0) << S6_GMAC_MACCONF2_FULL | 579 - 1 << S6_GMAC_MACCONF2_PADCRCENA | 580 - 1 << S6_GMAC_MACCONF2_LENGTHFCHK | 581 - (pd->link.giga ? 582 - S6_GMAC_MACCONF2_IFMODE_BYTE : 583 - S6_GMAC_MACCONF2_IFMODE_NIBBLE) 584 - << S6_GMAC_MACCONF2_IFMODE | 585 - 7 << S6_GMAC_MACCONF2_PREAMBLELEN, 586 - pd->reg + S6_GMAC_MACCONF2); 587 - writel(0, pd->reg + S6_GMAC_MACSTATADDR1); 588 - writel(0, pd->reg + S6_GMAC_MACSTATADDR2); 589 - writel(1 << S6_GMAC_FIFOCONF0_WTMENREQ | 590 - 1 << S6_GMAC_FIFOCONF0_SRFENREQ | 591 - 1 << S6_GMAC_FIFOCONF0_FRFENREQ | 592 - 1 << S6_GMAC_FIFOCONF0_STFENREQ | 593 - 1 << S6_GMAC_FIFOCONF0_FTFENREQ, 594 - pd->reg + S6_GMAC_FIFOCONF0); 595 - writel(128 << S6_GMAC_FIFOCONF3_CFGFTTH | 596 - 128 << S6_GMAC_FIFOCONF3_CFGHWMFT, 597 - pd->reg + S6_GMAC_FIFOCONF3); 598 - writel((S6_GMAC_FIFOCONF_RSV_MASK & ~( 599 - 1 << S6_GMAC_FIFOCONF_RSV_RUNT | 600 - 1 << S6_GMAC_FIFOCONF_RSV_CRCERR | 601 - 1 << S6_GMAC_FIFOCONF_RSV_OK | 602 - 1 << S6_GMAC_FIFOCONF_RSV_DRIBBLE | 603 - 1 << S6_GMAC_FIFOCONF_RSV_CTRLFRAME | 604 - 1 << S6_GMAC_FIFOCONF_RSV_PAUSECTRL | 605 - 1 << S6_GMAC_FIFOCONF_RSV_UNOPCODE | 606 - 1 << S6_GMAC_FIFOCONF_RSV_TRUNCATED)) | 607 - 1 << S6_GMAC_FIFOCONF5_DROPLT64 | 608 - pd->link.giga << S6_GMAC_FIFOCONF5_CFGBYTM | 609 - 1 << S6_GMAC_FIFOCONF5_RXDROPSIZE, 610 - pd->reg + S6_GMAC_FIFOCONF5); 611 - writel(1 << S6_GMAC_FIFOCONF_RSV_RUNT | 612 - 1 << S6_GMAC_FIFOCONF_RSV_CRCERR | 613 - 1 << S6_GMAC_FIFOCONF_RSV_DRIBBLE | 614 - 1 << S6_GMAC_FIFOCONF_RSV_CTRLFRAME | 615 - 1 << S6_GMAC_FIFOCONF_RSV_PAUSECTRL | 616 - 1 << S6_GMAC_FIFOCONF_RSV_UNOPCODE | 617 - 1 << S6_GMAC_FIFOCONF_RSV_TRUNCATED, 618 - pd->reg + S6_GMAC_FIFOCONF4); 619 - s6gmac_set_dstaddr(pd, 0, 620 - 0xFFFFFFFF, 0x0000FFFF, 0xFFFFFFFF, 0x0000FFFF); 621 - s6gmac_set_dstaddr(pd, 1, 622 - dev->dev_addr[5] | 623 - dev->dev_addr[4] << 8 | 624 - dev->dev_addr[3] << 16 | 625 - dev->dev_addr[2] << 24, 626 - dev->dev_addr[1] | 627 - dev->dev_addr[0] << 8, 628 - 0xFFFFFFFF, 0x0000FFFF); 629 - s6gmac_set_dstaddr(pd, 2, 630 - 0x00000000, 0x00000100, 0x00000000, 0x00000100); 631 - s6gmac_set_dstaddr(pd, 3, 632 - 0x00000000, 0x00000000, 0x00000000, 0x00000000); 633 - writel(1 << S6_GMAC_HOST_PBLKCTRL_TXENA | 634 - 1 << S6_GMAC_HOST_PBLKCTRL_RXENA | 635 - S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_TXBSIZ | 636 - S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_RXBSIZ | 637 - 1 << S6_GMAC_HOST_PBLKCTRL_STATENA | 638 - 1 << S6_GMAC_HOST_PBLKCTRL_STATCLEAR | 639 - is_rgmii << S6_GMAC_HOST_PBLKCTRL_RGMII, 640 - pd->reg + S6_GMAC_HOST_PBLKCTRL); 641 - } 642 - 643 - static void s6mii_enable(struct s6gmac *pd) 644 - { 645 - writel(readl(pd->reg + S6_GMAC_MACCONF1) & 646 - ~(1 << S6_GMAC_MACCONF1_SOFTRES), 647 - pd->reg + S6_GMAC_MACCONF1); 648 - writel((readl(pd->reg + S6_GMAC_MACMIICONF) 649 - & ~(S6_GMAC_MACMIICONF_CSEL_MASK << S6_GMAC_MACMIICONF_CSEL)) 650 - | (S6_GMAC_MACMIICONF_CSEL_DIV168 << S6_GMAC_MACMIICONF_CSEL), 651 - pd->reg + S6_GMAC_MACMIICONF); 652 - } 653 - 654 - static int s6mii_busy(struct s6gmac *pd, int tmo) 655 - { 656 - while (readl(pd->reg + S6_GMAC_MACMIIINDI)) { 657 - if (--tmo == 0) 658 - return -ETIME; 659 - udelay(64); 660 - } 661 - return 0; 662 - } 663 - 664 - static int s6mii_read(struct mii_bus *bus, int phy_addr, int regnum) 665 - { 666 - struct s6gmac *pd = bus->priv; 667 - s6mii_enable(pd); 668 - if (s6mii_busy(pd, 256)) 669 - return -ETIME; 670 - writel(phy_addr << S6_GMAC_MACMIIADDR_PHY | 671 - regnum << S6_GMAC_MACMIIADDR_REG, 672 - pd->reg + S6_GMAC_MACMIIADDR); 673 - writel(1 << S6_GMAC_MACMIICMD_READ, pd->reg + S6_GMAC_MACMIICMD); 674 - writel(0, pd->reg + S6_GMAC_MACMIICMD); 675 - if (s6mii_busy(pd, 256)) 676 - return -ETIME; 677 - return (u16)readl(pd->reg + S6_GMAC_MACMIISTAT); 678 - } 679 - 680 - static int s6mii_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value) 681 - { 682 - struct s6gmac *pd = bus->priv; 683 - s6mii_enable(pd); 684 - if (s6mii_busy(pd, 256)) 685 - return -ETIME; 686 - writel(phy_addr << S6_GMAC_MACMIIADDR_PHY | 687 - regnum << S6_GMAC_MACMIIADDR_REG, 688 - pd->reg + S6_GMAC_MACMIIADDR); 689 - writel(value, pd->reg + S6_GMAC_MACMIICTRL); 690 - if (s6mii_busy(pd, 256)) 691 - return -ETIME; 692 - return 0; 693 - } 694 - 695 - static int s6mii_reset(struct mii_bus *bus) 696 - { 697 - struct s6gmac *pd = bus->priv; 698 - s6mii_enable(pd); 699 - if (s6mii_busy(pd, PHY_INIT_TIMEOUT)) 700 - return -ETIME; 701 - return 0; 702 - } 703 - 704 - static void s6gmac_set_rgmii_txclock(struct s6gmac *pd) 705 - { 706 - u32 pllsel = readl(S6_REG_GREG1 + S6_GREG1_PLLSEL); 707 - pllsel &= ~(S6_GREG1_PLLSEL_GMAC_MASK << S6_GREG1_PLLSEL_GMAC); 708 - switch (pd->link.mbit) { 709 - case 10: 710 - pllsel |= S6_GREG1_PLLSEL_GMAC_2500KHZ << S6_GREG1_PLLSEL_GMAC; 711 - break; 712 - case 100: 713 - pllsel |= S6_GREG1_PLLSEL_GMAC_25MHZ << S6_GREG1_PLLSEL_GMAC; 714 - break; 715 - case 1000: 716 - pllsel |= S6_GREG1_PLLSEL_GMAC_125MHZ << S6_GREG1_PLLSEL_GMAC; 717 - break; 718 - default: 719 - return; 720 - } 721 - writel(pllsel, S6_REG_GREG1 + S6_GREG1_PLLSEL); 722 - } 723 - 724 - static inline void s6gmac_linkisup(struct net_device *dev, int isup) 725 - { 726 - struct s6gmac *pd = netdev_priv(dev); 727 - struct phy_device *phydev = pd->phydev; 728 - 729 - pd->link.full = phydev->duplex; 730 - pd->link.giga = (phydev->speed == 1000); 731 - if (pd->link.mbit != phydev->speed) { 732 - pd->link.mbit = phydev->speed; 733 - s6gmac_set_rgmii_txclock(pd); 734 - } 735 - pd->link.isup = isup; 736 - if (isup) 737 - netif_carrier_on(dev); 738 - phy_print_status(phydev); 739 - } 740 - 741 - static void s6gmac_adjust_link(struct net_device *dev) 742 - { 743 - struct s6gmac *pd = netdev_priv(dev); 744 - struct phy_device *phydev = pd->phydev; 745 - if (pd->link.isup && 746 - (!phydev->link || 747 - (pd->link.mbit != phydev->speed) || 748 - (pd->link.full != phydev->duplex))) { 749 - pd->link.isup = 0; 750 - netif_tx_disable(dev); 751 - if (!phydev->link) { 752 - netif_carrier_off(dev); 753 - phy_print_status(phydev); 754 - } 755 - } 756 - if (!pd->link.isup && phydev->link) { 757 - if (pd->link.full != phydev->duplex) { 758 - u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2); 759 - if (phydev->duplex) 760 - maccfg |= 1 << S6_GMAC_MACCONF2_FULL; 761 - else 762 - maccfg &= ~(1 << S6_GMAC_MACCONF2_FULL); 763 - writel(maccfg, pd->reg + S6_GMAC_MACCONF2); 764 - } 765 - 766 - if (pd->link.giga != (phydev->speed == 1000)) { 767 - u32 fifocfg = readl(pd->reg + S6_GMAC_FIFOCONF5); 768 - u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2); 769 - maccfg &= ~(S6_GMAC_MACCONF2_IFMODE_MASK 770 - << S6_GMAC_MACCONF2_IFMODE); 771 - if (phydev->speed == 1000) { 772 - fifocfg |= 1 << S6_GMAC_FIFOCONF5_CFGBYTM; 773 - maccfg |= S6_GMAC_MACCONF2_IFMODE_BYTE 774 - << S6_GMAC_MACCONF2_IFMODE; 775 - } else { 776 - fifocfg &= ~(1 << S6_GMAC_FIFOCONF5_CFGBYTM); 777 - maccfg |= S6_GMAC_MACCONF2_IFMODE_NIBBLE 778 - << S6_GMAC_MACCONF2_IFMODE; 779 - } 780 - writel(fifocfg, pd->reg + S6_GMAC_FIFOCONF5); 781 - writel(maccfg, pd->reg + S6_GMAC_MACCONF2); 782 - } 783 - 784 - if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan)) 785 - netif_wake_queue(dev); 786 - s6gmac_linkisup(dev, 1); 787 - } 788 - } 789 - 790 - static inline int s6gmac_phy_start(struct net_device *dev) 791 - { 792 - struct s6gmac *pd = netdev_priv(dev); 793 - int i = 0; 794 - struct phy_device *p = NULL; 795 - while ((i < PHY_MAX_ADDR) && (!(p = pd->mii.bus->phy_map[i]))) 796 - i++; 797 - p = phy_connect(dev, dev_name(&p->dev), &s6gmac_adjust_link, 798 - PHY_INTERFACE_MODE_RGMII); 799 - if (IS_ERR(p)) { 800 - printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 801 - return PTR_ERR(p); 802 - } 803 - p->supported &= PHY_GBIT_FEATURES; 804 - p->advertising = p->supported; 805 - pd->phydev = p; 806 - return 0; 807 - } 808 - 809 - static inline void s6gmac_init_stats(struct net_device *dev) 810 - { 811 - struct s6gmac *pd = netdev_priv(dev); 812 - u32 mask; 813 - mask = 1 << S6_GMAC_STATCARRY1_RDRP | 814 - 1 << S6_GMAC_STATCARRY1_RJBR | 815 - 1 << S6_GMAC_STATCARRY1_RFRG | 816 - 1 << S6_GMAC_STATCARRY1_ROVR | 817 - 1 << S6_GMAC_STATCARRY1_RUND | 818 - 1 << S6_GMAC_STATCARRY1_RCDE | 819 - 1 << S6_GMAC_STATCARRY1_RFLR | 820 - 1 << S6_GMAC_STATCARRY1_RALN | 821 - 1 << S6_GMAC_STATCARRY1_RMCA | 822 - 1 << S6_GMAC_STATCARRY1_RFCS | 823 - 1 << S6_GMAC_STATCARRY1_RPKT | 824 - 1 << S6_GMAC_STATCARRY1_RBYT; 825 - writel(mask, pd->reg + S6_GMAC_STATCARRY(0)); 826 - writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(0)); 827 - mask = 1 << S6_GMAC_STATCARRY2_TDRP | 828 - 1 << S6_GMAC_STATCARRY2_TNCL | 829 - 1 << S6_GMAC_STATCARRY2_TXCL | 830 - 1 << S6_GMAC_STATCARRY2_TEDF | 831 - 1 << S6_GMAC_STATCARRY2_TPKT | 832 - 1 << S6_GMAC_STATCARRY2_TBYT | 833 - 1 << S6_GMAC_STATCARRY2_TFRG | 834 - 1 << S6_GMAC_STATCARRY2_TUND | 835 - 1 << S6_GMAC_STATCARRY2_TOVR | 836 - 1 << S6_GMAC_STATCARRY2_TFCS | 837 - 1 << S6_GMAC_STATCARRY2_TJBR; 838 - writel(mask, pd->reg + S6_GMAC_STATCARRY(1)); 839 - writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(1)); 840 - } 841 - 842 - static inline void s6gmac_init_dmac(struct net_device *dev) 843 - { 844 - struct s6gmac *pd = netdev_priv(dev); 845 - s6dmac_disable_chan(pd->tx_dma, pd->tx_chan); 846 - s6dmac_disable_chan(pd->rx_dma, pd->rx_chan); 847 - s6dmac_disable_error_irqs(pd->tx_dma, 1 << S6_HIFDMA_GMACTX); 848 - s6dmac_disable_error_irqs(pd->rx_dma, 1 << S6_HIFDMA_GMACRX); 849 - } 850 - 851 - static int s6gmac_tx(struct sk_buff *skb, struct net_device *dev) 852 - { 853 - struct s6gmac *pd = netdev_priv(dev); 854 - unsigned long flags; 855 - 856 - spin_lock_irqsave(&pd->lock, flags); 857 - writel(skb->len << S6_GMAC_BURST_PREWR_LEN | 858 - 0 << S6_GMAC_BURST_PREWR_CFE | 859 - 1 << S6_GMAC_BURST_PREWR_PPE | 860 - 1 << S6_GMAC_BURST_PREWR_FCS | 861 - ((skb->len < ETH_ZLEN) ? 1 : 0) << S6_GMAC_BURST_PREWR_PAD, 862 - pd->reg + S6_GMAC_BURST_PREWR); 863 - s6dmac_put_fifo_cache(pd->tx_dma, pd->tx_chan, 864 - (u32)skb->data, pd->io, skb->len); 865 - if (s6dmac_fifo_full(pd->tx_dma, pd->tx_chan)) 866 - netif_stop_queue(dev); 867 - if (((u8)(pd->tx_skb_i - pd->tx_skb_o)) >= S6_NUM_TX_SKB) { 868 - printk(KERN_ERR "GMAC BUG: skb tx ring overflow [%x, %x]\n", 869 - pd->tx_skb_o, pd->tx_skb_i); 870 - BUG(); 871 - } 872 - pd->tx_skb[(pd->tx_skb_i++) % S6_NUM_TX_SKB] = skb; 873 - spin_unlock_irqrestore(&pd->lock, flags); 874 - return 0; 875 - } 876 - 877 - static void s6gmac_tx_timeout(struct net_device *dev) 878 - { 879 - struct s6gmac *pd = netdev_priv(dev); 880 - unsigned long flags; 881 - spin_lock_irqsave(&pd->lock, flags); 882 - s6gmac_tx_interrupt(dev); 883 - spin_unlock_irqrestore(&pd->lock, flags); 884 - } 885 - 886 - static int s6gmac_open(struct net_device *dev) 887 - { 888 - struct s6gmac *pd = netdev_priv(dev); 889 - unsigned long flags; 890 - phy_read_status(pd->phydev); 891 - spin_lock_irqsave(&pd->lock, flags); 892 - pd->link.mbit = 0; 893 - s6gmac_linkisup(dev, pd->phydev->link); 894 - s6gmac_init_device(dev); 895 - s6gmac_init_stats(dev); 896 - s6gmac_init_dmac(dev); 897 - s6gmac_rx_fillfifo(dev); 898 - s6dmac_enable_chan(pd->rx_dma, pd->rx_chan, 899 - 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1); 900 - s6dmac_enable_chan(pd->tx_dma, pd->tx_chan, 901 - 2, 0, 1, 0, 0, 0, 0, 7, -1, 2, 0, 1); 902 - writel(0 << S6_GMAC_HOST_INT_TXBURSTOVER | 903 - 0 << S6_GMAC_HOST_INT_TXPREWOVER | 904 - 0 << S6_GMAC_HOST_INT_RXBURSTUNDER | 905 - 0 << S6_GMAC_HOST_INT_RXPOSTRFULL | 906 - 0 << S6_GMAC_HOST_INT_RXPOSTRUNDER, 907 - pd->reg + S6_GMAC_HOST_INTMASK); 908 - spin_unlock_irqrestore(&pd->lock, flags); 909 - phy_start(pd->phydev); 910 - netif_start_queue(dev); 911 - return 0; 912 - } 913 - 914 - static int s6gmac_stop(struct net_device *dev) 915 - { 916 - struct s6gmac *pd = netdev_priv(dev); 917 - unsigned long flags; 918 - netif_stop_queue(dev); 919 - phy_stop(pd->phydev); 920 - spin_lock_irqsave(&pd->lock, flags); 921 - s6gmac_init_dmac(dev); 922 - s6gmac_stop_device(dev); 923 - while (pd->tx_skb_i != pd->tx_skb_o) 924 - dev_kfree_skb(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]); 925 - while (pd->rx_skb_i != pd->rx_skb_o) 926 - dev_kfree_skb(pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB]); 927 - spin_unlock_irqrestore(&pd->lock, flags); 928 - return 0; 929 - } 930 - 931 - static struct net_device_stats *s6gmac_stats(struct net_device *dev) 932 - { 933 - struct s6gmac *pd = netdev_priv(dev); 934 - struct net_device_stats *st = (struct net_device_stats *)&pd->stats; 935 - int i; 936 - do { 937 - unsigned long flags; 938 - spin_lock_irqsave(&pd->lock, flags); 939 - for (i = 0; i < ARRAY_SIZE(pd->stats); i++) 940 - pd->stats[i] = 941 - pd->carry[i] << (S6_GMAC_STAT_SIZE_MIN - 1); 942 - s6gmac_stats_collect(pd, &statinf[0][0]); 943 - s6gmac_stats_collect(pd, &statinf[1][0]); 944 - i = s6gmac_stats_pending(pd, 0) | 945 - s6gmac_stats_pending(pd, 1); 946 - spin_unlock_irqrestore(&pd->lock, flags); 947 - } while (i); 948 - st->rx_errors = st->rx_crc_errors + 949 - st->rx_frame_errors + 950 - st->rx_length_errors + 951 - st->rx_missed_errors; 952 - st->tx_errors += st->tx_aborted_errors; 953 - return st; 954 - } 955 - 956 - static int s6gmac_probe(struct platform_device *pdev) 957 - { 958 - struct net_device *dev; 959 - struct s6gmac *pd; 960 - int res; 961 - unsigned long i; 962 - struct mii_bus *mb; 963 - 964 - dev = alloc_etherdev(sizeof(*pd)); 965 - if (!dev) 966 - return -ENOMEM; 967 - 968 - dev->open = s6gmac_open; 969 - dev->stop = s6gmac_stop; 970 - dev->hard_start_xmit = s6gmac_tx; 971 - dev->tx_timeout = s6gmac_tx_timeout; 972 - dev->watchdog_timeo = HZ; 973 - dev->get_stats = s6gmac_stats; 974 - dev->irq = platform_get_irq(pdev, 0); 975 - pd = netdev_priv(dev); 976 - memset(pd, 0, sizeof(*pd)); 977 - spin_lock_init(&pd->lock); 978 - pd->reg = platform_get_resource(pdev, IORESOURCE_MEM, 0)->start; 979 - i = platform_get_resource(pdev, IORESOURCE_DMA, 0)->start; 980 - pd->tx_dma = DMA_MASK_DMAC(i); 981 - pd->tx_chan = DMA_INDEX_CHNL(i); 982 - i = platform_get_resource(pdev, IORESOURCE_DMA, 1)->start; 983 - pd->rx_dma = DMA_MASK_DMAC(i); 984 - pd->rx_chan = DMA_INDEX_CHNL(i); 985 - pd->io = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; 986 - res = request_irq(dev->irq, s6gmac_interrupt, 0, dev->name, dev); 987 - if (res) { 988 - printk(KERN_ERR DRV_PRMT "irq request failed: %d\n", dev->irq); 989 - goto errirq; 990 - } 991 - res = register_netdev(dev); 992 - if (res) { 993 - printk(KERN_ERR DRV_PRMT "error registering device %s\n", 994 - dev->name); 995 - goto errdev; 996 - } 997 - mb = mdiobus_alloc(); 998 - if (!mb) { 999 - printk(KERN_ERR DRV_PRMT "error allocating mii bus\n"); 1000 - res = -ENOMEM; 1001 - goto errmii; 1002 - } 1003 - mb->name = "s6gmac_mii"; 1004 - mb->read = s6mii_read; 1005 - mb->write = s6mii_write; 1006 - mb->reset = s6mii_reset; 1007 - mb->priv = pd; 1008 - snprintf(mb->id, MII_BUS_ID_SIZE, "%s-%x", pdev->name, pdev->id); 1009 - mb->phy_mask = ~(1 << 0); 1010 - mb->irq = &pd->mii.irq[0]; 1011 - for (i = 0; i < PHY_MAX_ADDR; i++) { 1012 - int n = platform_get_irq(pdev, i + 1); 1013 - if (n < 0) 1014 - n = PHY_POLL; 1015 - pd->mii.irq[i] = n; 1016 - } 1017 - mdiobus_register(mb); 1018 - pd->mii.bus = mb; 1019 - res = s6gmac_phy_start(dev); 1020 - if (res) 1021 - return res; 1022 - platform_set_drvdata(pdev, dev); 1023 - return 0; 1024 - errmii: 1025 - unregister_netdev(dev); 1026 - errdev: 1027 - free_irq(dev->irq, dev); 1028 - errirq: 1029 - free_netdev(dev); 1030 - return res; 1031 - } 1032 - 1033 - static int s6gmac_remove(struct platform_device *pdev) 1034 - { 1035 - struct net_device *dev = platform_get_drvdata(pdev); 1036 - if (dev) { 1037 - struct s6gmac *pd = netdev_priv(dev); 1038 - mdiobus_unregister(pd->mii.bus); 1039 - unregister_netdev(dev); 1040 - free_irq(dev->irq, dev); 1041 - free_netdev(dev); 1042 - } 1043 - return 0; 1044 - } 1045 - 1046 - static struct platform_driver s6gmac_driver = { 1047 - .probe = s6gmac_probe, 1048 - .remove = s6gmac_remove, 1049 - .driver = { 1050 - .name = "s6gmac", 1051 - }, 1052 - }; 1053 - 1054 - module_platform_driver(s6gmac_driver); 1055 - 1056 - MODULE_LICENSE("GPL"); 1057 - MODULE_DESCRIPTION("S6105 on chip Ethernet driver"); 1058 - MODULE_AUTHOR("Oskar Schirmer <oskar@scara.com>");
+8 -6
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1671 1671 * 0 on success and an appropriate (-)ve integer as defined in errno.h 1672 1672 * file on failure. 1673 1673 */ 1674 - static int stmmac_hw_setup(struct net_device *dev) 1674 + static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) 1675 1675 { 1676 1676 struct stmmac_priv *priv = netdev_priv(dev); 1677 1677 int ret; ··· 1708 1708 1709 1709 stmmac_mmc_setup(priv); 1710 1710 1711 - ret = stmmac_init_ptp(priv); 1712 - if (ret && ret != -EOPNOTSUPP) 1713 - pr_warn("%s: failed PTP initialisation\n", __func__); 1711 + if (init_ptp) { 1712 + ret = stmmac_init_ptp(priv); 1713 + if (ret && ret != -EOPNOTSUPP) 1714 + pr_warn("%s: failed PTP initialisation\n", __func__); 1715 + } 1714 1716 1715 1717 #ifdef CONFIG_DEBUG_FS 1716 1718 ret = stmmac_init_fs(dev); ··· 1789 1787 goto init_error; 1790 1788 } 1791 1789 1792 - ret = stmmac_hw_setup(dev); 1790 + ret = stmmac_hw_setup(dev, true); 1793 1791 if (ret < 0) { 1794 1792 pr_err("%s: Hw setup failed\n", __func__); 1795 1793 goto init_error; ··· 3038 3036 netif_device_attach(ndev); 3039 3037 3040 3038 init_dma_desc_rings(ndev, GFP_ATOMIC); 3041 - stmmac_hw_setup(ndev); 3039 + stmmac_hw_setup(ndev, false); 3042 3040 stmmac_init_tx_coalesce(priv); 3043 3041 3044 3042 napi_enable(&priv->napi);
-1
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 430 430 .remove = stmmac_pltfr_remove, 431 431 .driver = { 432 432 .name = STMMAC_RESOURCE_NAME, 433 - .owner = THIS_MODULE, 434 433 .pm = &stmmac_pltfr_pm_ops, 435 434 .of_match_table = of_match_ptr(stmmac_dt_ids), 436 435 },
+1
drivers/net/ethernet/sun/sunvnet.c
··· 1201 1201 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO); 1202 1202 if (IS_ERR(segs)) { 1203 1203 dev->stats.tx_dropped++; 1204 + dev_kfree_skb_any(skb); 1204 1205 return NETDEV_TX_OK; 1205 1206 } 1206 1207
-2
drivers/net/ethernet/xilinx/xilinx_axienet.h
··· 388 388 * @dma_err_tasklet: Tasklet structure to process Axi DMA errors 389 389 * @tx_irq: Axidma TX IRQ number 390 390 * @rx_irq: Axidma RX IRQ number 391 - * @temac_type: axienet type to identify between soft and hard temac 392 391 * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X 393 392 * @options: AxiEthernet option word 394 393 * @last_link: Phy link state in which the PHY was negotiated earlier ··· 430 431 431 432 int tx_irq; 432 433 int rx_irq; 433 - u32 temac_type; 434 434 u32 phy_type; 435 435 436 436 u32 options; /* Current options word */
-4
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 1555 1555 if ((be32_to_cpup(p)) >= 0x4000) 1556 1556 lp->jumbo_support = 1; 1557 1557 } 1558 - p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,temac-type", 1559 - NULL); 1560 - if (p) 1561 - lp->temac_type = be32_to_cpup(p); 1562 1558 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL); 1563 1559 if (p) 1564 1560 lp->phy_type = be32_to_cpup(p);
+1
drivers/net/hyperv/hyperv_net.h
··· 590 590 591 591 592 592 #define NETVSC_RECEIVE_BUFFER_ID 0xcafe 593 + #define NETVSC_SEND_BUFFER_ID 0 593 594 594 595 #define NETVSC_PACKET_SIZE 4096 595 596
+8 -7
drivers/net/hyperv/netvsc.c
··· 161 161 162 162 /* Deal with the send buffer we may have setup. 163 163 * If we got a send section size, it means we received a 164 - * SendsendBufferComplete msg (ie sent 165 - * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need 164 + * NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE msg (ie sent 165 + * NVSP_MSG1_TYPE_SEND_SEND_BUF msg) therefore, we need 166 166 * to send a revoke msg here 167 167 */ 168 168 if (net_device->send_section_size) { ··· 172 172 173 173 revoke_packet->hdr.msg_type = 174 174 NVSP_MSG1_TYPE_REVOKE_SEND_BUF; 175 - revoke_packet->msg.v1_msg.revoke_recv_buf.id = 0; 175 + revoke_packet->msg.v1_msg.revoke_send_buf.id = 176 + NETVSC_SEND_BUFFER_ID; 176 177 177 178 ret = vmbus_sendpacket(net_device->dev->channel, 178 179 revoke_packet, ··· 205 204 net_device->send_buf_gpadl_handle = 0; 206 205 } 207 206 if (net_device->send_buf) { 208 - /* Free up the receive buffer */ 207 + /* Free up the send buffer */ 209 208 vfree(net_device->send_buf); 210 209 net_device->send_buf = NULL; 211 210 } ··· 340 339 init_packet = &net_device->channel_init_pkt; 341 340 memset(init_packet, 0, sizeof(struct nvsp_message)); 342 341 init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_SEND_BUF; 343 - init_packet->msg.v1_msg.send_recv_buf.gpadl_handle = 342 + init_packet->msg.v1_msg.send_send_buf.gpadl_handle = 344 343 net_device->send_buf_gpadl_handle; 345 - init_packet->msg.v1_msg.send_recv_buf.id = 0; 344 + init_packet->msg.v1_msg.send_send_buf.id = NETVSC_SEND_BUFFER_ID; 346 345 347 346 /* Send the gpadl notification request */ 348 347 ret = vmbus_sendpacket(device->channel, init_packet, ··· 365 364 netdev_err(ndev, "Unable to complete send buffer " 366 365 "initialization with NetVsp - status %d\n", 367 366 init_packet->msg.v1_msg. 368 - send_recv_buf_complete.status); 367 + send_send_buf_complete.status); 369 368 ret = -EINVAL; 370 369 goto cleanup; 371 370 }
+3 -15
drivers/net/phy/micrel.c
··· 88 88 89 89 static const struct kszphy_type ksz8021_type = { 90 90 .led_mode_reg = MII_KSZPHY_CTRL_2, 91 + .has_broadcast_disable = true, 91 92 .has_rmii_ref_clk_sel = true, 92 93 }; 93 94 ··· 257 256 kszphy_setup_led(phydev, type->led_mode_reg, priv->led_mode); 258 257 259 258 return 0; 260 - } 261 - 262 - static int ksz8021_config_init(struct phy_device *phydev) 263 - { 264 - int rc; 265 - 266 - rc = kszphy_config_init(phydev); 267 - if (rc) 268 - return rc; 269 - 270 - rc = kszphy_broadcast_disable(phydev); 271 - 272 - return rc < 0 ? rc : 0; 273 259 } 274 260 275 261 static int ksz9021_load_values_from_of(struct phy_device *phydev, ··· 572 584 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 573 585 .driver_data = &ksz8021_type, 574 586 .probe = kszphy_probe, 575 - .config_init = ksz8021_config_init, 587 + .config_init = kszphy_config_init, 576 588 .config_aneg = genphy_config_aneg, 577 589 .read_status = genphy_read_status, 578 590 .ack_interrupt = kszphy_ack_interrupt, ··· 589 601 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 590 602 .driver_data = &ksz8021_type, 591 603 .probe = kszphy_probe, 592 - .config_init = ksz8021_config_init, 604 + .config_init = kszphy_config_init, 593 605 .config_aneg = genphy_config_aneg, 594 606 .read_status = genphy_read_status, 595 607 .ack_interrupt = kszphy_ack_interrupt,
-2
drivers/net/virtio_net.c
··· 760 760 container_of(napi, struct receive_queue, napi); 761 761 unsigned int r, received = 0; 762 762 763 - again: 764 763 received += virtnet_receive(rq, budget - received); 765 764 766 765 /* Out of packets? */ ··· 770 771 napi_schedule_prep(napi)) { 771 772 virtqueue_disable_cb(rq->vq); 772 773 __napi_schedule(napi); 773 - goto again; 774 774 } 775 775 } 776 776
+24 -10
drivers/net/vxlan.c
··· 1579 1579 bool udp_sum = !udp_get_no_check6_tx(vs->sock->sk); 1580 1580 1581 1581 skb = udp_tunnel_handle_offloads(skb, udp_sum); 1582 - if (IS_ERR(skb)) 1583 - return -EINVAL; 1582 + if (IS_ERR(skb)) { 1583 + err = -EINVAL; 1584 + goto err; 1585 + } 1584 1586 1585 1587 skb_scrub_packet(skb, xnet); 1586 1588 ··· 1592 1590 1593 1591 /* Need space for new headers (invalidates iph ptr) */ 1594 1592 err = skb_cow_head(skb, min_headroom); 1595 - if (unlikely(err)) 1596 - return err; 1593 + if (unlikely(err)) { 1594 + kfree_skb(skb); 1595 + goto err; 1596 + } 1597 1597 1598 1598 skb = vlan_hwaccel_push_inside(skb); 1599 - if (WARN_ON(!skb)) 1600 - return -ENOMEM; 1599 + if (WARN_ON(!skb)) { 1600 + err = -ENOMEM; 1601 + goto err; 1602 + } 1601 1603 1602 1604 vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh)); 1603 1605 vxh->vx_flags = htonl(VXLAN_FLAGS); ··· 1612 1606 udp_tunnel6_xmit_skb(vs->sock, dst, skb, dev, saddr, daddr, prio, 1613 1607 ttl, src_port, dst_port); 1614 1608 return 0; 1609 + err: 1610 + dst_release(dst); 1611 + return err; 1615 1612 } 1616 1613 #endif 1617 1614 ··· 1630 1621 1631 1622 skb = udp_tunnel_handle_offloads(skb, udp_sum); 1632 1623 if (IS_ERR(skb)) 1633 - return -EINVAL; 1624 + return PTR_ERR(skb); 1634 1625 1635 1626 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len 1636 1627 + VXLAN_HLEN + sizeof(struct iphdr) ··· 1638 1629 1639 1630 /* Need space for new headers (invalidates iph ptr) */ 1640 1631 err = skb_cow_head(skb, min_headroom); 1641 - if (unlikely(err)) 1632 + if (unlikely(err)) { 1633 + kfree_skb(skb); 1642 1634 return err; 1635 + } 1643 1636 1644 1637 skb = vlan_hwaccel_push_inside(skb); 1645 1638 if (WARN_ON(!skb)) ··· 1787 1776 tos, ttl, df, src_port, dst_port, 1788 1777 htonl(vni << 8), 1789 1778 !net_eq(vxlan->net, dev_net(vxlan->dev))); 1790 - 1791 - if (err < 0) 1779 + if (err < 0) { 1780 + /* skb is already freed. */ 1781 + skb = NULL; 1792 1782 goto rt_tx_error; 1783 + } 1784 + 1793 1785 iptunnel_xmit_stats(err, &dev->stats, dev->tstats); 1794 1786 #if IS_ENABLED(CONFIG_IPV6) 1795 1787 } else {
+2 -2
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
··· 1070 1070 */ 1071 1071 if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) && 1072 1072 ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) || 1073 - (sdiodev->pdata->oob_irq_supported))) 1073 + (sdiodev->pdata && sdiodev->pdata->oob_irq_supported))) 1074 1074 bus_if->wowl_supported = true; 1075 1075 #endif 1076 1076 ··· 1167 1167 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; 1168 1168 1169 1169 brcmf_dbg(SDIO, "Enter\n"); 1170 - if (sdiodev->pdata->oob_irq_supported) 1170 + if (sdiodev->pdata && sdiodev->pdata->oob_irq_supported) 1171 1171 disable_irq_wake(sdiodev->pdata->oob_irq_nr); 1172 1172 brcmf_sdio_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS); 1173 1173 atomic_set(&sdiodev->suspend, false);
+2 -1
drivers/net/wireless/ipw2x00/Kconfig
··· 65 65 66 66 config IPW2200 67 67 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection" 68 - depends on PCI && CFG80211 && CFG80211_WEXT 68 + depends on PCI && CFG80211 69 + select CFG80211_WEXT 69 70 select WIRELESS_EXT 70 71 select WEXT_SPY 71 72 select WEXT_PRIV
+1 -1
drivers/net/wireless/iwlwifi/iwl-drv.c
··· 1323 1323 1324 1324 try_again: 1325 1325 /* try next, if any */ 1326 - kfree(pieces); 1327 1326 release_firmware(ucode_raw); 1328 1327 if (iwl_request_firmware(drv, false)) 1329 1328 goto out_unbind; 1329 + kfree(pieces); 1330 1330 return; 1331 1331 1332 1332 out_free_fw:
+1
drivers/net/wireless/iwlwifi/iwl-fh.h
··· 310 310 #define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) 311 311 312 312 #define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 313 + #define FH_MEM_TB_MAX_LENGTH (0x00020000) 313 314 314 315 /* TFDB Area - TFDs buffer table */ 315 316 #define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
+13 -2
drivers/net/wireless/iwlwifi/mvm/mac80211.c
··· 1004 1004 { 1005 1005 lockdep_assert_held(&mvm->mutex); 1006 1006 1007 - /* disallow low power states when the FW is down */ 1008 - iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); 1007 + /* 1008 + * Disallow low power states when the FW is down by taking 1009 + * the UCODE_DOWN ref. in case of ongoing hw restart the 1010 + * ref is already taken, so don't take it again. 1011 + */ 1012 + if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status)) 1013 + iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); 1009 1014 1010 1015 /* async_handlers_wk is now blocked */ 1011 1016 ··· 1027 1022 1028 1023 /* the fw is stopped, the aux sta is dead: clean up driver state */ 1029 1024 iwl_mvm_del_aux_sta(mvm); 1025 + 1026 + /* 1027 + * Clear IN_HW_RESTART flag when stopping the hw (as restart_complete() 1028 + * won't be called in this case). 1029 + */ 1030 + clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status); 1030 1031 1031 1032 mvm->ucode_loaded = false; 1032 1033 }
+4
drivers/net/wireless/iwlwifi/pcie/drv.c
··· 367 367 368 368 /* 3165 Series */ 369 369 {IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)}, 370 + {IWL_PCI_DEVICE(0x3165, 0x4012, iwl3165_2ac_cfg)}, 371 + {IWL_PCI_DEVICE(0x3165, 0x4110, iwl3165_2ac_cfg)}, 370 372 {IWL_PCI_DEVICE(0x3165, 0x4210, iwl3165_2ac_cfg)}, 373 + {IWL_PCI_DEVICE(0x3165, 0x4410, iwl3165_2ac_cfg)}, 374 + {IWL_PCI_DEVICE(0x3165, 0x4510, iwl3165_2ac_cfg)}, 371 375 372 376 /* 7265 Series */ 373 377 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)},
+11 -6
drivers/net/wireless/iwlwifi/pcie/trans.c
··· 614 614 { 615 615 u8 *v_addr; 616 616 dma_addr_t p_addr; 617 - u32 offset, chunk_sz = section->len; 617 + u32 offset, chunk_sz = min_t(u32, FH_MEM_TB_MAX_LENGTH, section->len); 618 618 int ret = 0; 619 619 620 620 IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n", ··· 1012 1012 /* Stop the device, and put it in low power state */ 1013 1013 iwl_pcie_apm_stop(trans); 1014 1014 1015 - /* Upon stop, the APM issues an interrupt if HW RF kill is set. 1016 - * Clean again the interrupt here 1015 + /* stop and reset the on-board processor */ 1016 + iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 1017 + udelay(20); 1018 + 1019 + /* 1020 + * Upon stop, the APM issues an interrupt if HW RF kill is set. 1021 + * This is a bug in certain verions of the hardware. 1022 + * Certain devices also keep sending HW RF kill interrupt all 1023 + * the time, unless the interrupt is ACKed even if the interrupt 1024 + * should be masked. Re-ACK all the interrupts here. 1017 1025 */ 1018 1026 spin_lock(&trans_pcie->irq_lock); 1019 1027 iwl_disable_interrupts(trans); 1020 1028 spin_unlock(&trans_pcie->irq_lock); 1021 1029 1022 - /* stop and reset the on-board processor */ 1023 - iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); 1024 - udelay(20); 1025 1030 1026 1031 /* clear all status bits */ 1027 1032 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
+11 -9
include/linux/netdevice.h
··· 1012 1012 * Callback to use for xmit over the accelerated station. This 1013 1013 * is used in place of ndo_start_xmit on accelerated net 1014 1014 * devices. 1015 - * bool (*ndo_gso_check) (struct sk_buff *skb, 1016 - * struct net_device *dev); 1015 + * netdev_features_t (*ndo_features_check) (struct sk_buff *skb, 1016 + * struct net_device *dev 1017 + * netdev_features_t features); 1017 1018 * Called by core transmit path to determine if device is capable of 1018 - * performing GSO on a packet. The device returns true if it is 1019 - * able to GSO the packet, false otherwise. If the return value is 1020 - * false the stack will do software GSO. 1019 + * performing offload operations on a given packet. This is to give 1020 + * the device an opportunity to implement any restrictions that cannot 1021 + * be otherwise expressed by feature flags. The check is called with 1022 + * the set of features that the stack has calculated and it returns 1023 + * those the driver believes to be appropriate. 1021 1024 * 1022 1025 * int (*ndo_switch_parent_id_get)(struct net_device *dev, 1023 1026 * struct netdev_phys_item_id *psid); ··· 1181 1178 struct net_device *dev, 1182 1179 void *priv); 1183 1180 int (*ndo_get_lock_subclass)(struct net_device *dev); 1184 - bool (*ndo_gso_check) (struct sk_buff *skb, 1185 - struct net_device *dev); 1181 + netdev_features_t (*ndo_features_check) (struct sk_buff *skb, 1182 + struct net_device *dev, 1183 + netdev_features_t features); 1186 1184 #ifdef CONFIG_NET_SWITCHDEV 1187 1185 int (*ndo_switch_parent_id_get)(struct net_device *dev, 1188 1186 struct netdev_phys_item_id *psid); ··· 3615 3611 netdev_features_t features) 3616 3612 { 3617 3613 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || 3618 - (dev->netdev_ops->ndo_gso_check && 3619 - !dev->netdev_ops->ndo_gso_check(skb, dev)) || 3620 3614 unlikely((skb->ip_summed != CHECKSUM_PARTIAL) && 3621 3615 (skb->ip_summed != CHECKSUM_UNNECESSARY))); 3622 3616 }
+2 -2
include/linux/netlink.h
··· 46 46 unsigned int flags; 47 47 void (*input)(struct sk_buff *skb); 48 48 struct mutex *cb_mutex; 49 - int (*bind)(int group); 50 - void (*unbind)(int group); 49 + int (*bind)(struct net *net, int group); 50 + void (*unbind)(struct net *net, int group); 51 51 bool (*compare)(struct net *net, struct sock *sk); 52 52 }; 53 53
+7 -2
include/net/genetlink.h
··· 31 31 * do additional, common, filtering and return an error 32 32 * @post_doit: called after an operation's doit callback, it may 33 33 * undo operations done by pre_doit, for example release locks 34 + * @mcast_bind: a socket bound to the given multicast group (which 35 + * is given as the offset into the groups array) 36 + * @mcast_unbind: a socket was unbound from the given multicast group 34 37 * @attrbuf: buffer to store parsed attributes 35 38 * @family_list: family list 36 39 * @mcgrps: multicast groups used by this family (private) ··· 56 53 void (*post_doit)(const struct genl_ops *ops, 57 54 struct sk_buff *skb, 58 55 struct genl_info *info); 56 + int (*mcast_bind)(struct net *net, int group); 57 + void (*mcast_unbind)(struct net *net, int group); 59 58 struct nlattr ** attrbuf; /* private */ 60 59 const struct genl_ops * ops; /* private */ 61 60 const struct genl_multicast_group *mcgrps; /* private */ ··· 400 395 } 401 396 402 397 static inline int genl_has_listeners(struct genl_family *family, 403 - struct sock *sk, unsigned int group) 398 + struct net *net, unsigned int group) 404 399 { 405 400 if (WARN_ON_ONCE(group >= family->n_mcgrps)) 406 401 return -EINVAL; 407 402 group = family->mcgrp_offset + group; 408 - return netlink_has_listeners(sk, group); 403 + return netlink_has_listeners(net->genl_sock, group); 409 404 } 410 405 #endif /* __NET_GENERIC_NETLINK_H */
-1
include/net/neighbour.h
··· 190 190 191 191 192 192 struct neigh_table { 193 - struct neigh_table *next; 194 193 int family; 195 194 int entry_size; 196 195 int key_len;
+24 -4
include/net/vxlan.h
··· 1 1 #ifndef __NET_VXLAN_H 2 2 #define __NET_VXLAN_H 1 3 3 4 + #include <linux/ip.h> 5 + #include <linux/ipv6.h> 6 + #include <linux/if_vlan.h> 4 7 #include <linux/skbuff.h> 5 8 #include <linux/netdevice.h> 6 9 #include <linux/udp.h> ··· 54 51 __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, 55 52 __be16 src_port, __be16 dst_port, __be32 vni, bool xnet); 56 53 57 - static inline bool vxlan_gso_check(struct sk_buff *skb) 54 + static inline netdev_features_t vxlan_features_check(struct sk_buff *skb, 55 + netdev_features_t features) 58 56 { 59 - if ((skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) && 57 + u8 l4_hdr = 0; 58 + 59 + if (!skb->encapsulation) 60 + return features; 61 + 62 + switch (vlan_get_protocol(skb)) { 63 + case htons(ETH_P_IP): 64 + l4_hdr = ip_hdr(skb)->protocol; 65 + break; 66 + case htons(ETH_P_IPV6): 67 + l4_hdr = ipv6_hdr(skb)->nexthdr; 68 + break; 69 + default: 70 + return features;; 71 + } 72 + 73 + if ((l4_hdr == IPPROTO_UDP) && 60 74 (skb->inner_protocol_type != ENCAP_TYPE_ETHER || 61 75 skb->inner_protocol != htons(ETH_P_TEB) || 62 76 (skb_inner_mac_header(skb) - skb_transport_header(skb) != 63 77 sizeof(struct udphdr) + sizeof(struct vxlanhdr)))) 64 - return false; 78 + return features & ~(NETIF_F_ALL_CSUM | NETIF_F_GSO_MASK); 65 79 66 - return true; 80 + return features; 67 81 } 68 82 69 83 /* IP header + UDP + VXLAN + Ethernet header */
+2 -1
include/uapi/linux/in6.h
··· 149 149 /* 150 150 * IPV6 socket options 151 151 */ 152 - 152 + #if __UAPI_DEF_IPV6_OPTIONS 153 153 #define IPV6_ADDRFORM 1 154 154 #define IPV6_2292PKTINFO 2 155 155 #define IPV6_2292HOPOPTS 3 ··· 196 196 197 197 #define IPV6_IPSEC_POLICY 34 198 198 #define IPV6_XFRM_POLICY 35 199 + #endif 199 200 200 201 /* 201 202 * Multicast:
+3
include/uapi/linux/libc-compat.h
··· 69 69 #define __UAPI_DEF_SOCKADDR_IN6 0 70 70 #define __UAPI_DEF_IPV6_MREQ 0 71 71 #define __UAPI_DEF_IPPROTO_V6 0 72 + #define __UAPI_DEF_IPV6_OPTIONS 0 72 73 73 74 #else 74 75 ··· 83 82 #define __UAPI_DEF_SOCKADDR_IN6 1 84 83 #define __UAPI_DEF_IPV6_MREQ 1 85 84 #define __UAPI_DEF_IPPROTO_V6 1 85 + #define __UAPI_DEF_IPV6_OPTIONS 1 86 86 87 87 #endif /* _NETINET_IN_H */ 88 88 ··· 105 103 #define __UAPI_DEF_SOCKADDR_IN6 1 106 104 #define __UAPI_DEF_IPV6_MREQ 1 107 105 #define __UAPI_DEF_IPPROTO_V6 1 106 + #define __UAPI_DEF_IPV6_OPTIONS 1 108 107 109 108 /* Definitions for xattr.h */ 110 109 #define __UAPI_DEF_XATTR 1
+1 -1
kernel/audit.c
··· 1100 1100 } 1101 1101 1102 1102 /* Run custom bind function on netlink socket group connect or bind requests. */ 1103 - static int audit_bind(int group) 1103 + static int audit_bind(struct net *net, int group) 1104 1104 { 1105 1105 if (!capable(CAP_AUDIT_READ)) 1106 1106 return -EPERM;
+2 -2
net/batman-adv/fragmentation.c
··· 251 251 kfree(entry); 252 252 253 253 /* Make room for the rest of the fragments. */ 254 - if (pskb_expand_head(skb_out, 0, size - skb->len, GFP_ATOMIC) < 0) { 254 + if (pskb_expand_head(skb_out, 0, size - skb_out->len, GFP_ATOMIC) < 0) { 255 255 kfree_skb(skb_out); 256 256 skb_out = NULL; 257 257 goto free; ··· 434 434 * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE 435 435 */ 436 436 mtu = min_t(unsigned, mtu, BATADV_FRAG_MAX_FRAG_SIZE); 437 - max_fragment_size = (mtu - header_size - ETH_HLEN); 437 + max_fragment_size = mtu - header_size; 438 438 max_packet_size = max_fragment_size * BATADV_FRAG_MAX_FRAGMENTS; 439 439 440 440 /* Don't even try to fragment, if we need more than 16 fragments */
+1 -1
net/batman-adv/gateway_client.c
··· 810 810 goto out; 811 811 812 812 gw_node = batadv_gw_node_get(bat_priv, orig_dst_node); 813 - if (!gw_node->bandwidth_down == 0) 813 + if (!gw_node) 814 814 goto out; 815 815 816 816 switch (atomic_read(&bat_priv->gw_mode)) {
-1
net/bluetooth/6lowpan.c
··· 390 390 391 391 drop: 392 392 dev->stats.rx_dropped++; 393 - kfree_skb(skb); 394 393 return NET_RX_DROP; 395 394 } 396 395
+3
net/bluetooth/bnep/core.c
··· 533 533 534 534 BT_DBG(""); 535 535 536 + if (!l2cap_is_socket(sock)) 537 + return -EBADFD; 538 + 536 539 baswap((void *) dst, &l2cap_pi(sock->sk)->chan->dst); 537 540 baswap((void *) src, &l2cap_pi(sock->sk)->chan->src); 538 541
+3
net/bluetooth/cmtp/core.c
··· 334 334 335 335 BT_DBG(""); 336 336 337 + if (!l2cap_is_socket(sock)) 338 + return -EBADFD; 339 + 337 340 session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL); 338 341 if (!session) 339 342 return -ENOMEM;
+12 -4
net/bluetooth/hci_event.c
··· 242 242 if (rp->status) 243 243 return; 244 244 245 - if (test_bit(HCI_SETUP, &hdev->dev_flags)) 245 + if (test_bit(HCI_SETUP, &hdev->dev_flags) || 246 + test_bit(HCI_CONFIG, &hdev->dev_flags)) 246 247 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); 247 248 } 248 249 ··· 510 509 if (rp->status) 511 510 return; 512 511 513 - if (test_bit(HCI_SETUP, &hdev->dev_flags)) { 512 + if (test_bit(HCI_SETUP, &hdev->dev_flags) || 513 + test_bit(HCI_CONFIG, &hdev->dev_flags)) { 514 514 hdev->hci_ver = rp->hci_ver; 515 515 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); 516 516 hdev->lmp_ver = rp->lmp_ver; ··· 530 528 if (rp->status) 531 529 return; 532 530 533 - if (test_bit(HCI_SETUP, &hdev->dev_flags)) 531 + if (test_bit(HCI_SETUP, &hdev->dev_flags) || 532 + test_bit(HCI_CONFIG, &hdev->dev_flags)) 534 533 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); 535 534 } 536 535 ··· 2197 2194 return; 2198 2195 } 2199 2196 2200 - if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags) && 2197 + /* Require HCI_CONNECTABLE or a whitelist entry to accept the 2198 + * connection. These features are only touched through mgmt so 2199 + * only do the checks if HCI_MGMT is set. 2200 + */ 2201 + if (test_bit(HCI_MGMT, &hdev->dev_flags) && 2202 + !test_bit(HCI_CONNECTABLE, &hdev->dev_flags) && 2201 2203 !hci_bdaddr_list_lookup(&hdev->whitelist, &ev->bdaddr, 2202 2204 BDADDR_BREDR)) { 2203 2205 hci_reject_conn(hdev, &ev->bdaddr);
+2 -1
net/bluetooth/hidp/core.c
··· 1314 1314 { 1315 1315 struct hidp_session *session; 1316 1316 struct l2cap_conn *conn; 1317 - struct l2cap_chan *chan = l2cap_pi(ctrl_sock->sk)->chan; 1317 + struct l2cap_chan *chan; 1318 1318 int ret; 1319 1319 1320 1320 ret = hidp_verify_sockets(ctrl_sock, intr_sock); 1321 1321 if (ret) 1322 1322 return ret; 1323 1323 1324 + chan = l2cap_pi(ctrl_sock->sk)->chan; 1324 1325 conn = NULL; 1325 1326 l2cap_chan_lock(chan); 1326 1327 if (chan->conn)
+100 -75
net/core/dev.c
··· 1694 1694 1695 1695 skb_scrub_packet(skb, true); 1696 1696 skb->protocol = eth_type_trans(skb, dev); 1697 + skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN); 1697 1698 1698 1699 return 0; 1699 1700 } ··· 2523 2522 /* If MPLS offload request, verify we are testing hardware MPLS features 2524 2523 * instead of standard features for the netdev. 2525 2524 */ 2526 - #ifdef CONFIG_NET_MPLS_GSO 2525 + #if IS_ENABLED(CONFIG_NET_MPLS_GSO) 2527 2526 static netdev_features_t net_mpls_features(struct sk_buff *skb, 2528 2527 netdev_features_t features, 2529 2528 __be16 type) ··· 2563 2562 2564 2563 netdev_features_t netif_skb_features(struct sk_buff *skb) 2565 2564 { 2566 - const struct net_device *dev = skb->dev; 2565 + struct net_device *dev = skb->dev; 2567 2566 netdev_features_t features = dev->features; 2568 2567 u16 gso_segs = skb_shinfo(skb)->gso_segs; 2569 2568 __be16 protocol = skb->protocol; ··· 2571 2570 if (gso_segs > dev->gso_max_segs || gso_segs < dev->gso_min_segs) 2572 2571 features &= ~NETIF_F_GSO_MASK; 2573 2572 2574 - if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { 2575 - struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 2576 - protocol = veh->h_vlan_encapsulated_proto; 2577 - } else if (!vlan_tx_tag_present(skb)) { 2578 - return harmonize_features(skb, features); 2573 + /* If encapsulation offload request, verify we are testing 2574 + * hardware encapsulation features instead of standard 2575 + * features for the netdev 2576 + */ 2577 + if (skb->encapsulation) 2578 + features &= dev->hw_enc_features; 2579 + 2580 + if (!vlan_tx_tag_present(skb)) { 2581 + if (unlikely(protocol == htons(ETH_P_8021Q) || 2582 + protocol == htons(ETH_P_8021AD))) { 2583 + struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 2584 + protocol = veh->h_vlan_encapsulated_proto; 2585 + } else { 2586 + goto finalize; 2587 + } 2579 2588 } 2580 2589 2581 2590 features = netdev_intersect_features(features, ··· 2601 2590 NETIF_F_GEN_CSUM | 2602 2591 NETIF_F_HW_VLAN_CTAG_TX | 2603 2592 NETIF_F_HW_VLAN_STAG_TX); 2593 + 2594 + finalize: 2595 + if (dev->netdev_ops->ndo_features_check) 2596 + features &= dev->netdev_ops->ndo_features_check(skb, dev, 2597 + features); 2604 2598 2605 2599 return harmonize_features(skb, features); 2606 2600 } ··· 2677 2661 if (unlikely(!skb)) 2678 2662 goto out_null; 2679 2663 2680 - /* If encapsulation offload request, verify we are testing 2681 - * hardware encapsulation features instead of standard 2682 - * features for the netdev 2683 - */ 2684 - if (skb->encapsulation) 2685 - features &= dev->hw_enc_features; 2686 - 2687 2664 if (netif_needs_gso(dev, skb, features)) { 2688 2665 struct sk_buff *segs; 2689 2666 2690 2667 segs = skb_gso_segment(skb, features); 2691 2668 if (IS_ERR(segs)) { 2692 - segs = NULL; 2669 + goto out_kfree_skb; 2693 2670 } else if (segs) { 2694 2671 consume_skb(skb); 2695 2672 skb = segs; ··· 4566 4557 } 4567 4558 EXPORT_SYMBOL(netif_napi_del); 4568 4559 4560 + static int napi_poll(struct napi_struct *n, struct list_head *repoll) 4561 + { 4562 + void *have; 4563 + int work, weight; 4564 + 4565 + list_del_init(&n->poll_list); 4566 + 4567 + have = netpoll_poll_lock(n); 4568 + 4569 + weight = n->weight; 4570 + 4571 + /* This NAPI_STATE_SCHED test is for avoiding a race 4572 + * with netpoll's poll_napi(). Only the entity which 4573 + * obtains the lock and sees NAPI_STATE_SCHED set will 4574 + * actually make the ->poll() call. Therefore we avoid 4575 + * accidentally calling ->poll() when NAPI is not scheduled. 4576 + */ 4577 + work = 0; 4578 + if (test_bit(NAPI_STATE_SCHED, &n->state)) { 4579 + work = n->poll(n, weight); 4580 + trace_napi_poll(n); 4581 + } 4582 + 4583 + WARN_ON_ONCE(work > weight); 4584 + 4585 + if (likely(work < weight)) 4586 + goto out_unlock; 4587 + 4588 + /* Drivers must not modify the NAPI state if they 4589 + * consume the entire weight. In such cases this code 4590 + * still "owns" the NAPI instance and therefore can 4591 + * move the instance around on the list at-will. 4592 + */ 4593 + if (unlikely(napi_disable_pending(n))) { 4594 + napi_complete(n); 4595 + goto out_unlock; 4596 + } 4597 + 4598 + if (n->gro_list) { 4599 + /* flush too old packets 4600 + * If HZ < 1000, flush all packets. 4601 + */ 4602 + napi_gro_flush(n, HZ >= 1000); 4603 + } 4604 + 4605 + /* Some drivers may have called napi_schedule 4606 + * prior to exhausting their budget. 4607 + */ 4608 + if (unlikely(!list_empty(&n->poll_list))) { 4609 + pr_warn_once("%s: Budget exhausted after napi rescheduled\n", 4610 + n->dev ? n->dev->name : "backlog"); 4611 + goto out_unlock; 4612 + } 4613 + 4614 + list_add_tail(&n->poll_list, repoll); 4615 + 4616 + out_unlock: 4617 + netpoll_poll_unlock(have); 4618 + 4619 + return work; 4620 + } 4621 + 4569 4622 static void net_rx_action(struct softirq_action *h) 4570 4623 { 4571 4624 struct softnet_data *sd = this_cpu_ptr(&softnet_data); ··· 4635 4564 int budget = netdev_budget; 4636 4565 LIST_HEAD(list); 4637 4566 LIST_HEAD(repoll); 4638 - void *have; 4639 4567 4640 4568 local_irq_disable(); 4641 4569 list_splice_init(&sd->poll_list, &list); 4642 4570 local_irq_enable(); 4643 4571 4644 - while (!list_empty(&list)) { 4572 + for (;;) { 4645 4573 struct napi_struct *n; 4646 - int work, weight; 4574 + 4575 + if (list_empty(&list)) { 4576 + if (!sd_has_rps_ipi_waiting(sd) && list_empty(&repoll)) 4577 + return; 4578 + break; 4579 + } 4580 + 4581 + n = list_first_entry(&list, struct napi_struct, poll_list); 4582 + budget -= napi_poll(n, &repoll); 4647 4583 4648 4584 /* If softirq window is exhausted then punt. 4649 4585 * Allow this to run for 2 jiffies since which will allow 4650 4586 * an average latency of 1.5/HZ. 4651 4587 */ 4652 - if (unlikely(budget <= 0 || time_after_eq(jiffies, time_limit))) 4653 - goto softnet_break; 4654 - 4655 - 4656 - n = list_first_entry(&list, struct napi_struct, poll_list); 4657 - list_del_init(&n->poll_list); 4658 - 4659 - have = netpoll_poll_lock(n); 4660 - 4661 - weight = n->weight; 4662 - 4663 - /* This NAPI_STATE_SCHED test is for avoiding a race 4664 - * with netpoll's poll_napi(). Only the entity which 4665 - * obtains the lock and sees NAPI_STATE_SCHED set will 4666 - * actually make the ->poll() call. Therefore we avoid 4667 - * accidentally calling ->poll() when NAPI is not scheduled. 4668 - */ 4669 - work = 0; 4670 - if (test_bit(NAPI_STATE_SCHED, &n->state)) { 4671 - work = n->poll(n, weight); 4672 - trace_napi_poll(n); 4588 + if (unlikely(budget <= 0 || 4589 + time_after_eq(jiffies, time_limit))) { 4590 + sd->time_squeeze++; 4591 + break; 4673 4592 } 4674 - 4675 - WARN_ON_ONCE(work > weight); 4676 - 4677 - budget -= work; 4678 - 4679 - /* Drivers must not modify the NAPI state if they 4680 - * consume the entire weight. In such cases this code 4681 - * still "owns" the NAPI instance and therefore can 4682 - * move the instance around on the list at-will. 4683 - */ 4684 - if (unlikely(work == weight)) { 4685 - if (unlikely(napi_disable_pending(n))) { 4686 - napi_complete(n); 4687 - } else { 4688 - if (n->gro_list) { 4689 - /* flush too old packets 4690 - * If HZ < 1000, flush all packets. 4691 - */ 4692 - napi_gro_flush(n, HZ >= 1000); 4693 - } 4694 - list_add_tail(&n->poll_list, &repoll); 4695 - } 4696 - } 4697 - 4698 - netpoll_poll_unlock(have); 4699 4593 } 4700 4594 4701 - if (!sd_has_rps_ipi_waiting(sd) && 4702 - list_empty(&list) && 4703 - list_empty(&repoll)) 4704 - return; 4705 - out: 4706 4595 local_irq_disable(); 4707 4596 4708 4597 list_splice_tail_init(&sd->poll_list, &list); ··· 4672 4641 __raise_softirq_irqoff(NET_RX_SOFTIRQ); 4673 4642 4674 4643 net_rps_action_and_irq_enable(sd); 4675 - 4676 - return; 4677 - 4678 - softnet_break: 4679 - sd->time_squeeze++; 4680 - goto out; 4681 4644 } 4682 4645 4683 4646 struct netdev_adjacent {
+1
net/core/skbuff.c
··· 4148 4148 skb->ignore_df = 0; 4149 4149 skb_dst_drop(skb); 4150 4150 skb->mark = 0; 4151 + skb_init_secmark(skb); 4151 4152 secpath_reset(skb); 4152 4153 nf_reset(skb); 4153 4154 nf_reset_trace(skb);
+5 -1
net/ipv4/geneve.c
··· 122 122 int err; 123 123 124 124 skb = udp_tunnel_handle_offloads(skb, !gs->sock->sk->sk_no_check_tx); 125 + if (IS_ERR(skb)) 126 + return PTR_ERR(skb); 125 127 126 128 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len 127 129 + GENEVE_BASE_HLEN + opt_len + sizeof(struct iphdr) 128 130 + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0); 129 131 130 132 err = skb_cow_head(skb, min_headroom); 131 - if (unlikely(err)) 133 + if (unlikely(err)) { 134 + kfree_skb(skb); 132 135 return err; 136 + } 133 137 134 138 skb = vlan_hwaccel_push_inside(skb); 135 139 if (unlikely(!skb))
+29 -16
net/ipv6/tcp_ipv6.c
··· 1387 1387 return 0; 1388 1388 } 1389 1389 1390 + static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr, 1391 + const struct tcphdr *th) 1392 + { 1393 + /* This is tricky: we move IP6CB at its correct location into 1394 + * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because 1395 + * _decode_session6() uses IP6CB(). 1396 + * barrier() makes sure compiler won't play aliasing games. 1397 + */ 1398 + memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb), 1399 + sizeof(struct inet6_skb_parm)); 1400 + barrier(); 1401 + 1402 + TCP_SKB_CB(skb)->seq = ntohl(th->seq); 1403 + TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin + 1404 + skb->len - th->doff*4); 1405 + TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); 1406 + TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th); 1407 + TCP_SKB_CB(skb)->tcp_tw_isn = 0; 1408 + TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr); 1409 + TCP_SKB_CB(skb)->sacked = 0; 1410 + } 1411 + 1390 1412 static int tcp_v6_rcv(struct sk_buff *skb) 1391 1413 { 1392 1414 const struct tcphdr *th; ··· 1440 1418 1441 1419 th = tcp_hdr(skb); 1442 1420 hdr = ipv6_hdr(skb); 1443 - /* This is tricky : We move IPCB at its correct location into TCP_SKB_CB() 1444 - * barrier() makes sure compiler wont play fool^Waliasing games. 1445 - */ 1446 - memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb), 1447 - sizeof(struct inet6_skb_parm)); 1448 - barrier(); 1449 - 1450 - TCP_SKB_CB(skb)->seq = ntohl(th->seq); 1451 - TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin + 1452 - skb->len - th->doff*4); 1453 - TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); 1454 - TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th); 1455 - TCP_SKB_CB(skb)->tcp_tw_isn = 0; 1456 - TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr); 1457 - TCP_SKB_CB(skb)->sacked = 0; 1458 1421 1459 1422 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest, 1460 - tcp_v6_iif(skb)); 1423 + inet6_iif(skb)); 1461 1424 if (!sk) 1462 1425 goto no_tcp_socket; 1463 1426 ··· 1457 1450 1458 1451 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 1459 1452 goto discard_and_relse; 1453 + 1454 + tcp_v6_fill_cb(skb, hdr, th); 1460 1455 1461 1456 #ifdef CONFIG_TCP_MD5SIG 1462 1457 if (tcp_v6_inbound_md5_hash(sk, skb)) ··· 1491 1482 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 1492 1483 goto discard_it; 1493 1484 1485 + tcp_v6_fill_cb(skb, hdr, th); 1486 + 1494 1487 if (skb->len < (th->doff<<2) || tcp_checksum_complete(skb)) { 1495 1488 csum_error: 1496 1489 TCP_INC_STATS_BH(net, TCP_MIB_CSUMERRORS); ··· 1515 1504 inet_twsk_put(inet_twsk(sk)); 1516 1505 goto discard_it; 1517 1506 } 1507 + 1508 + tcp_v6_fill_cb(skb, hdr, th); 1518 1509 1519 1510 if (skb->len < (th->doff<<2)) { 1520 1511 inet_twsk_put(inet_twsk(sk));
+1 -4
net/mpls/mpls_gso.c
··· 31 31 SKB_GSO_TCPV6 | 32 32 SKB_GSO_UDP | 33 33 SKB_GSO_DODGY | 34 - SKB_GSO_TCP_ECN | 35 - SKB_GSO_GRE | 36 - SKB_GSO_GRE_CSUM | 37 - SKB_GSO_IPIP))) 34 + SKB_GSO_TCP_ECN))) 38 35 goto out; 39 36 40 37 /* Setup inner SKB. */
+1 -1
net/netfilter/nfnetlink.c
··· 463 463 } 464 464 465 465 #ifdef CONFIG_MODULES 466 - static int nfnetlink_bind(int group) 466 + static int nfnetlink_bind(struct net *net, int group) 467 467 { 468 468 const struct nfnetlink_subsystem *ss; 469 469 int type;
+23 -15
net/netlink/af_netlink.c
··· 1091 1091 mutex_unlock(&nl_sk_hash_lock); 1092 1092 1093 1093 netlink_table_grab(); 1094 - if (nlk_sk(sk)->subscriptions) 1094 + if (nlk_sk(sk)->subscriptions) { 1095 1095 __sk_del_bind_node(sk); 1096 + netlink_update_listeners(sk); 1097 + } 1096 1098 netlink_table_ungrab(); 1097 1099 } 1098 1100 ··· 1141 1139 struct module *module = NULL; 1142 1140 struct mutex *cb_mutex; 1143 1141 struct netlink_sock *nlk; 1144 - int (*bind)(int group); 1145 - void (*unbind)(int group); 1142 + int (*bind)(struct net *net, int group); 1143 + void (*unbind)(struct net *net, int group); 1146 1144 int err = 0; 1147 1145 1148 1146 sock->state = SS_UNCONNECTED; ··· 1228 1226 1229 1227 module_put(nlk->module); 1230 1228 1231 - netlink_table_grab(); 1232 1229 if (netlink_is_kernel(sk)) { 1230 + netlink_table_grab(); 1233 1231 BUG_ON(nl_table[sk->sk_protocol].registered == 0); 1234 1232 if (--nl_table[sk->sk_protocol].registered == 0) { 1235 1233 struct listeners *old; ··· 1243 1241 nl_table[sk->sk_protocol].flags = 0; 1244 1242 nl_table[sk->sk_protocol].registered = 0; 1245 1243 } 1246 - } else if (nlk->subscriptions) { 1247 - netlink_update_listeners(sk); 1244 + netlink_table_ungrab(); 1248 1245 } 1249 - netlink_table_ungrab(); 1250 1246 1247 + if (nlk->netlink_unbind) { 1248 + int i; 1249 + 1250 + for (i = 0; i < nlk->ngroups; i++) 1251 + if (test_bit(i, nlk->groups)) 1252 + nlk->netlink_unbind(sock_net(sk), i + 1); 1253 + } 1251 1254 kfree(nlk->groups); 1252 1255 nlk->groups = NULL; 1253 1256 ··· 1417 1410 return err; 1418 1411 } 1419 1412 1420 - static void netlink_unbind(int group, long unsigned int groups, 1421 - struct netlink_sock *nlk) 1413 + static void netlink_undo_bind(int group, long unsigned int groups, 1414 + struct sock *sk) 1422 1415 { 1416 + struct netlink_sock *nlk = nlk_sk(sk); 1423 1417 int undo; 1424 1418 1425 1419 if (!nlk->netlink_unbind) ··· 1428 1420 1429 1421 for (undo = 0; undo < group; undo++) 1430 1422 if (test_bit(undo, &groups)) 1431 - nlk->netlink_unbind(undo); 1423 + nlk->netlink_unbind(sock_net(sk), undo); 1432 1424 } 1433 1425 1434 1426 static int netlink_bind(struct socket *sock, struct sockaddr *addr, ··· 1466 1458 for (group = 0; group < nlk->ngroups; group++) { 1467 1459 if (!test_bit(group, &groups)) 1468 1460 continue; 1469 - err = nlk->netlink_bind(group); 1461 + err = nlk->netlink_bind(net, group); 1470 1462 if (!err) 1471 1463 continue; 1472 - netlink_unbind(group, groups, nlk); 1464 + netlink_undo_bind(group, groups, sk); 1473 1465 return err; 1474 1466 } 1475 1467 } ··· 1479 1471 netlink_insert(sk, net, nladdr->nl_pid) : 1480 1472 netlink_autobind(sock); 1481 1473 if (err) { 1482 - netlink_unbind(nlk->ngroups, groups, nlk); 1474 + netlink_undo_bind(nlk->ngroups, groups, sk); 1483 1475 return err; 1484 1476 } 1485 1477 } ··· 2130 2122 if (!val || val - 1 >= nlk->ngroups) 2131 2123 return -EINVAL; 2132 2124 if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) { 2133 - err = nlk->netlink_bind(val); 2125 + err = nlk->netlink_bind(sock_net(sk), val); 2134 2126 if (err) 2135 2127 return err; 2136 2128 } ··· 2139 2131 optname == NETLINK_ADD_MEMBERSHIP); 2140 2132 netlink_table_ungrab(); 2141 2133 if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind) 2142 - nlk->netlink_unbind(val); 2134 + nlk->netlink_unbind(sock_net(sk), val); 2143 2135 2144 2136 err = 0; 2145 2137 break;
+4 -4
net/netlink/af_netlink.h
··· 39 39 struct mutex *cb_mutex; 40 40 struct mutex cb_def_mutex; 41 41 void (*netlink_rcv)(struct sk_buff *skb); 42 - int (*netlink_bind)(int group); 43 - void (*netlink_unbind)(int group); 42 + int (*netlink_bind)(struct net *net, int group); 43 + void (*netlink_unbind)(struct net *net, int group); 44 44 struct module *module; 45 45 #ifdef CONFIG_NETLINK_MMAP 46 46 struct mutex pg_vec_lock; ··· 65 65 unsigned int groups; 66 66 struct mutex *cb_mutex; 67 67 struct module *module; 68 - int (*bind)(int group); 69 - void (*unbind)(int group); 68 + int (*bind)(struct net *net, int group); 69 + void (*unbind)(struct net *net, int group); 70 70 bool (*compare)(struct net *net, struct sock *sock); 71 71 int registered; 72 72 };
+56
net/netlink/genetlink.c
··· 983 983 { .name = "notify", }, 984 984 }; 985 985 986 + static int genl_bind(struct net *net, int group) 987 + { 988 + int i, err = 0; 989 + 990 + down_read(&cb_lock); 991 + for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { 992 + struct genl_family *f; 993 + 994 + list_for_each_entry(f, genl_family_chain(i), family_list) { 995 + if (group >= f->mcgrp_offset && 996 + group < f->mcgrp_offset + f->n_mcgrps) { 997 + int fam_grp = group - f->mcgrp_offset; 998 + 999 + if (!f->netnsok && net != &init_net) 1000 + err = -ENOENT; 1001 + else if (f->mcast_bind) 1002 + err = f->mcast_bind(net, fam_grp); 1003 + else 1004 + err = 0; 1005 + break; 1006 + } 1007 + } 1008 + } 1009 + up_read(&cb_lock); 1010 + 1011 + return err; 1012 + } 1013 + 1014 + static void genl_unbind(struct net *net, int group) 1015 + { 1016 + int i; 1017 + bool found = false; 1018 + 1019 + down_read(&cb_lock); 1020 + for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { 1021 + struct genl_family *f; 1022 + 1023 + list_for_each_entry(f, genl_family_chain(i), family_list) { 1024 + if (group >= f->mcgrp_offset && 1025 + group < f->mcgrp_offset + f->n_mcgrps) { 1026 + int fam_grp = group - f->mcgrp_offset; 1027 + 1028 + if (f->mcast_unbind) 1029 + f->mcast_unbind(net, fam_grp); 1030 + found = true; 1031 + break; 1032 + } 1033 + } 1034 + } 1035 + up_read(&cb_lock); 1036 + 1037 + WARN_ON(!found); 1038 + } 1039 + 986 1040 static int __net_init genl_pernet_init(struct net *net) 987 1041 { 988 1042 struct netlink_kernel_cfg cfg = { 989 1043 .input = genl_rcv, 990 1044 .flags = NL_CFG_F_NONROOT_RECV, 1045 + .bind = genl_bind, 1046 + .unbind = genl_unbind, 991 1047 }; 992 1048 993 1049 /* we'll bump the group number right afterwards */
+2 -1
net/openvswitch/actions.c
··· 147 147 hdr = eth_hdr(skb); 148 148 hdr->h_proto = mpls->mpls_ethertype; 149 149 150 - skb_set_inner_protocol(skb, skb->protocol); 150 + if (!skb->inner_protocol) 151 + skb_set_inner_protocol(skb, skb->protocol); 151 152 skb->protocol = mpls->mpls_ethertype; 152 153 153 154 invalidate_flow_key(key);
+1 -2
net/openvswitch/datapath.c
··· 83 83 unsigned int group) 84 84 { 85 85 return info->nlhdr->nlmsg_flags & NLM_F_ECHO || 86 - genl_has_listeners(family, genl_info_net(info)->genl_sock, 87 - group); 86 + genl_has_listeners(family, genl_info_net(info), group); 88 87 } 89 88 90 89 static void ovs_notify(struct genl_family *family,
+1 -12
net/openvswitch/flow_netlink.c
··· 1753 1753 __be16 eth_type, __be16 vlan_tci, bool log) 1754 1754 { 1755 1755 const struct nlattr *a; 1756 - bool out_tnl_port = false; 1757 1756 int rem, err; 1758 1757 1759 1758 if (depth >= SAMPLE_ACTION_DEPTH) ··· 1795 1796 case OVS_ACTION_ATTR_OUTPUT: 1796 1797 if (nla_get_u32(a) >= DP_MAX_PORTS) 1797 1798 return -EINVAL; 1798 - out_tnl_port = false; 1799 - 1800 1799 break; 1801 1800 1802 1801 case OVS_ACTION_ATTR_HASH: { ··· 1828 1831 1829 1832 case OVS_ACTION_ATTR_PUSH_MPLS: { 1830 1833 const struct ovs_action_push_mpls *mpls = nla_data(a); 1831 - 1832 - /* Networking stack do not allow simultaneous Tunnel 1833 - * and MPLS GSO. 1834 - */ 1835 - if (out_tnl_port) 1836 - return -EINVAL; 1837 1834 1838 1835 if (!eth_p_mpls(mpls->mpls_ethertype)) 1839 1836 return -EINVAL; ··· 1864 1873 1865 1874 case OVS_ACTION_ATTR_SET: 1866 1875 err = validate_set(a, key, sfa, 1867 - &out_tnl_port, eth_type, log); 1876 + &skip_copy, eth_type, log); 1868 1877 if (err) 1869 1878 return err; 1870 - 1871 - skip_copy = out_tnl_port; 1872 1879 break; 1873 1880 1874 1881 case OVS_ACTION_ATTR_SAMPLE:
+3
net/openvswitch/vport-geneve.c
··· 219 219 false); 220 220 if (err < 0) 221 221 ip_rt_put(rt); 222 + return err; 223 + 222 224 error: 225 + kfree_skb(skb); 223 226 return err; 224 227 } 225 228
+11 -7
net/openvswitch/vport-gre.c
··· 73 73 74 74 skb = gre_handle_offloads(skb, !!(tun_key->tun_flags & TUNNEL_CSUM)); 75 75 if (IS_ERR(skb)) 76 - return NULL; 76 + return skb; 77 77 78 78 tpi.flags = filter_tnl_flags(tun_key->tun_flags); 79 79 tpi.proto = htons(ETH_P_TEB); ··· 144 144 145 145 if (unlikely(!OVS_CB(skb)->egress_tun_info)) { 146 146 err = -EINVAL; 147 - goto error; 147 + goto err_free_skb; 148 148 } 149 149 150 150 tun_key = &OVS_CB(skb)->egress_tun_info->tunnel; ··· 157 157 fl.flowi4_proto = IPPROTO_GRE; 158 158 159 159 rt = ip_route_output_key(net, &fl); 160 - if (IS_ERR(rt)) 161 - return PTR_ERR(rt); 160 + if (IS_ERR(rt)) { 161 + err = PTR_ERR(rt); 162 + goto err_free_skb; 163 + } 162 164 163 165 tunnel_hlen = ip_gre_calc_hlen(tun_key->tun_flags); 164 166 ··· 185 183 186 184 /* Push Tunnel header. */ 187 185 skb = __build_header(skb, tunnel_hlen); 188 - if (unlikely(!skb)) { 189 - err = 0; 186 + if (IS_ERR(skb)) { 187 + err = PTR_ERR(skb); 188 + skb = NULL; 190 189 goto err_free_rt; 191 190 } 192 191 ··· 201 198 tun_key->ipv4_tos, tun_key->ipv4_ttl, df, false); 202 199 err_free_rt: 203 200 ip_rt_put(rt); 204 - error: 201 + err_free_skb: 202 + kfree_skb(skb); 205 203 return err; 206 204 } 207 205
+2
net/openvswitch/vport-vxlan.c
··· 187 187 false); 188 188 if (err < 0) 189 189 ip_rt_put(rt); 190 + return err; 190 191 error: 192 + kfree_skb(skb); 191 193 return err; 192 194 } 193 195
+2 -3
net/openvswitch/vport.c
··· 519 519 u64_stats_update_end(&stats->syncp); 520 520 } else if (sent < 0) { 521 521 ovs_vport_record_error(vport, VPORT_E_TX_ERROR); 522 - kfree_skb(skb); 523 - } else 522 + } else { 524 523 ovs_vport_record_error(vport, VPORT_E_TX_DROPPED); 525 - 524 + } 526 525 return sent; 527 526 } 528 527
+7 -4
net/packet/af_packet.c
··· 785 785 786 786 struct tpacket3_hdr *last_pkt; 787 787 struct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1; 788 + struct sock *sk = &po->sk; 788 789 789 790 if (po->stats.stats3.tp_drops) 790 791 status |= TP_STATUS_LOSING; ··· 809 808 810 809 /* Flush the block */ 811 810 prb_flush_block(pkc1, pbd1, status); 811 + 812 + sk->sk_data_ready(sk); 812 813 813 814 pkc1->kactive_blk_num = GET_NEXT_PRB_BLK_NUM(pkc1); 814 815 } ··· 2055 2052 smp_wmb(); 2056 2053 #endif 2057 2054 2058 - if (po->tp_version <= TPACKET_V2) 2055 + if (po->tp_version <= TPACKET_V2) { 2059 2056 __packet_set_status(po, h.raw, status); 2060 - else 2057 + sk->sk_data_ready(sk); 2058 + } else { 2061 2059 prb_clear_blk_fill_status(&po->rx_ring); 2062 - 2063 - sk->sk_data_ready(sk); 2060 + } 2064 2061 2065 2062 drop_n_restore: 2066 2063 if (skb_head != skb->data && skb_shared(skb)) {