diff options
98 files changed, 1444 insertions, 1193 deletions
diff --git a/drivers/infiniband/hw/mlx4/Kconfig b/drivers/infiniband/hw/mlx4/Kconfig index 4175a4bd0c78..bd995b2b50d8 100644 --- a/drivers/infiniband/hw/mlx4/Kconfig +++ b/drivers/infiniband/hw/mlx4/Kconfig | |||
@@ -1,5 +1,6 @@ | |||
1 | config MLX4_INFINIBAND | 1 | config MLX4_INFINIBAND |
2 | tristate "Mellanox ConnectX HCA support" | 2 | tristate "Mellanox ConnectX HCA support" |
3 | depends on NETDEVICES && NETDEV_10000 && PCI | ||
3 | select MLX4_CORE | 4 | select MLX4_CORE |
4 | ---help--- | 5 | ---help--- |
5 | This driver provides low-level InfiniBand support for | 6 | This driver provides low-level InfiniBand support for |
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c index ca00f0a11217..de579d043169 100644 --- a/drivers/net/3c523.c +++ b/drivers/net/3c523.c | |||
@@ -287,7 +287,7 @@ static int elmc_open(struct net_device *dev) | |||
287 | 287 | ||
288 | elmc_id_attn586(); /* disable interrupts */ | 288 | elmc_id_attn586(); /* disable interrupts */ |
289 | 289 | ||
290 | ret = request_irq(dev->irq, elmc_interrupt, IRQF_SHARED | IRQF_SAMPLE_RANDOM, | 290 | ret = request_irq(dev->irq, elmc_interrupt, IRQF_SHARED, |
291 | dev->name, dev); | 291 | dev->name, dev); |
292 | if (ret) { | 292 | if (ret) { |
293 | pr_err("%s: couldn't get irq %d\n", dev->name, dev->irq); | 293 | pr_err("%s: couldn't get irq %d\n", dev->name, dev->irq); |
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c index 70705d1306b9..0d6ca1e407d0 100644 --- a/drivers/net/3c527.c +++ b/drivers/net/3c527.c | |||
@@ -443,7 +443,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot) | |||
443 | * Grab the IRQ | 443 | * Grab the IRQ |
444 | */ | 444 | */ |
445 | 445 | ||
446 | err = request_irq(dev->irq, mc32_interrupt, IRQF_SHARED | IRQF_SAMPLE_RANDOM, DRV_NAME, dev); | 446 | err = request_irq(dev->irq, mc32_interrupt, IRQF_SHARED, DRV_NAME, dev); |
447 | if (err) { | 447 | if (err) { |
448 | release_region(dev->base_addr, MC32_IO_EXTENT); | 448 | release_region(dev->base_addr, MC32_IO_EXTENT); |
449 | pr_err("%s: unable to get IRQ %d.\n", DRV_NAME, dev->irq); | 449 | pr_err("%s: unable to get IRQ %d.\n", DRV_NAME, dev->irq); |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 13d01f358f34..d24f54b8c19a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -177,6 +177,13 @@ config NET_SB1000 | |||
177 | 177 | ||
178 | source "drivers/net/arcnet/Kconfig" | 178 | source "drivers/net/arcnet/Kconfig" |
179 | 179 | ||
180 | config MII | ||
181 | tristate "Generic Media Independent Interface device support" | ||
182 | help | ||
183 | Most ethernet controllers have MII transceiver either as an external | ||
184 | or internal device. It is safe to say Y or M here even if your | ||
185 | ethernet card lacks MII. | ||
186 | |||
180 | source "drivers/net/phy/Kconfig" | 187 | source "drivers/net/phy/Kconfig" |
181 | 188 | ||
182 | # | 189 | # |
@@ -212,13 +219,6 @@ menuconfig NET_ETHERNET | |||
212 | 219 | ||
213 | if NET_ETHERNET | 220 | if NET_ETHERNET |
214 | 221 | ||
215 | config MII | ||
216 | tristate "Generic Media Independent Interface device support" | ||
217 | help | ||
218 | Most ethernet controllers have MII transceiver either as an external | ||
219 | or internal device. It is safe to say Y or M here even if your | ||
220 | ethernet card lack MII. | ||
221 | |||
222 | config MACB | 222 | config MACB |
223 | tristate "Atmel MACB support" | 223 | tristate "Atmel MACB support" |
224 | depends on AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263 || ARCH_AT91SAM9G20 || ARCH_AT91SAM9G45 || ARCH_AT91CAP9 | 224 | depends on AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263 || ARCH_AT91SAM9G20 || ARCH_AT91SAM9G45 || ARCH_AT91CAP9 |
diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h index c49b643e009b..3bf236b160dd 100644 --- a/drivers/net/bnx2x/bnx2x.h +++ b/drivers/net/bnx2x/bnx2x.h | |||
@@ -20,8 +20,8 @@ | |||
20 | * (you will need to reboot afterwards) */ | 20 | * (you will need to reboot afterwards) */ |
21 | /* #define BNX2X_STOP_ON_ERROR */ | 21 | /* #define BNX2X_STOP_ON_ERROR */ |
22 | 22 | ||
23 | #define DRV_MODULE_VERSION "1.60.00-1" | 23 | #define DRV_MODULE_VERSION "1.60.00-3" |
24 | #define DRV_MODULE_RELDATE "2010/10/06" | 24 | #define DRV_MODULE_RELDATE "2010/10/19" |
25 | #define BNX2X_BC_VER 0x040200 | 25 | #define BNX2X_BC_VER 0x040200 |
26 | 26 | ||
27 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | 27 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) |
@@ -1180,15 +1180,10 @@ struct bnx2x { | |||
1180 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY | 1180 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_IPV6_TCP_CAPABILITY |
1181 | 1181 | ||
1182 | /* func init flags */ | 1182 | /* func init flags */ |
1183 | #define FUNC_FLG_RSS 0x0001 | 1183 | #define FUNC_FLG_STATS 0x0001 |
1184 | #define FUNC_FLG_STATS 0x0002 | 1184 | #define FUNC_FLG_TPA 0x0002 |
1185 | /* removed FUNC_FLG_UNMATCHED 0x0004 */ | 1185 | #define FUNC_FLG_SPQ 0x0004 |
1186 | #define FUNC_FLG_TPA 0x0008 | 1186 | #define FUNC_FLG_LEADING 0x0008 /* PF only */ |
1187 | #define FUNC_FLG_SPQ 0x0010 | ||
1188 | #define FUNC_FLG_LEADING 0x0020 /* PF only */ | ||
1189 | |||
1190 | #define FUNC_CONFIG(flgs) ((flgs) & (FUNC_FLG_RSS | FUNC_FLG_TPA | \ | ||
1191 | FUNC_FLG_LEADING)) | ||
1192 | 1187 | ||
1193 | struct rxq_pause_params { | 1188 | struct rxq_pause_params { |
1194 | u16 bd_th_lo; | 1189 | u16 bd_th_lo; |
diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c index 97ef674dcc34..1966ceeefcd4 100644 --- a/drivers/net/bnx2x/bnx2x_cmn.c +++ b/drivers/net/bnx2x/bnx2x_cmn.c | |||
@@ -507,8 +507,11 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | |||
507 | len = le16_to_cpu(cqe->fast_path_cqe.pkt_len); | 507 | len = le16_to_cpu(cqe->fast_path_cqe.pkt_len); |
508 | pad = cqe->fast_path_cqe.placement_offset; | 508 | pad = cqe->fast_path_cqe.placement_offset; |
509 | 509 | ||
510 | /* If CQE is marked both TPA_START and TPA_END | 510 | /* - If CQE is marked both TPA_START and TPA_END it is |
511 | it is a non-TPA CQE */ | 511 | * a non-TPA CQE. |
512 | * - FP CQE will always have either TPA_START or/and | ||
513 | * TPA_STOP flags set. | ||
514 | */ | ||
512 | if ((!fp->disable_tpa) && | 515 | if ((!fp->disable_tpa) && |
513 | (TPA_TYPE(cqe_fp_flags) != | 516 | (TPA_TYPE(cqe_fp_flags) != |
514 | (TPA_TYPE_START | TPA_TYPE_END))) { | 517 | (TPA_TYPE_START | TPA_TYPE_END))) { |
@@ -526,9 +529,7 @@ int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget) | |||
526 | bnx2x_set_skb_rxhash(bp, cqe, skb); | 529 | bnx2x_set_skb_rxhash(bp, cqe, skb); |
527 | 530 | ||
528 | goto next_rx; | 531 | goto next_rx; |
529 | } | 532 | } else { /* TPA_STOP */ |
530 | |||
531 | if (TPA_TYPE(cqe_fp_flags) == TPA_TYPE_END) { | ||
532 | DP(NETIF_MSG_RX_STATUS, | 533 | DP(NETIF_MSG_RX_STATUS, |
533 | "calling tpa_stop on queue %d\n", | 534 | "calling tpa_stop on queue %d\n", |
534 | queue); | 535 | queue); |
@@ -830,7 +831,7 @@ void bnx2x_init_rx_rings(struct bnx2x *bp) | |||
830 | int i, j; | 831 | int i, j; |
831 | 832 | ||
832 | bp->rx_buf_size = bp->dev->mtu + ETH_OVREHEAD + BNX2X_RX_ALIGN + | 833 | bp->rx_buf_size = bp->dev->mtu + ETH_OVREHEAD + BNX2X_RX_ALIGN + |
833 | BNX2X_FW_IP_HDR_ALIGN_PAD; | 834 | IP_HEADER_ALIGNMENT_PADDING; |
834 | 835 | ||
835 | DP(NETIF_MSG_IFUP, | 836 | DP(NETIF_MSG_IFUP, |
836 | "mtu %d rx_buf_size %d\n", bp->dev->mtu, bp->rx_buf_size); | 837 | "mtu %d rx_buf_size %d\n", bp->dev->mtu, bp->rx_buf_size); |
@@ -1288,8 +1289,6 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) | |||
1288 | if (rc) { | 1289 | if (rc) { |
1289 | BNX2X_ERR("HW init failed, aborting\n"); | 1290 | BNX2X_ERR("HW init failed, aborting\n"); |
1290 | bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_DONE, 0); | 1291 | bnx2x_fw_command(bp, DRV_MSG_CODE_LOAD_DONE, 0); |
1291 | bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_REQ_WOL_MCP, 0); | ||
1292 | bnx2x_fw_command(bp, DRV_MSG_CODE_UNLOAD_DONE, 0); | ||
1293 | goto load_error2; | 1292 | goto load_error2; |
1294 | } | 1293 | } |
1295 | 1294 | ||
@@ -1522,6 +1521,12 @@ int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state) | |||
1522 | { | 1521 | { |
1523 | u16 pmcsr; | 1522 | u16 pmcsr; |
1524 | 1523 | ||
1524 | /* If there is no power capability, silently succeed */ | ||
1525 | if (!bp->pm_cap) { | ||
1526 | DP(NETIF_MSG_HW, "No power capability. Breaking.\n"); | ||
1527 | return 0; | ||
1528 | } | ||
1529 | |||
1525 | pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmcsr); | 1530 | pci_read_config_word(bp->pdev, bp->pm_cap + PCI_PM_CTRL, &pmcsr); |
1526 | 1531 | ||
1527 | switch (state) { | 1532 | switch (state) { |
diff --git a/drivers/net/bnx2x/bnx2x_cmn.h b/drivers/net/bnx2x/bnx2x_cmn.h index 7f52cec9bb99..5bfe0ab1d2d4 100644 --- a/drivers/net/bnx2x/bnx2x_cmn.h +++ b/drivers/net/bnx2x/bnx2x_cmn.h | |||
@@ -1032,6 +1032,4 @@ static inline void storm_memset_cmng(struct bnx2x *bp, | |||
1032 | void bnx2x_acquire_phy_lock(struct bnx2x *bp); | 1032 | void bnx2x_acquire_phy_lock(struct bnx2x *bp); |
1033 | void bnx2x_release_phy_lock(struct bnx2x *bp); | 1033 | void bnx2x_release_phy_lock(struct bnx2x *bp); |
1034 | 1034 | ||
1035 | #define BNX2X_FW_IP_HDR_ALIGN_PAD 2 /* FW places hdr with this padding */ | ||
1036 | |||
1037 | #endif /* BNX2X_CMN_H */ | 1035 | #endif /* BNX2X_CMN_H */ |
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c index ead524bca8f2..f22e283cabef 100644 --- a/drivers/net/bnx2x/bnx2x_main.c +++ b/drivers/net/bnx2x/bnx2x_main.c | |||
@@ -1111,14 +1111,19 @@ static void bnx2x_hc_int_enable(struct bnx2x *bp) | |||
1111 | HC_CONFIG_0_REG_INT_LINE_EN_0 | | 1111 | HC_CONFIG_0_REG_INT_LINE_EN_0 | |
1112 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); | 1112 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); |
1113 | 1113 | ||
1114 | DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", | 1114 | if (!CHIP_IS_E1(bp)) { |
1115 | val, port, addr); | 1115 | DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", |
1116 | val, port, addr); | ||
1116 | 1117 | ||
1117 | REG_WR(bp, addr, val); | 1118 | REG_WR(bp, addr, val); |
1118 | 1119 | ||
1119 | val &= ~HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0; | 1120 | val &= ~HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0; |
1121 | } | ||
1120 | } | 1122 | } |
1121 | 1123 | ||
1124 | if (CHIP_IS_E1(bp)) | ||
1125 | REG_WR(bp, HC_REG_INT_MASK + port*4, 0x1FFFF); | ||
1126 | |||
1122 | DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x) mode %s\n", | 1127 | DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x) mode %s\n", |
1123 | val, port, addr, (msix ? "MSI-X" : (msi ? "MSI" : "INTx"))); | 1128 | val, port, addr, (msix ? "MSI-X" : (msi ? "MSI" : "INTx"))); |
1124 | 1129 | ||
@@ -1212,10 +1217,26 @@ static void bnx2x_hc_int_disable(struct bnx2x *bp) | |||
1212 | u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0; | 1217 | u32 addr = port ? HC_REG_CONFIG_1 : HC_REG_CONFIG_0; |
1213 | u32 val = REG_RD(bp, addr); | 1218 | u32 val = REG_RD(bp, addr); |
1214 | 1219 | ||
1215 | val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | | 1220 | /* |
1216 | HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 | | 1221 | * in E1 we must use only PCI configuration space to disable |
1217 | HC_CONFIG_0_REG_INT_LINE_EN_0 | | 1222 | * MSI/MSIX capablility |
1218 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); | 1223 | * It's forbitten to disable IGU_PF_CONF_MSI_MSIX_EN in HC block |
1224 | */ | ||
1225 | if (CHIP_IS_E1(bp)) { | ||
1226 | /* Since IGU_PF_CONF_MSI_MSIX_EN still always on | ||
1227 | * Use mask register to prevent from HC sending interrupts | ||
1228 | * after we exit the function | ||
1229 | */ | ||
1230 | REG_WR(bp, HC_REG_INT_MASK + port*4, 0); | ||
1231 | |||
1232 | val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | | ||
1233 | HC_CONFIG_0_REG_INT_LINE_EN_0 | | ||
1234 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); | ||
1235 | } else | ||
1236 | val &= ~(HC_CONFIG_0_REG_SINGLE_ISR_EN_0 | | ||
1237 | HC_CONFIG_0_REG_MSI_MSIX_INT_EN_0 | | ||
1238 | HC_CONFIG_0_REG_INT_LINE_EN_0 | | ||
1239 | HC_CONFIG_0_REG_ATTN_BIT_EN_0); | ||
1219 | 1240 | ||
1220 | DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", | 1241 | DP(NETIF_MSG_INTR, "write %x to HC %d (addr 0x%x)\n", |
1221 | val, port, addr); | 1242 | val, port, addr); |
@@ -2284,35 +2305,31 @@ void bnx2x_rxq_set_mac_filters(struct bnx2x *bp, u16 cl_id, u32 filters) | |||
2284 | 2305 | ||
2285 | void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p) | 2306 | void bnx2x_func_init(struct bnx2x *bp, struct bnx2x_func_init_params *p) |
2286 | { | 2307 | { |
2287 | if (FUNC_CONFIG(p->func_flgs)) { | 2308 | struct tstorm_eth_function_common_config tcfg = {0}; |
2288 | struct tstorm_eth_function_common_config tcfg = {0}; | 2309 | u16 rss_flgs; |
2289 | |||
2290 | /* tpa */ | ||
2291 | if (p->func_flgs & FUNC_FLG_TPA) | ||
2292 | tcfg.config_flags |= | ||
2293 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_ENABLE_TPA; | ||
2294 | 2310 | ||
2295 | /* set rss flags */ | 2311 | /* tpa */ |
2296 | if (p->func_flgs & FUNC_FLG_RSS) { | 2312 | if (p->func_flgs & FUNC_FLG_TPA) |
2297 | u16 rss_flgs = (p->rss->mode << | 2313 | tcfg.config_flags |= |
2298 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT); | 2314 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_ENABLE_TPA; |
2299 | 2315 | ||
2300 | if (p->rss->cap & RSS_IPV4_CAP) | 2316 | /* set rss flags */ |
2301 | rss_flgs |= RSS_IPV4_CAP_MASK; | 2317 | rss_flgs = (p->rss->mode << |
2302 | if (p->rss->cap & RSS_IPV4_TCP_CAP) | 2318 | TSTORM_ETH_FUNCTION_COMMON_CONFIG_RSS_MODE_SHIFT); |
2303 | rss_flgs |= RSS_IPV4_TCP_CAP_MASK; | ||
2304 | if (p->rss->cap & RSS_IPV6_CAP) | ||
2305 | rss_flgs |= RSS_IPV6_CAP_MASK; | ||
2306 | if (p->rss->cap & RSS_IPV6_TCP_CAP) | ||
2307 | rss_flgs |= RSS_IPV6_TCP_CAP_MASK; | ||
2308 | 2319 | ||
2309 | tcfg.config_flags |= rss_flgs; | 2320 | if (p->rss->cap & RSS_IPV4_CAP) |
2310 | tcfg.rss_result_mask = p->rss->result_mask; | 2321 | rss_flgs |= RSS_IPV4_CAP_MASK; |
2322 | if (p->rss->cap & RSS_IPV4_TCP_CAP) | ||
2323 | rss_flgs |= RSS_IPV4_TCP_CAP_MASK; | ||
2324 | if (p->rss->cap & RSS_IPV6_CAP) | ||
2325 | rss_flgs |= RSS_IPV6_CAP_MASK; | ||
2326 | if (p->rss->cap & RSS_IPV6_TCP_CAP) | ||
2327 | rss_flgs |= RSS_IPV6_TCP_CAP_MASK; | ||
2311 | 2328 | ||
2312 | } | 2329 | tcfg.config_flags |= rss_flgs; |
2330 | tcfg.rss_result_mask = p->rss->result_mask; | ||
2313 | 2331 | ||
2314 | storm_memset_func_cfg(bp, &tcfg, p->func_id); | 2332 | storm_memset_func_cfg(bp, &tcfg, p->func_id); |
2315 | } | ||
2316 | 2333 | ||
2317 | /* Enable the function in the FW */ | 2334 | /* Enable the function in the FW */ |
2318 | storm_memset_vf_to_pf(bp, p->func_id, p->pf_id); | 2335 | storm_memset_vf_to_pf(bp, p->func_id, p->pf_id); |
@@ -2479,23 +2496,17 @@ void bnx2x_pf_init(struct bnx2x *bp) | |||
2479 | else | 2496 | else |
2480 | flags |= FUNC_FLG_TPA; | 2497 | flags |= FUNC_FLG_TPA; |
2481 | 2498 | ||
2499 | /* function setup */ | ||
2500 | |||
2482 | /** | 2501 | /** |
2483 | * Although RSS is meaningless when there is a single HW queue we | 2502 | * Although RSS is meaningless when there is a single HW queue we |
2484 | * still need it enabled in order to have HW Rx hash generated. | 2503 | * still need it enabled in order to have HW Rx hash generated. |
2485 | * | ||
2486 | * if (is_eth_multi(bp)) | ||
2487 | * flags |= FUNC_FLG_RSS; | ||
2488 | */ | 2504 | */ |
2489 | flags |= FUNC_FLG_RSS; | 2505 | rss.cap = (RSS_IPV4_CAP | RSS_IPV4_TCP_CAP | |
2490 | 2506 | RSS_IPV6_CAP | RSS_IPV6_TCP_CAP); | |
2491 | /* function setup */ | 2507 | rss.mode = bp->multi_mode; |
2492 | if (flags & FUNC_FLG_RSS) { | 2508 | rss.result_mask = MULTI_MASK; |
2493 | rss.cap = (RSS_IPV4_CAP | RSS_IPV4_TCP_CAP | | 2509 | func_init.rss = &rss; |
2494 | RSS_IPV6_CAP | RSS_IPV6_TCP_CAP); | ||
2495 | rss.mode = bp->multi_mode; | ||
2496 | rss.result_mask = MULTI_MASK; | ||
2497 | func_init.rss = &rss; | ||
2498 | } | ||
2499 | 2510 | ||
2500 | func_init.func_flgs = flags; | 2511 | func_init.func_flgs = flags; |
2501 | func_init.pf_id = BP_FUNC(bp); | 2512 | func_init.pf_id = BP_FUNC(bp); |
@@ -5446,7 +5457,8 @@ static int bnx2x_init_hw_func(struct bnx2x *bp) | |||
5446 | struct bnx2x_ilt *ilt = BP_ILT(bp); | 5457 | struct bnx2x_ilt *ilt = BP_ILT(bp); |
5447 | u16 cdu_ilt_start; | 5458 | u16 cdu_ilt_start; |
5448 | u32 addr, val; | 5459 | u32 addr, val; |
5449 | int i; | 5460 | u32 main_mem_base, main_mem_size, main_mem_prty_clr; |
5461 | int i, main_mem_width; | ||
5450 | 5462 | ||
5451 | DP(BNX2X_MSG_MCP, "starting func init func %d\n", func); | 5463 | DP(BNX2X_MSG_MCP, "starting func init func %d\n", func); |
5452 | 5464 | ||
@@ -5695,6 +5707,31 @@ static int bnx2x_init_hw_func(struct bnx2x *bp) | |||
5695 | bnx2x_init_block(bp, MCP_BLOCK, FUNC0_STAGE + func); | 5707 | bnx2x_init_block(bp, MCP_BLOCK, FUNC0_STAGE + func); |
5696 | bnx2x_init_block(bp, DMAE_BLOCK, FUNC0_STAGE + func); | 5708 | bnx2x_init_block(bp, DMAE_BLOCK, FUNC0_STAGE + func); |
5697 | 5709 | ||
5710 | if (CHIP_IS_E1x(bp)) { | ||
5711 | main_mem_size = HC_REG_MAIN_MEMORY_SIZE / 2; /*dwords*/ | ||
5712 | main_mem_base = HC_REG_MAIN_MEMORY + | ||
5713 | BP_PORT(bp) * (main_mem_size * 4); | ||
5714 | main_mem_prty_clr = HC_REG_HC_PRTY_STS_CLR; | ||
5715 | main_mem_width = 8; | ||
5716 | |||
5717 | val = REG_RD(bp, main_mem_prty_clr); | ||
5718 | if (val) | ||
5719 | DP(BNX2X_MSG_MCP, "Hmmm... Parity errors in HC " | ||
5720 | "block during " | ||
5721 | "function init (0x%x)!\n", val); | ||
5722 | |||
5723 | /* Clear "false" parity errors in MSI-X table */ | ||
5724 | for (i = main_mem_base; | ||
5725 | i < main_mem_base + main_mem_size * 4; | ||
5726 | i += main_mem_width) { | ||
5727 | bnx2x_read_dmae(bp, i, main_mem_width / 4); | ||
5728 | bnx2x_write_dmae(bp, bnx2x_sp_mapping(bp, wb_data), | ||
5729 | i, main_mem_width / 4); | ||
5730 | } | ||
5731 | /* Clear HC parity attention */ | ||
5732 | REG_RD(bp, main_mem_prty_clr); | ||
5733 | } | ||
5734 | |||
5698 | bnx2x_phy_probe(&bp->link_params); | 5735 | bnx2x_phy_probe(&bp->link_params); |
5699 | 5736 | ||
5700 | return 0; | 5737 | return 0; |
diff --git a/drivers/net/bnx2x/bnx2x_reg.h b/drivers/net/bnx2x/bnx2x_reg.h index 18a86284ebcc..1cefe489a955 100644 --- a/drivers/net/bnx2x/bnx2x_reg.h +++ b/drivers/net/bnx2x/bnx2x_reg.h | |||
@@ -800,9 +800,13 @@ | |||
800 | #define HC_REG_HC_PRTY_MASK 0x1080a0 | 800 | #define HC_REG_HC_PRTY_MASK 0x1080a0 |
801 | /* [R 3] Parity register #0 read */ | 801 | /* [R 3] Parity register #0 read */ |
802 | #define HC_REG_HC_PRTY_STS 0x108094 | 802 | #define HC_REG_HC_PRTY_STS 0x108094 |
803 | #define HC_REG_INT_MASK 0x108108 | 803 | /* [RC 3] Parity register #0 read clear */ |
804 | #define HC_REG_HC_PRTY_STS_CLR 0x108098 | ||
805 | #define HC_REG_INT_MASK 0x108108 | ||
804 | #define HC_REG_LEADING_EDGE_0 0x108040 | 806 | #define HC_REG_LEADING_EDGE_0 0x108040 |
805 | #define HC_REG_LEADING_EDGE_1 0x108048 | 807 | #define HC_REG_LEADING_EDGE_1 0x108048 |
808 | #define HC_REG_MAIN_MEMORY 0x108800 | ||
809 | #define HC_REG_MAIN_MEMORY_SIZE 152 | ||
806 | #define HC_REG_P0_PROD_CONS 0x108200 | 810 | #define HC_REG_P0_PROD_CONS 0x108200 |
807 | #define HC_REG_P1_PROD_CONS 0x108400 | 811 | #define HC_REG_P1_PROD_CONS 0x108400 |
808 | #define HC_REG_PBA_COMMAND 0x108140 | 812 | #define HC_REG_PBA_COMMAND 0x108140 |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 7703d35de65d..6b9a7bd8ec14 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -76,6 +76,7 @@ | |||
76 | #include <linux/if_vlan.h> | 76 | #include <linux/if_vlan.h> |
77 | #include <linux/if_bonding.h> | 77 | #include <linux/if_bonding.h> |
78 | #include <linux/jiffies.h> | 78 | #include <linux/jiffies.h> |
79 | #include <linux/preempt.h> | ||
79 | #include <net/route.h> | 80 | #include <net/route.h> |
80 | #include <net/net_namespace.h> | 81 | #include <net/net_namespace.h> |
81 | #include <net/netns/generic.h> | 82 | #include <net/netns/generic.h> |
@@ -169,6 +170,10 @@ MODULE_PARM_DESC(resend_igmp, "Number of IGMP membership reports to send on link | |||
169 | 170 | ||
170 | /*----------------------------- Global variables ----------------------------*/ | 171 | /*----------------------------- Global variables ----------------------------*/ |
171 | 172 | ||
173 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
174 | cpumask_var_t netpoll_block_tx; | ||
175 | #endif | ||
176 | |||
172 | static const char * const version = | 177 | static const char * const version = |
173 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; | 178 | DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; |
174 | 179 | ||
@@ -179,9 +184,6 @@ static int arp_ip_count; | |||
179 | static int bond_mode = BOND_MODE_ROUNDROBIN; | 184 | static int bond_mode = BOND_MODE_ROUNDROBIN; |
180 | static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2; | 185 | static int xmit_hashtype = BOND_XMIT_POLICY_LAYER2; |
181 | static int lacp_fast; | 186 | static int lacp_fast; |
182 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
183 | static int disable_netpoll = 1; | ||
184 | #endif | ||
185 | 187 | ||
186 | const struct bond_parm_tbl bond_lacp_tbl[] = { | 188 | const struct bond_parm_tbl bond_lacp_tbl[] = { |
187 | { "slow", AD_LACP_SLOW}, | 189 | { "slow", AD_LACP_SLOW}, |
@@ -310,6 +312,7 @@ static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id) | |||
310 | 312 | ||
311 | pr_debug("bond: %s, vlan id %d\n", bond->dev->name, vlan_id); | 313 | pr_debug("bond: %s, vlan id %d\n", bond->dev->name, vlan_id); |
312 | 314 | ||
315 | block_netpoll_tx(); | ||
313 | write_lock_bh(&bond->lock); | 316 | write_lock_bh(&bond->lock); |
314 | 317 | ||
315 | list_for_each_entry(vlan, &bond->vlan_list, vlan_list) { | 318 | list_for_each_entry(vlan, &bond->vlan_list, vlan_list) { |
@@ -344,6 +347,7 @@ static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id) | |||
344 | 347 | ||
345 | out: | 348 | out: |
346 | write_unlock_bh(&bond->lock); | 349 | write_unlock_bh(&bond->lock); |
350 | unblock_netpoll_tx(); | ||
347 | return res; | 351 | return res; |
348 | } | 352 | } |
349 | 353 | ||
@@ -449,11 +453,9 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, | |||
449 | if (unlikely(bond->dev->priv_flags & IFF_IN_NETPOLL)) { | 453 | if (unlikely(bond->dev->priv_flags & IFF_IN_NETPOLL)) { |
450 | struct netpoll *np = bond->dev->npinfo->netpoll; | 454 | struct netpoll *np = bond->dev->npinfo->netpoll; |
451 | slave_dev->npinfo = bond->dev->npinfo; | 455 | slave_dev->npinfo = bond->dev->npinfo; |
452 | np->real_dev = np->dev = skb->dev; | ||
453 | slave_dev->priv_flags |= IFF_IN_NETPOLL; | 456 | slave_dev->priv_flags |= IFF_IN_NETPOLL; |
454 | netpoll_send_skb(np, skb); | 457 | netpoll_send_skb_on_dev(np, skb, slave_dev); |
455 | slave_dev->priv_flags &= ~IFF_IN_NETPOLL; | 458 | slave_dev->priv_flags &= ~IFF_IN_NETPOLL; |
456 | np->dev = bond->dev; | ||
457 | } else | 459 | } else |
458 | #endif | 460 | #endif |
459 | dev_queue_xmit(skb); | 461 | dev_queue_xmit(skb); |
@@ -1332,9 +1334,14 @@ static bool slaves_support_netpoll(struct net_device *bond_dev) | |||
1332 | 1334 | ||
1333 | static void bond_poll_controller(struct net_device *bond_dev) | 1335 | static void bond_poll_controller(struct net_device *bond_dev) |
1334 | { | 1336 | { |
1335 | struct net_device *dev = bond_dev->npinfo->netpoll->real_dev; | 1337 | struct bonding *bond = netdev_priv(bond_dev); |
1336 | if (dev != bond_dev) | 1338 | struct slave *slave; |
1337 | netpoll_poll_dev(dev); | 1339 | int i; |
1340 | |||
1341 | bond_for_each_slave(bond, slave, i) { | ||
1342 | if (slave->dev && IS_UP(slave->dev)) | ||
1343 | netpoll_poll_dev(slave->dev); | ||
1344 | } | ||
1338 | } | 1345 | } |
1339 | 1346 | ||
1340 | static void bond_netpoll_cleanup(struct net_device *bond_dev) | 1347 | static void bond_netpoll_cleanup(struct net_device *bond_dev) |
@@ -1801,23 +1808,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1801 | bond_set_carrier(bond); | 1808 | bond_set_carrier(bond); |
1802 | 1809 | ||
1803 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1810 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1804 | /* | 1811 | if (slaves_support_netpoll(bond_dev)) { |
1805 | * Netpoll and bonding is broken, make sure it is not initialized | 1812 | bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; |
1806 | * until it is fixed. | 1813 | if (bond_dev->npinfo) |
1807 | */ | 1814 | slave_dev->npinfo = bond_dev->npinfo; |
1808 | if (disable_netpoll) { | 1815 | } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) { |
1809 | bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; | 1816 | bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; |
1810 | } else { | 1817 | pr_info("New slave device %s does not support netpoll\n", |
1811 | if (slaves_support_netpoll(bond_dev)) { | 1818 | slave_dev->name); |
1812 | bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; | 1819 | pr_info("Disabling netpoll support for %s\n", bond_dev->name); |
1813 | if (bond_dev->npinfo) | ||
1814 | slave_dev->npinfo = bond_dev->npinfo; | ||
1815 | } else if (!(bond_dev->priv_flags & IFF_DISABLE_NETPOLL)) { | ||
1816 | bond_dev->priv_flags |= IFF_DISABLE_NETPOLL; | ||
1817 | pr_info("New slave device %s does not support netpoll\n", | ||
1818 | slave_dev->name); | ||
1819 | pr_info("Disabling netpoll support for %s\n", bond_dev->name); | ||
1820 | } | ||
1821 | } | 1820 | } |
1822 | #endif | 1821 | #endif |
1823 | read_unlock(&bond->lock); | 1822 | read_unlock(&bond->lock); |
@@ -1889,6 +1888,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1889 | return -EINVAL; | 1888 | return -EINVAL; |
1890 | } | 1889 | } |
1891 | 1890 | ||
1891 | block_netpoll_tx(); | ||
1892 | netdev_bonding_change(bond_dev, NETDEV_BONDING_DESLAVE); | 1892 | netdev_bonding_change(bond_dev, NETDEV_BONDING_DESLAVE); |
1893 | write_lock_bh(&bond->lock); | 1893 | write_lock_bh(&bond->lock); |
1894 | 1894 | ||
@@ -1898,6 +1898,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1898 | pr_info("%s: %s not enslaved\n", | 1898 | pr_info("%s: %s not enslaved\n", |
1899 | bond_dev->name, slave_dev->name); | 1899 | bond_dev->name, slave_dev->name); |
1900 | write_unlock_bh(&bond->lock); | 1900 | write_unlock_bh(&bond->lock); |
1901 | unblock_netpoll_tx(); | ||
1901 | return -EINVAL; | 1902 | return -EINVAL; |
1902 | } | 1903 | } |
1903 | 1904 | ||
@@ -1991,6 +1992,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1991 | } | 1992 | } |
1992 | 1993 | ||
1993 | write_unlock_bh(&bond->lock); | 1994 | write_unlock_bh(&bond->lock); |
1995 | unblock_netpoll_tx(); | ||
1994 | 1996 | ||
1995 | /* must do this from outside any spinlocks */ | 1997 | /* must do this from outside any spinlocks */ |
1996 | bond_destroy_slave_symlinks(bond_dev, slave_dev); | 1998 | bond_destroy_slave_symlinks(bond_dev, slave_dev); |
@@ -2021,10 +2023,8 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | |||
2021 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2023 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2022 | read_lock_bh(&bond->lock); | 2024 | read_lock_bh(&bond->lock); |
2023 | 2025 | ||
2024 | /* Make sure netpoll over stays disabled until fixed. */ | 2026 | if (slaves_support_netpoll(bond_dev)) |
2025 | if (!disable_netpoll) | 2027 | bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; |
2026 | if (slaves_support_netpoll(bond_dev)) | ||
2027 | bond_dev->priv_flags &= ~IFF_DISABLE_NETPOLL; | ||
2028 | read_unlock_bh(&bond->lock); | 2028 | read_unlock_bh(&bond->lock); |
2029 | if (slave_dev->netdev_ops->ndo_netpoll_cleanup) | 2029 | if (slave_dev->netdev_ops->ndo_netpoll_cleanup) |
2030 | slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev); | 2030 | slave_dev->netdev_ops->ndo_netpoll_cleanup(slave_dev); |
@@ -2180,7 +2180,6 @@ static int bond_release_all(struct net_device *bond_dev) | |||
2180 | 2180 | ||
2181 | out: | 2181 | out: |
2182 | write_unlock_bh(&bond->lock); | 2182 | write_unlock_bh(&bond->lock); |
2183 | |||
2184 | return 0; | 2183 | return 0; |
2185 | } | 2184 | } |
2186 | 2185 | ||
@@ -2229,9 +2228,11 @@ static int bond_ioctl_change_active(struct net_device *bond_dev, struct net_devi | |||
2229 | (old_active) && | 2228 | (old_active) && |
2230 | (new_active->link == BOND_LINK_UP) && | 2229 | (new_active->link == BOND_LINK_UP) && |
2231 | IS_UP(new_active->dev)) { | 2230 | IS_UP(new_active->dev)) { |
2231 | block_netpoll_tx(); | ||
2232 | write_lock_bh(&bond->curr_slave_lock); | 2232 | write_lock_bh(&bond->curr_slave_lock); |
2233 | bond_change_active_slave(bond, new_active); | 2233 | bond_change_active_slave(bond, new_active); |
2234 | write_unlock_bh(&bond->curr_slave_lock); | 2234 | write_unlock_bh(&bond->curr_slave_lock); |
2235 | unblock_netpoll_tx(); | ||
2235 | } else | 2236 | } else |
2236 | res = -EINVAL; | 2237 | res = -EINVAL; |
2237 | 2238 | ||
@@ -2463,9 +2464,11 @@ static void bond_miimon_commit(struct bonding *bond) | |||
2463 | 2464 | ||
2464 | do_failover: | 2465 | do_failover: |
2465 | ASSERT_RTNL(); | 2466 | ASSERT_RTNL(); |
2467 | block_netpoll_tx(); | ||
2466 | write_lock_bh(&bond->curr_slave_lock); | 2468 | write_lock_bh(&bond->curr_slave_lock); |
2467 | bond_select_active_slave(bond); | 2469 | bond_select_active_slave(bond); |
2468 | write_unlock_bh(&bond->curr_slave_lock); | 2470 | write_unlock_bh(&bond->curr_slave_lock); |
2471 | unblock_netpoll_tx(); | ||
2469 | } | 2472 | } |
2470 | 2473 | ||
2471 | bond_set_carrier(bond); | 2474 | bond_set_carrier(bond); |
@@ -2908,11 +2911,13 @@ void bond_loadbalance_arp_mon(struct work_struct *work) | |||
2908 | } | 2911 | } |
2909 | 2912 | ||
2910 | if (do_failover) { | 2913 | if (do_failover) { |
2914 | block_netpoll_tx(); | ||
2911 | write_lock_bh(&bond->curr_slave_lock); | 2915 | write_lock_bh(&bond->curr_slave_lock); |
2912 | 2916 | ||
2913 | bond_select_active_slave(bond); | 2917 | bond_select_active_slave(bond); |
2914 | 2918 | ||
2915 | write_unlock_bh(&bond->curr_slave_lock); | 2919 | write_unlock_bh(&bond->curr_slave_lock); |
2920 | unblock_netpoll_tx(); | ||
2916 | } | 2921 | } |
2917 | 2922 | ||
2918 | re_arm: | 2923 | re_arm: |
@@ -3071,9 +3076,11 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks) | |||
3071 | 3076 | ||
3072 | do_failover: | 3077 | do_failover: |
3073 | ASSERT_RTNL(); | 3078 | ASSERT_RTNL(); |
3079 | block_netpoll_tx(); | ||
3074 | write_lock_bh(&bond->curr_slave_lock); | 3080 | write_lock_bh(&bond->curr_slave_lock); |
3075 | bond_select_active_slave(bond); | 3081 | bond_select_active_slave(bond); |
3076 | write_unlock_bh(&bond->curr_slave_lock); | 3082 | write_unlock_bh(&bond->curr_slave_lock); |
3083 | unblock_netpoll_tx(); | ||
3077 | } | 3084 | } |
3078 | 3085 | ||
3079 | bond_set_carrier(bond); | 3086 | bond_set_carrier(bond); |
@@ -4561,6 +4568,13 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4561 | { | 4568 | { |
4562 | struct bonding *bond = netdev_priv(dev); | 4569 | struct bonding *bond = netdev_priv(dev); |
4563 | 4570 | ||
4571 | /* | ||
4572 | * If we risk deadlock from transmitting this in the | ||
4573 | * netpoll path, tell netpoll to queue the frame for later tx | ||
4574 | */ | ||
4575 | if (is_netpoll_tx_blocked(dev)) | ||
4576 | return NETDEV_TX_BUSY; | ||
4577 | |||
4564 | if (TX_QUEUE_OVERRIDE(bond->params.mode)) { | 4578 | if (TX_QUEUE_OVERRIDE(bond->params.mode)) { |
4565 | if (!bond_slave_override(bond, skb)) | 4579 | if (!bond_slave_override(bond, skb)) |
4566 | return NETDEV_TX_OK; | 4580 | return NETDEV_TX_OK; |
@@ -5283,6 +5297,13 @@ static int __init bonding_init(void) | |||
5283 | if (res) | 5297 | if (res) |
5284 | goto out; | 5298 | goto out; |
5285 | 5299 | ||
5300 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
5301 | if (!alloc_cpumask_var(&netpoll_block_tx, GFP_KERNEL)) { | ||
5302 | res = -ENOMEM; | ||
5303 | goto out; | ||
5304 | } | ||
5305 | #endif | ||
5306 | |||
5286 | res = register_pernet_subsys(&bond_net_ops); | 5307 | res = register_pernet_subsys(&bond_net_ops); |
5287 | if (res) | 5308 | if (res) |
5288 | goto out; | 5309 | goto out; |
@@ -5301,6 +5322,7 @@ static int __init bonding_init(void) | |||
5301 | if (res) | 5322 | if (res) |
5302 | goto err; | 5323 | goto err; |
5303 | 5324 | ||
5325 | |||
5304 | register_netdevice_notifier(&bond_netdev_notifier); | 5326 | register_netdevice_notifier(&bond_netdev_notifier); |
5305 | register_inetaddr_notifier(&bond_inetaddr_notifier); | 5327 | register_inetaddr_notifier(&bond_inetaddr_notifier); |
5306 | bond_register_ipv6_notifier(); | 5328 | bond_register_ipv6_notifier(); |
@@ -5310,6 +5332,9 @@ err: | |||
5310 | rtnl_link_unregister(&bond_link_ops); | 5332 | rtnl_link_unregister(&bond_link_ops); |
5311 | err_link: | 5333 | err_link: |
5312 | unregister_pernet_subsys(&bond_net_ops); | 5334 | unregister_pernet_subsys(&bond_net_ops); |
5335 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
5336 | free_cpumask_var(netpoll_block_tx); | ||
5337 | #endif | ||
5313 | goto out; | 5338 | goto out; |
5314 | 5339 | ||
5315 | } | 5340 | } |
@@ -5324,6 +5349,10 @@ static void __exit bonding_exit(void) | |||
5324 | 5349 | ||
5325 | rtnl_link_unregister(&bond_link_ops); | 5350 | rtnl_link_unregister(&bond_link_ops); |
5326 | unregister_pernet_subsys(&bond_net_ops); | 5351 | unregister_pernet_subsys(&bond_net_ops); |
5352 | |||
5353 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
5354 | free_cpumask_var(netpoll_block_tx); | ||
5355 | #endif | ||
5327 | } | 5356 | } |
5328 | 5357 | ||
5329 | module_init(bonding_init); | 5358 | module_init(bonding_init); |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 01b4c3f5d9e7..8fd0174c5380 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -1066,6 +1066,7 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1066 | 1066 | ||
1067 | if (!rtnl_trylock()) | 1067 | if (!rtnl_trylock()) |
1068 | return restart_syscall(); | 1068 | return restart_syscall(); |
1069 | block_netpoll_tx(); | ||
1069 | read_lock(&bond->lock); | 1070 | read_lock(&bond->lock); |
1070 | write_lock_bh(&bond->curr_slave_lock); | 1071 | write_lock_bh(&bond->curr_slave_lock); |
1071 | 1072 | ||
@@ -1101,6 +1102,7 @@ static ssize_t bonding_store_primary(struct device *d, | |||
1101 | out: | 1102 | out: |
1102 | write_unlock_bh(&bond->curr_slave_lock); | 1103 | write_unlock_bh(&bond->curr_slave_lock); |
1103 | read_unlock(&bond->lock); | 1104 | read_unlock(&bond->lock); |
1105 | unblock_netpoll_tx(); | ||
1104 | rtnl_unlock(); | 1106 | rtnl_unlock(); |
1105 | 1107 | ||
1106 | return count; | 1108 | return count; |
@@ -1146,11 +1148,13 @@ static ssize_t bonding_store_primary_reselect(struct device *d, | |||
1146 | bond->dev->name, pri_reselect_tbl[new_value].modename, | 1148 | bond->dev->name, pri_reselect_tbl[new_value].modename, |
1147 | new_value); | 1149 | new_value); |
1148 | 1150 | ||
1151 | block_netpoll_tx(); | ||
1149 | read_lock(&bond->lock); | 1152 | read_lock(&bond->lock); |
1150 | write_lock_bh(&bond->curr_slave_lock); | 1153 | write_lock_bh(&bond->curr_slave_lock); |
1151 | bond_select_active_slave(bond); | 1154 | bond_select_active_slave(bond); |
1152 | write_unlock_bh(&bond->curr_slave_lock); | 1155 | write_unlock_bh(&bond->curr_slave_lock); |
1153 | read_unlock(&bond->lock); | 1156 | read_unlock(&bond->lock); |
1157 | unblock_netpoll_tx(); | ||
1154 | out: | 1158 | out: |
1155 | rtnl_unlock(); | 1159 | rtnl_unlock(); |
1156 | return ret; | 1160 | return ret; |
@@ -1232,6 +1236,8 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1232 | 1236 | ||
1233 | if (!rtnl_trylock()) | 1237 | if (!rtnl_trylock()) |
1234 | return restart_syscall(); | 1238 | return restart_syscall(); |
1239 | |||
1240 | block_netpoll_tx(); | ||
1235 | read_lock(&bond->lock); | 1241 | read_lock(&bond->lock); |
1236 | write_lock_bh(&bond->curr_slave_lock); | 1242 | write_lock_bh(&bond->curr_slave_lock); |
1237 | 1243 | ||
@@ -1288,6 +1294,8 @@ static ssize_t bonding_store_active_slave(struct device *d, | |||
1288 | out: | 1294 | out: |
1289 | write_unlock_bh(&bond->curr_slave_lock); | 1295 | write_unlock_bh(&bond->curr_slave_lock); |
1290 | read_unlock(&bond->lock); | 1296 | read_unlock(&bond->lock); |
1297 | unblock_netpoll_tx(); | ||
1298 | |||
1291 | rtnl_unlock(); | 1299 | rtnl_unlock(); |
1292 | 1300 | ||
1293 | return count; | 1301 | return count; |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index c15f21347486..2c12a5f812f4 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/proc_fs.h> | 19 | #include <linux/proc_fs.h> |
20 | #include <linux/if_bonding.h> | 20 | #include <linux/if_bonding.h> |
21 | #include <linux/kobject.h> | 21 | #include <linux/kobject.h> |
22 | #include <linux/cpumask.h> | ||
22 | #include <linux/in6.h> | 23 | #include <linux/in6.h> |
23 | #include "bond_3ad.h" | 24 | #include "bond_3ad.h" |
24 | #include "bond_alb.h" | 25 | #include "bond_alb.h" |
@@ -117,6 +118,35 @@ | |||
117 | bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave) | 118 | bond_for_each_slave_from(bond, pos, cnt, (bond)->first_slave) |
118 | 119 | ||
119 | 120 | ||
121 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
122 | extern cpumask_var_t netpoll_block_tx; | ||
123 | |||
124 | static inline void block_netpoll_tx(void) | ||
125 | { | ||
126 | preempt_disable(); | ||
127 | BUG_ON(cpumask_test_and_set_cpu(smp_processor_id(), | ||
128 | netpoll_block_tx)); | ||
129 | } | ||
130 | |||
131 | static inline void unblock_netpoll_tx(void) | ||
132 | { | ||
133 | BUG_ON(!cpumask_test_and_clear_cpu(smp_processor_id(), | ||
134 | netpoll_block_tx)); | ||
135 | preempt_enable(); | ||
136 | } | ||
137 | |||
138 | static inline int is_netpoll_tx_blocked(struct net_device *dev) | ||
139 | { | ||
140 | if (unlikely(dev->priv_flags & IFF_IN_NETPOLL)) | ||
141 | return cpumask_test_cpu(smp_processor_id(), netpoll_block_tx); | ||
142 | return 0; | ||
143 | } | ||
144 | #else | ||
145 | #define block_netpoll_tx() | ||
146 | #define unblock_netpoll_tx() | ||
147 | #define is_netpoll_tx_blocked(dev) (0) | ||
148 | #endif | ||
149 | |||
120 | struct bond_params { | 150 | struct bond_params { |
121 | int mode; | 151 | int mode; |
122 | int xmit_policy; | 152 | int xmit_policy; |
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c index b11a0cb5ed81..c664be261e98 100644 --- a/drivers/net/can/mcp251x.c +++ b/drivers/net/can/mcp251x.c | |||
@@ -38,14 +38,14 @@ | |||
38 | * static struct mcp251x_platform_data mcp251x_info = { | 38 | * static struct mcp251x_platform_data mcp251x_info = { |
39 | * .oscillator_frequency = 8000000, | 39 | * .oscillator_frequency = 8000000, |
40 | * .board_specific_setup = &mcp251x_setup, | 40 | * .board_specific_setup = &mcp251x_setup, |
41 | * .model = CAN_MCP251X_MCP2510, | ||
42 | * .power_enable = mcp251x_power_enable, | 41 | * .power_enable = mcp251x_power_enable, |
43 | * .transceiver_enable = NULL, | 42 | * .transceiver_enable = NULL, |
44 | * }; | 43 | * }; |
45 | * | 44 | * |
46 | * static struct spi_board_info spi_board_info[] = { | 45 | * static struct spi_board_info spi_board_info[] = { |
47 | * { | 46 | * { |
48 | * .modalias = "mcp251x", | 47 | * .modalias = "mcp2510", |
48 | * // or "mcp2515" depending on your controller | ||
49 | * .platform_data = &mcp251x_info, | 49 | * .platform_data = &mcp251x_info, |
50 | * .irq = IRQ_EINT13, | 50 | * .irq = IRQ_EINT13, |
51 | * .max_speed_hz = 2*1000*1000, | 51 | * .max_speed_hz = 2*1000*1000, |
@@ -125,6 +125,8 @@ | |||
125 | # define CANINTF_TX0IF 0x04 | 125 | # define CANINTF_TX0IF 0x04 |
126 | # define CANINTF_RX1IF 0x02 | 126 | # define CANINTF_RX1IF 0x02 |
127 | # define CANINTF_RX0IF 0x01 | 127 | # define CANINTF_RX0IF 0x01 |
128 | # define CANINTF_ERR_TX \ | ||
129 | (CANINTF_ERRIF | CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF) | ||
128 | #define EFLG 0x2d | 130 | #define EFLG 0x2d |
129 | # define EFLG_EWARN 0x01 | 131 | # define EFLG_EWARN 0x01 |
130 | # define EFLG_RXWAR 0x02 | 132 | # define EFLG_RXWAR 0x02 |
@@ -222,10 +224,16 @@ static struct can_bittiming_const mcp251x_bittiming_const = { | |||
222 | .brp_inc = 1, | 224 | .brp_inc = 1, |
223 | }; | 225 | }; |
224 | 226 | ||
227 | enum mcp251x_model { | ||
228 | CAN_MCP251X_MCP2510 = 0x2510, | ||
229 | CAN_MCP251X_MCP2515 = 0x2515, | ||
230 | }; | ||
231 | |||
225 | struct mcp251x_priv { | 232 | struct mcp251x_priv { |
226 | struct can_priv can; | 233 | struct can_priv can; |
227 | struct net_device *net; | 234 | struct net_device *net; |
228 | struct spi_device *spi; | 235 | struct spi_device *spi; |
236 | enum mcp251x_model model; | ||
229 | 237 | ||
230 | struct mutex mcp_lock; /* SPI device lock */ | 238 | struct mutex mcp_lock; /* SPI device lock */ |
231 | 239 | ||
@@ -250,6 +258,16 @@ struct mcp251x_priv { | |||
250 | int restart_tx; | 258 | int restart_tx; |
251 | }; | 259 | }; |
252 | 260 | ||
261 | #define MCP251X_IS(_model) \ | ||
262 | static inline int mcp251x_is_##_model(struct spi_device *spi) \ | ||
263 | { \ | ||
264 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); \ | ||
265 | return priv->model == CAN_MCP251X_MCP##_model; \ | ||
266 | } | ||
267 | |||
268 | MCP251X_IS(2510); | ||
269 | MCP251X_IS(2515); | ||
270 | |||
253 | static void mcp251x_clean(struct net_device *net) | 271 | static void mcp251x_clean(struct net_device *net) |
254 | { | 272 | { |
255 | struct mcp251x_priv *priv = netdev_priv(net); | 273 | struct mcp251x_priv *priv = netdev_priv(net); |
@@ -319,6 +337,20 @@ static u8 mcp251x_read_reg(struct spi_device *spi, uint8_t reg) | |||
319 | return val; | 337 | return val; |
320 | } | 338 | } |
321 | 339 | ||
340 | static void mcp251x_read_2regs(struct spi_device *spi, uint8_t reg, | ||
341 | uint8_t *v1, uint8_t *v2) | ||
342 | { | ||
343 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); | ||
344 | |||
345 | priv->spi_tx_buf[0] = INSTRUCTION_READ; | ||
346 | priv->spi_tx_buf[1] = reg; | ||
347 | |||
348 | mcp251x_spi_trans(spi, 4); | ||
349 | |||
350 | *v1 = priv->spi_rx_buf[2]; | ||
351 | *v2 = priv->spi_rx_buf[3]; | ||
352 | } | ||
353 | |||
322 | static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val) | 354 | static void mcp251x_write_reg(struct spi_device *spi, u8 reg, uint8_t val) |
323 | { | 355 | { |
324 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); | 356 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); |
@@ -346,10 +378,9 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg, | |||
346 | static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf, | 378 | static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf, |
347 | int len, int tx_buf_idx) | 379 | int len, int tx_buf_idx) |
348 | { | 380 | { |
349 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; | ||
350 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); | 381 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); |
351 | 382 | ||
352 | if (pdata->model == CAN_MCP251X_MCP2510) { | 383 | if (mcp251x_is_2510(spi)) { |
353 | int i; | 384 | int i; |
354 | 385 | ||
355 | for (i = 1; i < TXBDAT_OFF + len; i++) | 386 | for (i = 1; i < TXBDAT_OFF + len; i++) |
@@ -392,9 +423,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf, | |||
392 | int buf_idx) | 423 | int buf_idx) |
393 | { | 424 | { |
394 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); | 425 | struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); |
395 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; | ||
396 | 426 | ||
397 | if (pdata->model == CAN_MCP251X_MCP2510) { | 427 | if (mcp251x_is_2510(spi)) { |
398 | int i, len; | 428 | int i, len; |
399 | 429 | ||
400 | for (i = 1; i < RXBDAT_OFF; i++) | 430 | for (i = 1; i < RXBDAT_OFF; i++) |
@@ -451,7 +481,7 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx) | |||
451 | 481 | ||
452 | priv->net->stats.rx_packets++; | 482 | priv->net->stats.rx_packets++; |
453 | priv->net->stats.rx_bytes += frame->can_dlc; | 483 | priv->net->stats.rx_bytes += frame->can_dlc; |
454 | netif_rx(skb); | 484 | netif_rx_ni(skb); |
455 | } | 485 | } |
456 | 486 | ||
457 | static void mcp251x_hw_sleep(struct spi_device *spi) | 487 | static void mcp251x_hw_sleep(struct spi_device *spi) |
@@ -676,7 +706,7 @@ static void mcp251x_error_skb(struct net_device *net, int can_id, int data1) | |||
676 | if (skb) { | 706 | if (skb) { |
677 | frame->can_id = can_id; | 707 | frame->can_id = can_id; |
678 | frame->data[1] = data1; | 708 | frame->data[1] = data1; |
679 | netif_rx(skb); | 709 | netif_rx_ni(skb); |
680 | } else { | 710 | } else { |
681 | dev_err(&net->dev, | 711 | dev_err(&net->dev, |
682 | "cannot allocate error skb\n"); | 712 | "cannot allocate error skb\n"); |
@@ -754,24 +784,39 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) | |||
754 | mutex_lock(&priv->mcp_lock); | 784 | mutex_lock(&priv->mcp_lock); |
755 | while (!priv->force_quit) { | 785 | while (!priv->force_quit) { |
756 | enum can_state new_state; | 786 | enum can_state new_state; |
757 | u8 intf = mcp251x_read_reg(spi, CANINTF); | 787 | u8 intf, eflag; |
758 | u8 eflag; | 788 | u8 clear_intf = 0; |
759 | int can_id = 0, data1 = 0; | 789 | int can_id = 0, data1 = 0; |
760 | 790 | ||
791 | mcp251x_read_2regs(spi, CANINTF, &intf, &eflag); | ||
792 | |||
793 | /* receive buffer 0 */ | ||
761 | if (intf & CANINTF_RX0IF) { | 794 | if (intf & CANINTF_RX0IF) { |
762 | mcp251x_hw_rx(spi, 0); | 795 | mcp251x_hw_rx(spi, 0); |
763 | /* Free one buffer ASAP */ | 796 | /* |
764 | mcp251x_write_bits(spi, CANINTF, intf & CANINTF_RX0IF, | 797 | * Free one buffer ASAP |
765 | 0x00); | 798 | * (The MCP2515 does this automatically.) |
799 | */ | ||
800 | if (mcp251x_is_2510(spi)) | ||
801 | mcp251x_write_bits(spi, CANINTF, CANINTF_RX0IF, 0x00); | ||
766 | } | 802 | } |
767 | 803 | ||
768 | if (intf & CANINTF_RX1IF) | 804 | /* receive buffer 1 */ |
805 | if (intf & CANINTF_RX1IF) { | ||
769 | mcp251x_hw_rx(spi, 1); | 806 | mcp251x_hw_rx(spi, 1); |
807 | /* the MCP2515 does this automatically */ | ||
808 | if (mcp251x_is_2510(spi)) | ||
809 | clear_intf |= CANINTF_RX1IF; | ||
810 | } | ||
770 | 811 | ||
771 | mcp251x_write_bits(spi, CANINTF, intf, 0x00); | 812 | /* any error or tx interrupt we need to clear? */ |
813 | if (intf & CANINTF_ERR_TX) | ||
814 | clear_intf |= intf & CANINTF_ERR_TX; | ||
815 | if (clear_intf) | ||
816 | mcp251x_write_bits(spi, CANINTF, clear_intf, 0x00); | ||
772 | 817 | ||
773 | eflag = mcp251x_read_reg(spi, EFLG); | 818 | if (eflag) |
774 | mcp251x_write_reg(spi, EFLG, 0x00); | 819 | mcp251x_write_bits(spi, EFLG, eflag, 0x00); |
775 | 820 | ||
776 | /* Update can state */ | 821 | /* Update can state */ |
777 | if (eflag & EFLG_TXBO) { | 822 | if (eflag & EFLG_TXBO) { |
@@ -816,10 +861,14 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) | |||
816 | if (intf & CANINTF_ERRIF) { | 861 | if (intf & CANINTF_ERRIF) { |
817 | /* Handle overflow counters */ | 862 | /* Handle overflow counters */ |
818 | if (eflag & (EFLG_RX0OVR | EFLG_RX1OVR)) { | 863 | if (eflag & (EFLG_RX0OVR | EFLG_RX1OVR)) { |
819 | if (eflag & EFLG_RX0OVR) | 864 | if (eflag & EFLG_RX0OVR) { |
820 | net->stats.rx_over_errors++; | 865 | net->stats.rx_over_errors++; |
821 | if (eflag & EFLG_RX1OVR) | 866 | net->stats.rx_errors++; |
867 | } | ||
868 | if (eflag & EFLG_RX1OVR) { | ||
822 | net->stats.rx_over_errors++; | 869 | net->stats.rx_over_errors++; |
870 | net->stats.rx_errors++; | ||
871 | } | ||
823 | can_id |= CAN_ERR_CRTL; | 872 | can_id |= CAN_ERR_CRTL; |
824 | data1 |= CAN_ERR_CRTL_RX_OVERFLOW; | 873 | data1 |= CAN_ERR_CRTL_RX_OVERFLOW; |
825 | } | 874 | } |
@@ -921,16 +970,12 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi) | |||
921 | struct net_device *net; | 970 | struct net_device *net; |
922 | struct mcp251x_priv *priv; | 971 | struct mcp251x_priv *priv; |
923 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; | 972 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; |
924 | int model = spi_get_device_id(spi)->driver_data; | ||
925 | int ret = -ENODEV; | 973 | int ret = -ENODEV; |
926 | 974 | ||
927 | if (!pdata) | 975 | if (!pdata) |
928 | /* Platform data is required for osc freq */ | 976 | /* Platform data is required for osc freq */ |
929 | goto error_out; | 977 | goto error_out; |
930 | 978 | ||
931 | if (model) | ||
932 | pdata->model = model; | ||
933 | |||
934 | /* Allocate can/net device */ | 979 | /* Allocate can/net device */ |
935 | net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); | 980 | net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); |
936 | if (!net) { | 981 | if (!net) { |
@@ -947,6 +992,7 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi) | |||
947 | priv->can.clock.freq = pdata->oscillator_frequency / 2; | 992 | priv->can.clock.freq = pdata->oscillator_frequency / 2; |
948 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | | 993 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | |
949 | CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY; | 994 | CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY; |
995 | priv->model = spi_get_device_id(spi)->driver_data; | ||
950 | priv->net = net; | 996 | priv->net = net; |
951 | dev_set_drvdata(&spi->dev, priv); | 997 | dev_set_drvdata(&spi->dev, priv); |
952 | 998 | ||
@@ -1120,8 +1166,7 @@ static int mcp251x_can_resume(struct spi_device *spi) | |||
1120 | #define mcp251x_can_resume NULL | 1166 | #define mcp251x_can_resume NULL |
1121 | #endif | 1167 | #endif |
1122 | 1168 | ||
1123 | static struct spi_device_id mcp251x_id_table[] = { | 1169 | static const struct spi_device_id mcp251x_id_table[] = { |
1124 | { "mcp251x", 0 /* Use pdata.model */ }, | ||
1125 | { "mcp2510", CAN_MCP251X_MCP2510 }, | 1170 | { "mcp2510", CAN_MCP251X_MCP2510 }, |
1126 | { "mcp2515", CAN_MCP251X_MCP2515 }, | 1171 | { "mcp2515", CAN_MCP251X_MCP2515 }, |
1127 | { }, | 1172 | { }, |
diff --git a/drivers/net/cxgb4vf/t4vf_common.h b/drivers/net/cxgb4vf/t4vf_common.h index 5c7bde7f9bae..873cb7d86c57 100644 --- a/drivers/net/cxgb4vf/t4vf_common.h +++ b/drivers/net/cxgb4vf/t4vf_common.h | |||
@@ -132,15 +132,15 @@ struct rss_params { | |||
132 | unsigned int mode; /* RSS mode */ | 132 | unsigned int mode; /* RSS mode */ |
133 | union { | 133 | union { |
134 | struct { | 134 | struct { |
135 | int synmapen:1; /* SYN Map Enable */ | 135 | unsigned int synmapen:1; /* SYN Map Enable */ |
136 | int syn4tupenipv6:1; /* enable hashing 4-tuple IPv6 SYNs */ | 136 | unsigned int syn4tupenipv6:1; /* enable hashing 4-tuple IPv6 SYNs */ |
137 | int syn2tupenipv6:1; /* enable hashing 2-tuple IPv6 SYNs */ | 137 | unsigned int syn2tupenipv6:1; /* enable hashing 2-tuple IPv6 SYNs */ |
138 | int syn4tupenipv4:1; /* enable hashing 4-tuple IPv4 SYNs */ | 138 | unsigned int syn4tupenipv4:1; /* enable hashing 4-tuple IPv4 SYNs */ |
139 | int syn2tupenipv4:1; /* enable hashing 2-tuple IPv4 SYNs */ | 139 | unsigned int syn2tupenipv4:1; /* enable hashing 2-tuple IPv4 SYNs */ |
140 | int ofdmapen:1; /* Offload Map Enable */ | 140 | unsigned int ofdmapen:1; /* Offload Map Enable */ |
141 | int tnlmapen:1; /* Tunnel Map Enable */ | 141 | unsigned int tnlmapen:1; /* Tunnel Map Enable */ |
142 | int tnlalllookup:1; /* Tunnel All Lookup */ | 142 | unsigned int tnlalllookup:1; /* Tunnel All Lookup */ |
143 | int hashtoeplitz:1; /* use Toeplitz hash */ | 143 | unsigned int hashtoeplitz:1; /* use Toeplitz hash */ |
144 | } basicvirtual; | 144 | } basicvirtual; |
145 | } u; | 145 | } u; |
146 | }; | 146 | }; |
@@ -151,10 +151,10 @@ struct rss_params { | |||
151 | union rss_vi_config { | 151 | union rss_vi_config { |
152 | struct { | 152 | struct { |
153 | u16 defaultq; /* Ingress Queue ID for !tnlalllookup */ | 153 | u16 defaultq; /* Ingress Queue ID for !tnlalllookup */ |
154 | int ip6fourtupen:1; /* hash 4-tuple IPv6 ingress packets */ | 154 | unsigned int ip6fourtupen:1; /* hash 4-tuple IPv6 ingress packets */ |
155 | int ip6twotupen:1; /* hash 2-tuple IPv6 ingress packets */ | 155 | unsigned int ip6twotupen:1; /* hash 2-tuple IPv6 ingress packets */ |
156 | int ip4fourtupen:1; /* hash 4-tuple IPv4 ingress packets */ | 156 | unsigned int ip4fourtupen:1; /* hash 4-tuple IPv4 ingress packets */ |
157 | int ip4twotupen:1; /* hash 2-tuple IPv4 ingress packets */ | 157 | unsigned int ip4twotupen:1; /* hash 2-tuple IPv4 ingress packets */ |
158 | int udpen; /* hash 4-tuple UDP ingress packets */ | 158 | int udpen; /* hash 4-tuple UDP ingress packets */ |
159 | } basicvirtual; | 159 | } basicvirtual; |
160 | }; | 160 | }; |
diff --git a/drivers/net/dnet.c b/drivers/net/dnet.c index 7c075756611a..9d8a20b72fa9 100644 --- a/drivers/net/dnet.c +++ b/drivers/net/dnet.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #undef DEBUG | 27 | #undef DEBUG |
28 | 28 | ||
29 | /* function for reading internal MAC register */ | 29 | /* function for reading internal MAC register */ |
30 | u16 dnet_readw_mac(struct dnet *bp, u16 reg) | 30 | static u16 dnet_readw_mac(struct dnet *bp, u16 reg) |
31 | { | 31 | { |
32 | u16 data_read; | 32 | u16 data_read; |
33 | 33 | ||
@@ -46,7 +46,7 @@ u16 dnet_readw_mac(struct dnet *bp, u16 reg) | |||
46 | } | 46 | } |
47 | 47 | ||
48 | /* function for writing internal MAC register */ | 48 | /* function for writing internal MAC register */ |
49 | void dnet_writew_mac(struct dnet *bp, u16 reg, u16 val) | 49 | static void dnet_writew_mac(struct dnet *bp, u16 reg, u16 val) |
50 | { | 50 | { |
51 | /* load data to write */ | 51 | /* load data to write */ |
52 | dnet_writel(bp, val, MACREG_DATA); | 52 | dnet_writel(bp, val, MACREG_DATA); |
@@ -63,11 +63,11 @@ static void __dnet_set_hwaddr(struct dnet *bp) | |||
63 | { | 63 | { |
64 | u16 tmp; | 64 | u16 tmp; |
65 | 65 | ||
66 | tmp = cpu_to_be16(*((u16 *) bp->dev->dev_addr)); | 66 | tmp = be16_to_cpup((__be16 *)bp->dev->dev_addr); |
67 | dnet_writew_mac(bp, DNET_INTERNAL_MAC_ADDR_0_REG, tmp); | 67 | dnet_writew_mac(bp, DNET_INTERNAL_MAC_ADDR_0_REG, tmp); |
68 | tmp = cpu_to_be16(*((u16 *) (bp->dev->dev_addr + 2))); | 68 | tmp = be16_to_cpup((__be16 *)(bp->dev->dev_addr + 2)); |
69 | dnet_writew_mac(bp, DNET_INTERNAL_MAC_ADDR_1_REG, tmp); | 69 | dnet_writew_mac(bp, DNET_INTERNAL_MAC_ADDR_1_REG, tmp); |
70 | tmp = cpu_to_be16(*((u16 *) (bp->dev->dev_addr + 4))); | 70 | tmp = be16_to_cpup((__be16 *)(bp->dev->dev_addr + 4)); |
71 | dnet_writew_mac(bp, DNET_INTERNAL_MAC_ADDR_2_REG, tmp); | 71 | dnet_writew_mac(bp, DNET_INTERNAL_MAC_ADDR_2_REG, tmp); |
72 | } | 72 | } |
73 | 73 | ||
@@ -89,11 +89,11 @@ static void __devinit dnet_get_hwaddr(struct dnet *bp) | |||
89 | * Mac_addr[15:0]). | 89 | * Mac_addr[15:0]). |
90 | */ | 90 | */ |
91 | tmp = dnet_readw_mac(bp, DNET_INTERNAL_MAC_ADDR_0_REG); | 91 | tmp = dnet_readw_mac(bp, DNET_INTERNAL_MAC_ADDR_0_REG); |
92 | *((u16 *) addr) = be16_to_cpu(tmp); | 92 | *((__be16 *)addr) = cpu_to_be16(tmp); |
93 | tmp = dnet_readw_mac(bp, DNET_INTERNAL_MAC_ADDR_1_REG); | 93 | tmp = dnet_readw_mac(bp, DNET_INTERNAL_MAC_ADDR_1_REG); |
94 | *((u16 *) (addr + 2)) = be16_to_cpu(tmp); | 94 | *((__be16 *)(addr + 2)) = cpu_to_be16(tmp); |
95 | tmp = dnet_readw_mac(bp, DNET_INTERNAL_MAC_ADDR_2_REG); | 95 | tmp = dnet_readw_mac(bp, DNET_INTERNAL_MAC_ADDR_2_REG); |
96 | *((u16 *) (addr + 4)) = be16_to_cpu(tmp); | 96 | *((__be16 *)(addr + 4)) = cpu_to_be16(tmp); |
97 | 97 | ||
98 | if (is_valid_ether_addr(addr)) | 98 | if (is_valid_ether_addr(addr)) |
99 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); | 99 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); |
@@ -361,7 +361,7 @@ err_out: | |||
361 | } | 361 | } |
362 | 362 | ||
363 | /* For Neptune board: LINK1000 as Link LED and TX as activity LED */ | 363 | /* For Neptune board: LINK1000 as Link LED and TX as activity LED */ |
364 | int dnet_phy_marvell_fixup(struct phy_device *phydev) | 364 | static int dnet_phy_marvell_fixup(struct phy_device *phydev) |
365 | { | 365 | { |
366 | return phy_write(phydev, 0x18, 0x4148); | 366 | return phy_write(phydev, 0x18, 0x4148); |
367 | } | 367 | } |
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index b7f15b3f0e03..8984d165a39b 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c | |||
@@ -1717,13 +1717,6 @@ static void e1000_diag_test(struct net_device *netdev, | |||
1717 | 1717 | ||
1718 | e_info("offline testing starting\n"); | 1718 | e_info("offline testing starting\n"); |
1719 | 1719 | ||
1720 | /* | ||
1721 | * Link test performed before hardware reset so autoneg doesn't | ||
1722 | * interfere with test result | ||
1723 | */ | ||
1724 | if (e1000_link_test(adapter, &data[4])) | ||
1725 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
1726 | |||
1727 | if (if_running) | 1720 | if (if_running) |
1728 | /* indicate we're in test mode */ | 1721 | /* indicate we're in test mode */ |
1729 | dev_close(netdev); | 1722 | dev_close(netdev); |
@@ -1747,15 +1740,19 @@ static void e1000_diag_test(struct net_device *netdev, | |||
1747 | if (e1000_loopback_test(adapter, &data[3])) | 1740 | if (e1000_loopback_test(adapter, &data[3])) |
1748 | eth_test->flags |= ETH_TEST_FL_FAILED; | 1741 | eth_test->flags |= ETH_TEST_FL_FAILED; |
1749 | 1742 | ||
1743 | /* force this routine to wait until autoneg complete/timeout */ | ||
1744 | adapter->hw.phy.autoneg_wait_to_complete = 1; | ||
1745 | e1000e_reset(adapter); | ||
1746 | adapter->hw.phy.autoneg_wait_to_complete = 0; | ||
1747 | |||
1748 | if (e1000_link_test(adapter, &data[4])) | ||
1749 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
1750 | |||
1750 | /* restore speed, duplex, autoneg settings */ | 1751 | /* restore speed, duplex, autoneg settings */ |
1751 | adapter->hw.phy.autoneg_advertised = autoneg_advertised; | 1752 | adapter->hw.phy.autoneg_advertised = autoneg_advertised; |
1752 | adapter->hw.mac.forced_speed_duplex = forced_speed_duplex; | 1753 | adapter->hw.mac.forced_speed_duplex = forced_speed_duplex; |
1753 | adapter->hw.mac.autoneg = autoneg; | 1754 | adapter->hw.mac.autoneg = autoneg; |
1754 | |||
1755 | /* force this routine to wait until autoneg complete/timeout */ | ||
1756 | adapter->hw.phy.autoneg_wait_to_complete = 1; | ||
1757 | e1000e_reset(adapter); | 1755 | e1000e_reset(adapter); |
1758 | adapter->hw.phy.autoneg_wait_to_complete = 0; | ||
1759 | 1756 | ||
1760 | clear_bit(__E1000_TESTING, &adapter->state); | 1757 | clear_bit(__E1000_TESTING, &adapter->state); |
1761 | if (if_running) | 1758 | if (if_running) |
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h index 44e0ff1494e0..edab9c442399 100644 --- a/drivers/net/igb/igb.h +++ b/drivers/net/igb/igb.h | |||
@@ -159,6 +159,7 @@ struct igb_tx_queue_stats { | |||
159 | u64 packets; | 159 | u64 packets; |
160 | u64 bytes; | 160 | u64 bytes; |
161 | u64 restart_queue; | 161 | u64 restart_queue; |
162 | u64 restart_queue2; | ||
162 | }; | 163 | }; |
163 | 164 | ||
164 | struct igb_rx_queue_stats { | 165 | struct igb_rx_queue_stats { |
@@ -210,11 +211,14 @@ struct igb_ring { | |||
210 | /* TX */ | 211 | /* TX */ |
211 | struct { | 212 | struct { |
212 | struct igb_tx_queue_stats tx_stats; | 213 | struct igb_tx_queue_stats tx_stats; |
214 | struct u64_stats_sync tx_syncp; | ||
215 | struct u64_stats_sync tx_syncp2; | ||
213 | bool detect_tx_hung; | 216 | bool detect_tx_hung; |
214 | }; | 217 | }; |
215 | /* RX */ | 218 | /* RX */ |
216 | struct { | 219 | struct { |
217 | struct igb_rx_queue_stats rx_stats; | 220 | struct igb_rx_queue_stats rx_stats; |
221 | struct u64_stats_sync rx_syncp; | ||
218 | u32 rx_buffer_len; | 222 | u32 rx_buffer_len; |
219 | }; | 223 | }; |
220 | }; | 224 | }; |
@@ -288,6 +292,9 @@ struct igb_adapter { | |||
288 | struct timecompare compare; | 292 | struct timecompare compare; |
289 | struct hwtstamp_config hwtstamp_config; | 293 | struct hwtstamp_config hwtstamp_config; |
290 | 294 | ||
295 | spinlock_t stats64_lock; | ||
296 | struct rtnl_link_stats64 stats64; | ||
297 | |||
291 | /* structs defined in e1000_hw.h */ | 298 | /* structs defined in e1000_hw.h */ |
292 | struct e1000_hw hw; | 299 | struct e1000_hw hw; |
293 | struct e1000_hw_stats stats; | 300 | struct e1000_hw_stats stats; |
@@ -357,7 +364,7 @@ extern netdev_tx_t igb_xmit_frame_ring_adv(struct sk_buff *, struct igb_ring *); | |||
357 | extern void igb_unmap_and_free_tx_resource(struct igb_ring *, | 364 | extern void igb_unmap_and_free_tx_resource(struct igb_ring *, |
358 | struct igb_buffer *); | 365 | struct igb_buffer *); |
359 | extern void igb_alloc_rx_buffers_adv(struct igb_ring *, int); | 366 | extern void igb_alloc_rx_buffers_adv(struct igb_ring *, int); |
360 | extern void igb_update_stats(struct igb_adapter *); | 367 | extern void igb_update_stats(struct igb_adapter *, struct rtnl_link_stats64 *); |
361 | extern bool igb_has_link(struct igb_adapter *adapter); | 368 | extern bool igb_has_link(struct igb_adapter *adapter); |
362 | extern void igb_set_ethtool_ops(struct net_device *); | 369 | extern void igb_set_ethtool_ops(struct net_device *); |
363 | extern void igb_power_up_link(struct igb_adapter *); | 370 | extern void igb_power_up_link(struct igb_adapter *); |
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index 26bf6a13d1c1..a70e16bcfa7e 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -90,8 +90,8 @@ static const struct igb_stats igb_gstrings_stats[] = { | |||
90 | 90 | ||
91 | #define IGB_NETDEV_STAT(_net_stat) { \ | 91 | #define IGB_NETDEV_STAT(_net_stat) { \ |
92 | .stat_string = __stringify(_net_stat), \ | 92 | .stat_string = __stringify(_net_stat), \ |
93 | .sizeof_stat = FIELD_SIZEOF(struct net_device_stats, _net_stat), \ | 93 | .sizeof_stat = FIELD_SIZEOF(struct rtnl_link_stats64, _net_stat), \ |
94 | .stat_offset = offsetof(struct net_device_stats, _net_stat) \ | 94 | .stat_offset = offsetof(struct rtnl_link_stats64, _net_stat) \ |
95 | } | 95 | } |
96 | static const struct igb_stats igb_gstrings_net_stats[] = { | 96 | static const struct igb_stats igb_gstrings_net_stats[] = { |
97 | IGB_NETDEV_STAT(rx_errors), | 97 | IGB_NETDEV_STAT(rx_errors), |
@@ -111,8 +111,9 @@ static const struct igb_stats igb_gstrings_net_stats[] = { | |||
111 | (sizeof(igb_gstrings_net_stats) / sizeof(struct igb_stats)) | 111 | (sizeof(igb_gstrings_net_stats) / sizeof(struct igb_stats)) |
112 | #define IGB_RX_QUEUE_STATS_LEN \ | 112 | #define IGB_RX_QUEUE_STATS_LEN \ |
113 | (sizeof(struct igb_rx_queue_stats) / sizeof(u64)) | 113 | (sizeof(struct igb_rx_queue_stats) / sizeof(u64)) |
114 | #define IGB_TX_QUEUE_STATS_LEN \ | 114 | |
115 | (sizeof(struct igb_tx_queue_stats) / sizeof(u64)) | 115 | #define IGB_TX_QUEUE_STATS_LEN 3 /* packets, bytes, restart_queue */ |
116 | |||
116 | #define IGB_QUEUE_STATS_LEN \ | 117 | #define IGB_QUEUE_STATS_LEN \ |
117 | ((((struct igb_adapter *)netdev_priv(netdev))->num_rx_queues * \ | 118 | ((((struct igb_adapter *)netdev_priv(netdev))->num_rx_queues * \ |
118 | IGB_RX_QUEUE_STATS_LEN) + \ | 119 | IGB_RX_QUEUE_STATS_LEN) + \ |
@@ -2070,12 +2071,14 @@ static void igb_get_ethtool_stats(struct net_device *netdev, | |||
2070 | struct ethtool_stats *stats, u64 *data) | 2071 | struct ethtool_stats *stats, u64 *data) |
2071 | { | 2072 | { |
2072 | struct igb_adapter *adapter = netdev_priv(netdev); | 2073 | struct igb_adapter *adapter = netdev_priv(netdev); |
2073 | struct net_device_stats *net_stats = &netdev->stats; | 2074 | struct rtnl_link_stats64 *net_stats = &adapter->stats64; |
2074 | u64 *queue_stat; | 2075 | unsigned int start; |
2075 | int i, j, k; | 2076 | struct igb_ring *ring; |
2077 | int i, j; | ||
2076 | char *p; | 2078 | char *p; |
2077 | 2079 | ||
2078 | igb_update_stats(adapter); | 2080 | spin_lock(&adapter->stats64_lock); |
2081 | igb_update_stats(adapter, net_stats); | ||
2079 | 2082 | ||
2080 | for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) { | 2083 | for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) { |
2081 | p = (char *)adapter + igb_gstrings_stats[i].stat_offset; | 2084 | p = (char *)adapter + igb_gstrings_stats[i].stat_offset; |
@@ -2088,15 +2091,36 @@ static void igb_get_ethtool_stats(struct net_device *netdev, | |||
2088 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; | 2091 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
2089 | } | 2092 | } |
2090 | for (j = 0; j < adapter->num_tx_queues; j++) { | 2093 | for (j = 0; j < adapter->num_tx_queues; j++) { |
2091 | queue_stat = (u64 *)&adapter->tx_ring[j]->tx_stats; | 2094 | u64 restart2; |
2092 | for (k = 0; k < IGB_TX_QUEUE_STATS_LEN; k++, i++) | 2095 | |
2093 | data[i] = queue_stat[k]; | 2096 | ring = adapter->tx_ring[j]; |
2097 | do { | ||
2098 | start = u64_stats_fetch_begin_bh(&ring->tx_syncp); | ||
2099 | data[i] = ring->tx_stats.packets; | ||
2100 | data[i+1] = ring->tx_stats.bytes; | ||
2101 | data[i+2] = ring->tx_stats.restart_queue; | ||
2102 | } while (u64_stats_fetch_retry_bh(&ring->tx_syncp, start)); | ||
2103 | do { | ||
2104 | start = u64_stats_fetch_begin_bh(&ring->tx_syncp2); | ||
2105 | restart2 = ring->tx_stats.restart_queue2; | ||
2106 | } while (u64_stats_fetch_retry_bh(&ring->tx_syncp2, start)); | ||
2107 | data[i+2] += restart2; | ||
2108 | |||
2109 | i += IGB_TX_QUEUE_STATS_LEN; | ||
2094 | } | 2110 | } |
2095 | for (j = 0; j < adapter->num_rx_queues; j++) { | 2111 | for (j = 0; j < adapter->num_rx_queues; j++) { |
2096 | queue_stat = (u64 *)&adapter->rx_ring[j]->rx_stats; | 2112 | ring = adapter->rx_ring[j]; |
2097 | for (k = 0; k < IGB_RX_QUEUE_STATS_LEN; k++, i++) | 2113 | do { |
2098 | data[i] = queue_stat[k]; | 2114 | start = u64_stats_fetch_begin_bh(&ring->rx_syncp); |
2115 | data[i] = ring->rx_stats.packets; | ||
2116 | data[i+1] = ring->rx_stats.bytes; | ||
2117 | data[i+2] = ring->rx_stats.drops; | ||
2118 | data[i+3] = ring->rx_stats.csum_err; | ||
2119 | data[i+4] = ring->rx_stats.alloc_failed; | ||
2120 | } while (u64_stats_fetch_retry_bh(&ring->rx_syncp, start)); | ||
2121 | i += IGB_RX_QUEUE_STATS_LEN; | ||
2099 | } | 2122 | } |
2123 | spin_unlock(&adapter->stats64_lock); | ||
2100 | } | 2124 | } |
2101 | 2125 | ||
2102 | static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data) | 2126 | static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data) |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 5b04eff2fd23..b8dccc0ac089 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -96,7 +96,6 @@ static int igb_setup_all_rx_resources(struct igb_adapter *); | |||
96 | static void igb_free_all_tx_resources(struct igb_adapter *); | 96 | static void igb_free_all_tx_resources(struct igb_adapter *); |
97 | static void igb_free_all_rx_resources(struct igb_adapter *); | 97 | static void igb_free_all_rx_resources(struct igb_adapter *); |
98 | static void igb_setup_mrqc(struct igb_adapter *); | 98 | static void igb_setup_mrqc(struct igb_adapter *); |
99 | void igb_update_stats(struct igb_adapter *); | ||
100 | static int igb_probe(struct pci_dev *, const struct pci_device_id *); | 99 | static int igb_probe(struct pci_dev *, const struct pci_device_id *); |
101 | static void __devexit igb_remove(struct pci_dev *pdev); | 100 | static void __devexit igb_remove(struct pci_dev *pdev); |
102 | static int igb_sw_init(struct igb_adapter *); | 101 | static int igb_sw_init(struct igb_adapter *); |
@@ -113,7 +112,8 @@ static void igb_update_phy_info(unsigned long); | |||
113 | static void igb_watchdog(unsigned long); | 112 | static void igb_watchdog(unsigned long); |
114 | static void igb_watchdog_task(struct work_struct *); | 113 | static void igb_watchdog_task(struct work_struct *); |
115 | static netdev_tx_t igb_xmit_frame_adv(struct sk_buff *skb, struct net_device *); | 114 | static netdev_tx_t igb_xmit_frame_adv(struct sk_buff *skb, struct net_device *); |
116 | static struct net_device_stats *igb_get_stats(struct net_device *); | 115 | static struct rtnl_link_stats64 *igb_get_stats64(struct net_device *dev, |
116 | struct rtnl_link_stats64 *stats); | ||
117 | static int igb_change_mtu(struct net_device *, int); | 117 | static int igb_change_mtu(struct net_device *, int); |
118 | static int igb_set_mac(struct net_device *, void *); | 118 | static int igb_set_mac(struct net_device *, void *); |
119 | static void igb_set_uta(struct igb_adapter *adapter); | 119 | static void igb_set_uta(struct igb_adapter *adapter); |
@@ -1536,7 +1536,9 @@ void igb_down(struct igb_adapter *adapter) | |||
1536 | netif_carrier_off(netdev); | 1536 | netif_carrier_off(netdev); |
1537 | 1537 | ||
1538 | /* record the stats before reset*/ | 1538 | /* record the stats before reset*/ |
1539 | igb_update_stats(adapter); | 1539 | spin_lock(&adapter->stats64_lock); |
1540 | igb_update_stats(adapter, &adapter->stats64); | ||
1541 | spin_unlock(&adapter->stats64_lock); | ||
1540 | 1542 | ||
1541 | adapter->link_speed = 0; | 1543 | adapter->link_speed = 0; |
1542 | adapter->link_duplex = 0; | 1544 | adapter->link_duplex = 0; |
@@ -1689,7 +1691,7 @@ static const struct net_device_ops igb_netdev_ops = { | |||
1689 | .ndo_open = igb_open, | 1691 | .ndo_open = igb_open, |
1690 | .ndo_stop = igb_close, | 1692 | .ndo_stop = igb_close, |
1691 | .ndo_start_xmit = igb_xmit_frame_adv, | 1693 | .ndo_start_xmit = igb_xmit_frame_adv, |
1692 | .ndo_get_stats = igb_get_stats, | 1694 | .ndo_get_stats64 = igb_get_stats64, |
1693 | .ndo_set_rx_mode = igb_set_rx_mode, | 1695 | .ndo_set_rx_mode = igb_set_rx_mode, |
1694 | .ndo_set_multicast_list = igb_set_rx_mode, | 1696 | .ndo_set_multicast_list = igb_set_rx_mode, |
1695 | .ndo_set_mac_address = igb_set_mac, | 1697 | .ndo_set_mac_address = igb_set_mac, |
@@ -2276,6 +2278,7 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter) | |||
2276 | adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; | 2278 | adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; |
2277 | adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; | 2279 | adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; |
2278 | 2280 | ||
2281 | spin_lock_init(&adapter->stats64_lock); | ||
2279 | #ifdef CONFIG_PCI_IOV | 2282 | #ifdef CONFIG_PCI_IOV |
2280 | if (hw->mac.type == e1000_82576) | 2283 | if (hw->mac.type == e1000_82576) |
2281 | adapter->vfs_allocated_count = (max_vfs > 7) ? 7 : max_vfs; | 2284 | adapter->vfs_allocated_count = (max_vfs > 7) ? 7 : max_vfs; |
@@ -3483,7 +3486,9 @@ static void igb_watchdog_task(struct work_struct *work) | |||
3483 | } | 3486 | } |
3484 | } | 3487 | } |
3485 | 3488 | ||
3486 | igb_update_stats(adapter); | 3489 | spin_lock(&adapter->stats64_lock); |
3490 | igb_update_stats(adapter, &adapter->stats64); | ||
3491 | spin_unlock(&adapter->stats64_lock); | ||
3487 | 3492 | ||
3488 | for (i = 0; i < adapter->num_tx_queues; i++) { | 3493 | for (i = 0; i < adapter->num_tx_queues; i++) { |
3489 | struct igb_ring *tx_ring = adapter->tx_ring[i]; | 3494 | struct igb_ring *tx_ring = adapter->tx_ring[i]; |
@@ -3550,6 +3555,8 @@ static void igb_update_ring_itr(struct igb_q_vector *q_vector) | |||
3550 | int new_val = q_vector->itr_val; | 3555 | int new_val = q_vector->itr_val; |
3551 | int avg_wire_size = 0; | 3556 | int avg_wire_size = 0; |
3552 | struct igb_adapter *adapter = q_vector->adapter; | 3557 | struct igb_adapter *adapter = q_vector->adapter; |
3558 | struct igb_ring *ring; | ||
3559 | unsigned int packets; | ||
3553 | 3560 | ||
3554 | /* For non-gigabit speeds, just fix the interrupt rate at 4000 | 3561 | /* For non-gigabit speeds, just fix the interrupt rate at 4000 |
3555 | * ints/sec - ITR timer value of 120 ticks. | 3562 | * ints/sec - ITR timer value of 120 ticks. |
@@ -3559,16 +3566,21 @@ static void igb_update_ring_itr(struct igb_q_vector *q_vector) | |||
3559 | goto set_itr_val; | 3566 | goto set_itr_val; |
3560 | } | 3567 | } |
3561 | 3568 | ||
3562 | if (q_vector->rx_ring && q_vector->rx_ring->total_packets) { | 3569 | ring = q_vector->rx_ring; |
3563 | struct igb_ring *ring = q_vector->rx_ring; | 3570 | if (ring) { |
3564 | avg_wire_size = ring->total_bytes / ring->total_packets; | 3571 | packets = ACCESS_ONCE(ring->total_packets); |
3572 | |||
3573 | if (packets) | ||
3574 | avg_wire_size = ring->total_bytes / packets; | ||
3565 | } | 3575 | } |
3566 | 3576 | ||
3567 | if (q_vector->tx_ring && q_vector->tx_ring->total_packets) { | 3577 | ring = q_vector->tx_ring; |
3568 | struct igb_ring *ring = q_vector->tx_ring; | 3578 | if (ring) { |
3569 | avg_wire_size = max_t(u32, avg_wire_size, | 3579 | packets = ACCESS_ONCE(ring->total_packets); |
3570 | (ring->total_bytes / | 3580 | |
3571 | ring->total_packets)); | 3581 | if (packets) |
3582 | avg_wire_size = max_t(u32, avg_wire_size, | ||
3583 | ring->total_bytes / packets); | ||
3572 | } | 3584 | } |
3573 | 3585 | ||
3574 | /* if avg_wire_size isn't set no work was done */ | 3586 | /* if avg_wire_size isn't set no work was done */ |
@@ -4077,7 +4089,11 @@ static int __igb_maybe_stop_tx(struct igb_ring *tx_ring, int size) | |||
4077 | 4089 | ||
4078 | /* A reprieve! */ | 4090 | /* A reprieve! */ |
4079 | netif_wake_subqueue(netdev, tx_ring->queue_index); | 4091 | netif_wake_subqueue(netdev, tx_ring->queue_index); |
4080 | tx_ring->tx_stats.restart_queue++; | 4092 | |
4093 | u64_stats_update_begin(&tx_ring->tx_syncp2); | ||
4094 | tx_ring->tx_stats.restart_queue2++; | ||
4095 | u64_stats_update_end(&tx_ring->tx_syncp2); | ||
4096 | |||
4081 | return 0; | 4097 | return 0; |
4082 | } | 4098 | } |
4083 | 4099 | ||
@@ -4214,16 +4230,22 @@ static void igb_reset_task(struct work_struct *work) | |||
4214 | } | 4230 | } |
4215 | 4231 | ||
4216 | /** | 4232 | /** |
4217 | * igb_get_stats - Get System Network Statistics | 4233 | * igb_get_stats64 - Get System Network Statistics |
4218 | * @netdev: network interface device structure | 4234 | * @netdev: network interface device structure |
4235 | * @stats: rtnl_link_stats64 pointer | ||
4219 | * | 4236 | * |
4220 | * Returns the address of the device statistics structure. | ||
4221 | * The statistics are actually updated from the timer callback. | ||
4222 | **/ | 4237 | **/ |
4223 | static struct net_device_stats *igb_get_stats(struct net_device *netdev) | 4238 | static struct rtnl_link_stats64 *igb_get_stats64(struct net_device *netdev, |
4239 | struct rtnl_link_stats64 *stats) | ||
4224 | { | 4240 | { |
4225 | /* only return the current stats */ | 4241 | struct igb_adapter *adapter = netdev_priv(netdev); |
4226 | return &netdev->stats; | 4242 | |
4243 | spin_lock(&adapter->stats64_lock); | ||
4244 | igb_update_stats(adapter, &adapter->stats64); | ||
4245 | memcpy(stats, &adapter->stats64, sizeof(*stats)); | ||
4246 | spin_unlock(&adapter->stats64_lock); | ||
4247 | |||
4248 | return stats; | ||
4227 | } | 4249 | } |
4228 | 4250 | ||
4229 | /** | 4251 | /** |
@@ -4305,15 +4327,17 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu) | |||
4305 | * @adapter: board private structure | 4327 | * @adapter: board private structure |
4306 | **/ | 4328 | **/ |
4307 | 4329 | ||
4308 | void igb_update_stats(struct igb_adapter *adapter) | 4330 | void igb_update_stats(struct igb_adapter *adapter, |
4331 | struct rtnl_link_stats64 *net_stats) | ||
4309 | { | 4332 | { |
4310 | struct net_device_stats *net_stats = igb_get_stats(adapter->netdev); | ||
4311 | struct e1000_hw *hw = &adapter->hw; | 4333 | struct e1000_hw *hw = &adapter->hw; |
4312 | struct pci_dev *pdev = adapter->pdev; | 4334 | struct pci_dev *pdev = adapter->pdev; |
4313 | u32 reg, mpc; | 4335 | u32 reg, mpc; |
4314 | u16 phy_tmp; | 4336 | u16 phy_tmp; |
4315 | int i; | 4337 | int i; |
4316 | u64 bytes, packets; | 4338 | u64 bytes, packets; |
4339 | unsigned int start; | ||
4340 | u64 _bytes, _packets; | ||
4317 | 4341 | ||
4318 | #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF | 4342 | #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF |
4319 | 4343 | ||
@@ -4331,10 +4355,17 @@ void igb_update_stats(struct igb_adapter *adapter) | |||
4331 | for (i = 0; i < adapter->num_rx_queues; i++) { | 4355 | for (i = 0; i < adapter->num_rx_queues; i++) { |
4332 | u32 rqdpc_tmp = rd32(E1000_RQDPC(i)) & 0x0FFF; | 4356 | u32 rqdpc_tmp = rd32(E1000_RQDPC(i)) & 0x0FFF; |
4333 | struct igb_ring *ring = adapter->rx_ring[i]; | 4357 | struct igb_ring *ring = adapter->rx_ring[i]; |
4358 | |||
4334 | ring->rx_stats.drops += rqdpc_tmp; | 4359 | ring->rx_stats.drops += rqdpc_tmp; |
4335 | net_stats->rx_fifo_errors += rqdpc_tmp; | 4360 | net_stats->rx_fifo_errors += rqdpc_tmp; |
4336 | bytes += ring->rx_stats.bytes; | 4361 | |
4337 | packets += ring->rx_stats.packets; | 4362 | do { |
4363 | start = u64_stats_fetch_begin_bh(&ring->rx_syncp); | ||
4364 | _bytes = ring->rx_stats.bytes; | ||
4365 | _packets = ring->rx_stats.packets; | ||
4366 | } while (u64_stats_fetch_retry_bh(&ring->rx_syncp, start)); | ||
4367 | bytes += _bytes; | ||
4368 | packets += _packets; | ||
4338 | } | 4369 | } |
4339 | 4370 | ||
4340 | net_stats->rx_bytes = bytes; | 4371 | net_stats->rx_bytes = bytes; |
@@ -4344,8 +4375,13 @@ void igb_update_stats(struct igb_adapter *adapter) | |||
4344 | packets = 0; | 4375 | packets = 0; |
4345 | for (i = 0; i < adapter->num_tx_queues; i++) { | 4376 | for (i = 0; i < adapter->num_tx_queues; i++) { |
4346 | struct igb_ring *ring = adapter->tx_ring[i]; | 4377 | struct igb_ring *ring = adapter->tx_ring[i]; |
4347 | bytes += ring->tx_stats.bytes; | 4378 | do { |
4348 | packets += ring->tx_stats.packets; | 4379 | start = u64_stats_fetch_begin_bh(&ring->tx_syncp); |
4380 | _bytes = ring->tx_stats.bytes; | ||
4381 | _packets = ring->tx_stats.packets; | ||
4382 | } while (u64_stats_fetch_retry_bh(&ring->tx_syncp, start)); | ||
4383 | bytes += _bytes; | ||
4384 | packets += _packets; | ||
4349 | } | 4385 | } |
4350 | net_stats->tx_bytes = bytes; | 4386 | net_stats->tx_bytes = bytes; |
4351 | net_stats->tx_packets = packets; | 4387 | net_stats->tx_packets = packets; |
@@ -5397,7 +5433,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) | |||
5397 | if (__netif_subqueue_stopped(netdev, tx_ring->queue_index) && | 5433 | if (__netif_subqueue_stopped(netdev, tx_ring->queue_index) && |
5398 | !(test_bit(__IGB_DOWN, &adapter->state))) { | 5434 | !(test_bit(__IGB_DOWN, &adapter->state))) { |
5399 | netif_wake_subqueue(netdev, tx_ring->queue_index); | 5435 | netif_wake_subqueue(netdev, tx_ring->queue_index); |
5436 | |||
5437 | u64_stats_update_begin(&tx_ring->tx_syncp); | ||
5400 | tx_ring->tx_stats.restart_queue++; | 5438 | tx_ring->tx_stats.restart_queue++; |
5439 | u64_stats_update_end(&tx_ring->tx_syncp); | ||
5401 | } | 5440 | } |
5402 | } | 5441 | } |
5403 | 5442 | ||
@@ -5437,8 +5476,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) | |||
5437 | } | 5476 | } |
5438 | tx_ring->total_bytes += total_bytes; | 5477 | tx_ring->total_bytes += total_bytes; |
5439 | tx_ring->total_packets += total_packets; | 5478 | tx_ring->total_packets += total_packets; |
5479 | u64_stats_update_begin(&tx_ring->tx_syncp); | ||
5440 | tx_ring->tx_stats.bytes += total_bytes; | 5480 | tx_ring->tx_stats.bytes += total_bytes; |
5441 | tx_ring->tx_stats.packets += total_packets; | 5481 | tx_ring->tx_stats.packets += total_packets; |
5482 | u64_stats_update_end(&tx_ring->tx_syncp); | ||
5442 | return count < tx_ring->count; | 5483 | return count < tx_ring->count; |
5443 | } | 5484 | } |
5444 | 5485 | ||
@@ -5480,9 +5521,11 @@ static inline void igb_rx_checksum_adv(struct igb_ring *ring, | |||
5480 | * packets, (aka let the stack check the crc32c) | 5521 | * packets, (aka let the stack check the crc32c) |
5481 | */ | 5522 | */ |
5482 | if ((skb->len == 60) && | 5523 | if ((skb->len == 60) && |
5483 | (ring->flags & IGB_RING_FLAG_RX_SCTP_CSUM)) | 5524 | (ring->flags & IGB_RING_FLAG_RX_SCTP_CSUM)) { |
5525 | u64_stats_update_begin(&ring->rx_syncp); | ||
5484 | ring->rx_stats.csum_err++; | 5526 | ring->rx_stats.csum_err++; |
5485 | 5527 | u64_stats_update_end(&ring->rx_syncp); | |
5528 | } | ||
5486 | /* let the stack verify checksum errors */ | 5529 | /* let the stack verify checksum errors */ |
5487 | return; | 5530 | return; |
5488 | } | 5531 | } |
@@ -5669,8 +5712,10 @@ next_desc: | |||
5669 | 5712 | ||
5670 | rx_ring->total_packets += total_packets; | 5713 | rx_ring->total_packets += total_packets; |
5671 | rx_ring->total_bytes += total_bytes; | 5714 | rx_ring->total_bytes += total_bytes; |
5715 | u64_stats_update_begin(&rx_ring->rx_syncp); | ||
5672 | rx_ring->rx_stats.packets += total_packets; | 5716 | rx_ring->rx_stats.packets += total_packets; |
5673 | rx_ring->rx_stats.bytes += total_bytes; | 5717 | rx_ring->rx_stats.bytes += total_bytes; |
5718 | u64_stats_update_end(&rx_ring->rx_syncp); | ||
5674 | return cleaned; | 5719 | return cleaned; |
5675 | } | 5720 | } |
5676 | 5721 | ||
@@ -5698,8 +5743,10 @@ void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring, int cleaned_count) | |||
5698 | if ((bufsz < IGB_RXBUFFER_1024) && !buffer_info->page_dma) { | 5743 | if ((bufsz < IGB_RXBUFFER_1024) && !buffer_info->page_dma) { |
5699 | if (!buffer_info->page) { | 5744 | if (!buffer_info->page) { |
5700 | buffer_info->page = netdev_alloc_page(netdev); | 5745 | buffer_info->page = netdev_alloc_page(netdev); |
5701 | if (!buffer_info->page) { | 5746 | if (unlikely(!buffer_info->page)) { |
5747 | u64_stats_update_begin(&rx_ring->rx_syncp); | ||
5702 | rx_ring->rx_stats.alloc_failed++; | 5748 | rx_ring->rx_stats.alloc_failed++; |
5749 | u64_stats_update_end(&rx_ring->rx_syncp); | ||
5703 | goto no_buffers; | 5750 | goto no_buffers; |
5704 | } | 5751 | } |
5705 | buffer_info->page_offset = 0; | 5752 | buffer_info->page_offset = 0; |
@@ -5714,7 +5761,9 @@ void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring, int cleaned_count) | |||
5714 | if (dma_mapping_error(rx_ring->dev, | 5761 | if (dma_mapping_error(rx_ring->dev, |
5715 | buffer_info->page_dma)) { | 5762 | buffer_info->page_dma)) { |
5716 | buffer_info->page_dma = 0; | 5763 | buffer_info->page_dma = 0; |
5764 | u64_stats_update_begin(&rx_ring->rx_syncp); | ||
5717 | rx_ring->rx_stats.alloc_failed++; | 5765 | rx_ring->rx_stats.alloc_failed++; |
5766 | u64_stats_update_end(&rx_ring->rx_syncp); | ||
5718 | goto no_buffers; | 5767 | goto no_buffers; |
5719 | } | 5768 | } |
5720 | } | 5769 | } |
@@ -5722,8 +5771,10 @@ void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring, int cleaned_count) | |||
5722 | skb = buffer_info->skb; | 5771 | skb = buffer_info->skb; |
5723 | if (!skb) { | 5772 | if (!skb) { |
5724 | skb = netdev_alloc_skb_ip_align(netdev, bufsz); | 5773 | skb = netdev_alloc_skb_ip_align(netdev, bufsz); |
5725 | if (!skb) { | 5774 | if (unlikely(!skb)) { |
5775 | u64_stats_update_begin(&rx_ring->rx_syncp); | ||
5726 | rx_ring->rx_stats.alloc_failed++; | 5776 | rx_ring->rx_stats.alloc_failed++; |
5777 | u64_stats_update_end(&rx_ring->rx_syncp); | ||
5727 | goto no_buffers; | 5778 | goto no_buffers; |
5728 | } | 5779 | } |
5729 | 5780 | ||
@@ -5737,7 +5788,9 @@ void igb_alloc_rx_buffers_adv(struct igb_ring *rx_ring, int cleaned_count) | |||
5737 | if (dma_mapping_error(rx_ring->dev, | 5788 | if (dma_mapping_error(rx_ring->dev, |
5738 | buffer_info->dma)) { | 5789 | buffer_info->dma)) { |
5739 | buffer_info->dma = 0; | 5790 | buffer_info->dma = 0; |
5791 | u64_stats_update_begin(&rx_ring->rx_syncp); | ||
5740 | rx_ring->rx_stats.alloc_failed++; | 5792 | rx_ring->rx_stats.alloc_failed++; |
5793 | u64_stats_update_end(&rx_ring->rx_syncp); | ||
5741 | goto no_buffers; | 5794 | goto no_buffers; |
5742 | } | 5795 | } |
5743 | } | 5796 | } |
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c index 265501348f33..6693323a6cf5 100644 --- a/drivers/net/igbvf/netdev.c +++ b/drivers/net/igbvf/netdev.c | |||
@@ -41,14 +41,12 @@ | |||
41 | #include <linux/mii.h> | 41 | #include <linux/mii.h> |
42 | #include <linux/ethtool.h> | 42 | #include <linux/ethtool.h> |
43 | #include <linux/if_vlan.h> | 43 | #include <linux/if_vlan.h> |
44 | #include <linux/pm_qos_params.h> | ||
45 | 44 | ||
46 | #include "igbvf.h" | 45 | #include "igbvf.h" |
47 | 46 | ||
48 | #define DRV_VERSION "1.0.0-k0" | 47 | #define DRV_VERSION "1.0.0-k0" |
49 | char igbvf_driver_name[] = "igbvf"; | 48 | char igbvf_driver_name[] = "igbvf"; |
50 | const char igbvf_driver_version[] = DRV_VERSION; | 49 | const char igbvf_driver_version[] = DRV_VERSION; |
51 | static struct pm_qos_request_list igbvf_driver_pm_qos_req; | ||
52 | static const char igbvf_driver_string[] = | 50 | static const char igbvf_driver_string[] = |
53 | "Intel(R) Virtual Function Network Driver"; | 51 | "Intel(R) Virtual Function Network Driver"; |
54 | static const char igbvf_copyright[] = "Copyright (c) 2009 Intel Corporation."; | 52 | static const char igbvf_copyright[] = "Copyright (c) 2009 Intel Corporation."; |
@@ -2904,8 +2902,6 @@ static int __init igbvf_init_module(void) | |||
2904 | printk(KERN_INFO "%s\n", igbvf_copyright); | 2902 | printk(KERN_INFO "%s\n", igbvf_copyright); |
2905 | 2903 | ||
2906 | ret = pci_register_driver(&igbvf_driver); | 2904 | ret = pci_register_driver(&igbvf_driver); |
2907 | pm_qos_add_request(&igbvf_driver_pm_qos_req, PM_QOS_CPU_DMA_LATENCY, | ||
2908 | PM_QOS_DEFAULT_VALUE); | ||
2909 | 2905 | ||
2910 | return ret; | 2906 | return ret; |
2911 | } | 2907 | } |
@@ -2920,7 +2916,6 @@ module_init(igbvf_init_module); | |||
2920 | static void __exit igbvf_exit_module(void) | 2916 | static void __exit igbvf_exit_module(void) |
2921 | { | 2917 | { |
2922 | pci_unregister_driver(&igbvf_driver); | 2918 | pci_unregister_driver(&igbvf_driver); |
2923 | pm_qos_remove_request(&igbvf_driver_pm_qos_req); | ||
2924 | } | 2919 | } |
2925 | module_exit(igbvf_exit_module); | 2920 | module_exit(igbvf_exit_module); |
2926 | 2921 | ||
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index ca142c47b2e4..94255f09093d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c | |||
@@ -678,7 +678,14 @@ static int netconsole_netdev_event(struct notifier_block *this, | |||
678 | strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); | 678 | strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ); |
679 | break; | 679 | break; |
680 | case NETDEV_UNREGISTER: | 680 | case NETDEV_UNREGISTER: |
681 | netpoll_cleanup(&nt->np); | 681 | /* |
682 | * rtnl_lock already held | ||
683 | */ | ||
684 | if (nt->np.dev) { | ||
685 | __netpoll_cleanup(&nt->np); | ||
686 | dev_put(nt->np.dev); | ||
687 | nt->np.dev = NULL; | ||
688 | } | ||
682 | /* Fall through */ | 689 | /* Fall through */ |
683 | case NETDEV_GOING_DOWN: | 690 | case NETDEV_GOING_DOWN: |
684 | case NETDEV_BONDING_DESLAVE: | 691 | case NETDEV_BONDING_DESLAVE: |
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 6dca3574e355..92f89af0720e 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -175,7 +175,10 @@ | |||
175 | #define MAX_NUM_CARDS 4 | 175 | #define MAX_NUM_CARDS 4 |
176 | 176 | ||
177 | #define MAX_BUFFERS_PER_CMD 32 | 177 | #define MAX_BUFFERS_PER_CMD 32 |
178 | #define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + 4) | 178 | #define MAX_TSO_HEADER_DESC 2 |
179 | #define MGMT_CMD_DESC_RESV 4 | ||
180 | #define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ | ||
181 | + MGMT_CMD_DESC_RESV) | ||
179 | #define NX_MAX_TX_TIMEOUTS 2 | 182 | #define NX_MAX_TX_TIMEOUTS 2 |
180 | 183 | ||
181 | /* | 184 | /* |
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 29d7b93d0493..4b4ac7106786 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -598,8 +598,14 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter, | |||
598 | 598 | ||
599 | if (nr_desc >= netxen_tx_avail(tx_ring)) { | 599 | if (nr_desc >= netxen_tx_avail(tx_ring)) { |
600 | netif_tx_stop_queue(tx_ring->txq); | 600 | netif_tx_stop_queue(tx_ring->txq); |
601 | __netif_tx_unlock_bh(tx_ring->txq); | 601 | smp_mb(); |
602 | return -EBUSY; | 602 | if (netxen_tx_avail(tx_ring) > nr_desc) { |
603 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) | ||
604 | netif_tx_wake_queue(tx_ring->txq); | ||
605 | } else { | ||
606 | __netif_tx_unlock_bh(tx_ring->txq); | ||
607 | return -EBUSY; | ||
608 | } | ||
603 | } | 609 | } |
604 | 610 | ||
605 | do { | 611 | do { |
@@ -1816,14 +1822,14 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter) | |||
1816 | if (netxen_rom_fast_read(adapter, offset, &board_type)) | 1822 | if (netxen_rom_fast_read(adapter, offset, &board_type)) |
1817 | return -EIO; | 1823 | return -EIO; |
1818 | 1824 | ||
1819 | adapter->ahw.board_type = board_type; | ||
1820 | |||
1821 | if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) { | 1825 | if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) { |
1822 | u32 gpio = NXRD32(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I); | 1826 | u32 gpio = NXRD32(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I); |
1823 | if ((gpio & 0x8000) == 0) | 1827 | if ((gpio & 0x8000) == 0) |
1824 | board_type = NETXEN_BRDTYPE_P3_10G_TP; | 1828 | board_type = NETXEN_BRDTYPE_P3_10G_TP; |
1825 | } | 1829 | } |
1826 | 1830 | ||
1831 | adapter->ahw.board_type = board_type; | ||
1832 | |||
1827 | switch (board_type) { | 1833 | switch (board_type) { |
1828 | case NETXEN_BRDTYPE_P2_SB35_4G: | 1834 | case NETXEN_BRDTYPE_P2_SB35_4G: |
1829 | adapter->ahw.port_type = NETXEN_NIC_GBE; | 1835 | adapter->ahw.port_type = NETXEN_NIC_GBE; |
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index a2d805aa75cd..95fe552aa279 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -1763,14 +1763,10 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) | |||
1763 | 1763 | ||
1764 | smp_mb(); | 1764 | smp_mb(); |
1765 | 1765 | ||
1766 | if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) { | 1766 | if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) |
1767 | __netif_tx_lock(tx_ring->txq, smp_processor_id()); | 1767 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) |
1768 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) { | ||
1769 | netif_wake_queue(netdev); | 1768 | netif_wake_queue(netdev); |
1770 | adapter->tx_timeo_cnt = 0; | 1769 | adapter->tx_timeo_cnt = 0; |
1771 | } | ||
1772 | __netif_tx_unlock(tx_ring->txq); | ||
1773 | } | ||
1774 | } | 1770 | } |
1775 | /* | 1771 | /* |
1776 | * If everything is freed up to consumer then check if the ring is full | 1772 | * If everything is freed up to consumer then check if the ring is full |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 2c6ceeb592b3..6f111691aca4 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -125,11 +125,6 @@ netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, | |||
125 | struct nx_host_tx_ring *tx_ring) | 125 | struct nx_host_tx_ring *tx_ring) |
126 | { | 126 | { |
127 | NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer); | 127 | NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer); |
128 | |||
129 | if (netxen_tx_avail(tx_ring) <= TX_STOP_THRESH) { | ||
130 | netif_stop_queue(adapter->netdev); | ||
131 | smp_mb(); | ||
132 | } | ||
133 | } | 128 | } |
134 | 129 | ||
135 | static uint32_t crb_cmd_consumer[4] = { | 130 | static uint32_t crb_cmd_consumer[4] = { |
@@ -1209,7 +1204,7 @@ netxen_setup_netdev(struct netxen_adapter *adapter, | |||
1209 | adapter->max_mc_count = 16; | 1204 | adapter->max_mc_count = 16; |
1210 | 1205 | ||
1211 | netdev->netdev_ops = &netxen_netdev_ops; | 1206 | netdev->netdev_ops = &netxen_netdev_ops; |
1212 | netdev->watchdog_timeo = 2*HZ; | 1207 | netdev->watchdog_timeo = 5*HZ; |
1213 | 1208 | ||
1214 | netxen_nic_change_mtu(netdev, netdev->mtu); | 1209 | netxen_nic_change_mtu(netdev, netdev->mtu); |
1215 | 1210 | ||
@@ -1254,6 +1249,28 @@ netxen_setup_netdev(struct netxen_adapter *adapter, | |||
1254 | return 0; | 1249 | return 0; |
1255 | } | 1250 | } |
1256 | 1251 | ||
1252 | #ifdef CONFIG_PCIEAER | ||
1253 | static void netxen_mask_aer_correctable(struct netxen_adapter *adapter) | ||
1254 | { | ||
1255 | struct pci_dev *pdev = adapter->pdev; | ||
1256 | struct pci_dev *root = pdev->bus->self; | ||
1257 | u32 aer_pos; | ||
1258 | |||
1259 | if (adapter->ahw.board_type != NETXEN_BRDTYPE_P3_4_GB_MM && | ||
1260 | adapter->ahw.board_type != NETXEN_BRDTYPE_P3_10G_TP) | ||
1261 | return; | ||
1262 | |||
1263 | if (root->pcie_type != PCI_EXP_TYPE_ROOT_PORT) | ||
1264 | return; | ||
1265 | |||
1266 | aer_pos = pci_find_ext_capability(root, PCI_EXT_CAP_ID_ERR); | ||
1267 | if (!aer_pos) | ||
1268 | return; | ||
1269 | |||
1270 | pci_write_config_dword(root, aer_pos + PCI_ERR_COR_MASK, 0xffff); | ||
1271 | } | ||
1272 | #endif | ||
1273 | |||
1257 | static int __devinit | 1274 | static int __devinit |
1258 | netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 1275 | netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
1259 | { | 1276 | { |
@@ -1322,6 +1339,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1322 | goto err_out_iounmap; | 1339 | goto err_out_iounmap; |
1323 | } | 1340 | } |
1324 | 1341 | ||
1342 | #ifdef CONFIG_PCIEAER | ||
1343 | netxen_mask_aer_correctable(adapter); | ||
1344 | #endif | ||
1345 | |||
1325 | /* Mezz cards have PCI function 0,2,3 enabled */ | 1346 | /* Mezz cards have PCI function 0,2,3 enabled */ |
1326 | switch (adapter->ahw.board_type) { | 1347 | switch (adapter->ahw.board_type) { |
1327 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: | 1348 | case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: |
@@ -1825,9 +1846,13 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1825 | /* 4 fragments per cmd des */ | 1846 | /* 4 fragments per cmd des */ |
1826 | no_of_desc = (frag_count + 3) >> 2; | 1847 | no_of_desc = (frag_count + 3) >> 2; |
1827 | 1848 | ||
1828 | if (unlikely(no_of_desc + 2 > netxen_tx_avail(tx_ring))) { | 1849 | if (unlikely(netxen_tx_avail(tx_ring) <= TX_STOP_THRESH)) { |
1829 | netif_stop_queue(netdev); | 1850 | netif_stop_queue(netdev); |
1830 | return NETDEV_TX_BUSY; | 1851 | smp_mb(); |
1852 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) | ||
1853 | netif_start_queue(netdev); | ||
1854 | else | ||
1855 | return NETDEV_TX_BUSY; | ||
1831 | } | 1856 | } |
1832 | 1857 | ||
1833 | producer = tx_ring->producer; | 1858 | producer = tx_ring->producer; |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index c0437fd8d3f2..781e368329f9 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -7090,24 +7090,20 @@ static int niu_get_hash_opts(struct niu *np, struct ethtool_rxnfc *nfc) | |||
7090 | static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp, | 7090 | static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp, |
7091 | struct ethtool_rx_flow_spec *fsp) | 7091 | struct ethtool_rx_flow_spec *fsp) |
7092 | { | 7092 | { |
7093 | u32 tmp; | ||
7094 | u16 prt; | ||
7093 | 7095 | ||
7094 | fsp->h_u.tcp_ip4_spec.ip4src = (tp->key[3] & TCAM_V4KEY3_SADDR) >> | 7096 | tmp = (tp->key[3] & TCAM_V4KEY3_SADDR) >> TCAM_V4KEY3_SADDR_SHIFT; |
7095 | TCAM_V4KEY3_SADDR_SHIFT; | 7097 | fsp->h_u.tcp_ip4_spec.ip4src = cpu_to_be32(tmp); |
7096 | fsp->h_u.tcp_ip4_spec.ip4dst = (tp->key[3] & TCAM_V4KEY3_DADDR) >> | 7098 | |
7097 | TCAM_V4KEY3_DADDR_SHIFT; | 7099 | tmp = (tp->key[3] & TCAM_V4KEY3_DADDR) >> TCAM_V4KEY3_DADDR_SHIFT; |
7098 | fsp->m_u.tcp_ip4_spec.ip4src = (tp->key_mask[3] & TCAM_V4KEY3_SADDR) >> | 7100 | fsp->h_u.tcp_ip4_spec.ip4dst = cpu_to_be32(tmp); |
7099 | TCAM_V4KEY3_SADDR_SHIFT; | 7101 | |
7100 | fsp->m_u.tcp_ip4_spec.ip4dst = (tp->key_mask[3] & TCAM_V4KEY3_DADDR) >> | 7102 | tmp = (tp->key_mask[3] & TCAM_V4KEY3_SADDR) >> TCAM_V4KEY3_SADDR_SHIFT; |
7101 | TCAM_V4KEY3_DADDR_SHIFT; | 7103 | fsp->m_u.tcp_ip4_spec.ip4src = cpu_to_be32(tmp); |
7102 | 7104 | ||
7103 | fsp->h_u.tcp_ip4_spec.ip4src = | 7105 | tmp = (tp->key_mask[3] & TCAM_V4KEY3_DADDR) >> TCAM_V4KEY3_DADDR_SHIFT; |
7104 | cpu_to_be32(fsp->h_u.tcp_ip4_spec.ip4src); | 7106 | fsp->m_u.tcp_ip4_spec.ip4dst = cpu_to_be32(tmp); |
7105 | fsp->m_u.tcp_ip4_spec.ip4src = | ||
7106 | cpu_to_be32(fsp->m_u.tcp_ip4_spec.ip4src); | ||
7107 | fsp->h_u.tcp_ip4_spec.ip4dst = | ||
7108 | cpu_to_be32(fsp->h_u.tcp_ip4_spec.ip4dst); | ||
7109 | fsp->m_u.tcp_ip4_spec.ip4dst = | ||
7110 | cpu_to_be32(fsp->m_u.tcp_ip4_spec.ip4dst); | ||
7111 | 7107 | ||
7112 | fsp->h_u.tcp_ip4_spec.tos = (tp->key[2] & TCAM_V4KEY2_TOS) >> | 7108 | fsp->h_u.tcp_ip4_spec.tos = (tp->key[2] & TCAM_V4KEY2_TOS) >> |
7113 | TCAM_V4KEY2_TOS_SHIFT; | 7109 | TCAM_V4KEY2_TOS_SHIFT; |
@@ -7118,54 +7114,40 @@ static void niu_get_ip4fs_from_tcam_key(struct niu_tcam_entry *tp, | |||
7118 | case TCP_V4_FLOW: | 7114 | case TCP_V4_FLOW: |
7119 | case UDP_V4_FLOW: | 7115 | case UDP_V4_FLOW: |
7120 | case SCTP_V4_FLOW: | 7116 | case SCTP_V4_FLOW: |
7121 | fsp->h_u.tcp_ip4_spec.psrc = | 7117 | prt = ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7122 | ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | 7118 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; |
7123 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; | 7119 | fsp->h_u.tcp_ip4_spec.psrc = cpu_to_be16(prt); |
7124 | fsp->h_u.tcp_ip4_spec.pdst = | 7120 | |
7125 | ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | 7121 | prt = ((tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7126 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; | 7122 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; |
7127 | fsp->m_u.tcp_ip4_spec.psrc = | 7123 | fsp->h_u.tcp_ip4_spec.pdst = cpu_to_be16(prt); |
7128 | ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7129 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; | ||
7130 | fsp->m_u.tcp_ip4_spec.pdst = | ||
7131 | ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7132 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; | ||
7133 | 7124 | ||
7134 | fsp->h_u.tcp_ip4_spec.psrc = | 7125 | prt = ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7135 | cpu_to_be16(fsp->h_u.tcp_ip4_spec.psrc); | 7126 | TCAM_V4KEY2_PORT_SPI_SHIFT) >> 16; |
7136 | fsp->h_u.tcp_ip4_spec.pdst = | 7127 | fsp->m_u.tcp_ip4_spec.psrc = cpu_to_be16(prt); |
7137 | cpu_to_be16(fsp->h_u.tcp_ip4_spec.pdst); | 7128 | |
7138 | fsp->m_u.tcp_ip4_spec.psrc = | 7129 | prt = ((tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7139 | cpu_to_be16(fsp->m_u.tcp_ip4_spec.psrc); | 7130 | TCAM_V4KEY2_PORT_SPI_SHIFT) & 0xffff; |
7140 | fsp->m_u.tcp_ip4_spec.pdst = | 7131 | fsp->m_u.tcp_ip4_spec.pdst = cpu_to_be16(prt); |
7141 | cpu_to_be16(fsp->m_u.tcp_ip4_spec.pdst); | ||
7142 | break; | 7132 | break; |
7143 | case AH_V4_FLOW: | 7133 | case AH_V4_FLOW: |
7144 | case ESP_V4_FLOW: | 7134 | case ESP_V4_FLOW: |
7145 | fsp->h_u.ah_ip4_spec.spi = | 7135 | tmp = (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7146 | (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7147 | TCAM_V4KEY2_PORT_SPI_SHIFT; | ||
7148 | fsp->m_u.ah_ip4_spec.spi = | ||
7149 | (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7150 | TCAM_V4KEY2_PORT_SPI_SHIFT; | 7136 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7137 | fsp->h_u.ah_ip4_spec.spi = cpu_to_be32(tmp); | ||
7151 | 7138 | ||
7152 | fsp->h_u.ah_ip4_spec.spi = | 7139 | tmp = (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7153 | cpu_to_be32(fsp->h_u.ah_ip4_spec.spi); | 7140 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7154 | fsp->m_u.ah_ip4_spec.spi = | 7141 | fsp->m_u.ah_ip4_spec.spi = cpu_to_be32(tmp); |
7155 | cpu_to_be32(fsp->m_u.ah_ip4_spec.spi); | ||
7156 | break; | 7142 | break; |
7157 | case IP_USER_FLOW: | 7143 | case IP_USER_FLOW: |
7158 | fsp->h_u.usr_ip4_spec.l4_4_bytes = | 7144 | tmp = (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> |
7159 | (tp->key[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7160 | TCAM_V4KEY2_PORT_SPI_SHIFT; | ||
7161 | fsp->m_u.usr_ip4_spec.l4_4_bytes = | ||
7162 | (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> | ||
7163 | TCAM_V4KEY2_PORT_SPI_SHIFT; | 7145 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7146 | fsp->h_u.usr_ip4_spec.l4_4_bytes = cpu_to_be32(tmp); | ||
7164 | 7147 | ||
7165 | fsp->h_u.usr_ip4_spec.l4_4_bytes = | 7148 | tmp = (tp->key_mask[2] & TCAM_V4KEY2_PORT_SPI) >> |
7166 | cpu_to_be32(fsp->h_u.usr_ip4_spec.l4_4_bytes); | 7149 | TCAM_V4KEY2_PORT_SPI_SHIFT; |
7167 | fsp->m_u.usr_ip4_spec.l4_4_bytes = | 7150 | fsp->m_u.usr_ip4_spec.l4_4_bytes = cpu_to_be32(tmp); |
7168 | cpu_to_be32(fsp->m_u.usr_ip4_spec.l4_4_bytes); | ||
7169 | 7151 | ||
7170 | fsp->h_u.usr_ip4_spec.proto = | 7152 | fsp->h_u.usr_ip4_spec.proto = |
7171 | (tp->key[2] & TCAM_V4KEY2_PROTO) >> | 7153 | (tp->key[2] & TCAM_V4KEY2_PROTO) >> |
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c index 3bbd0aab17e8..84134c766f3a 100644 --- a/drivers/net/ns83820.c +++ b/drivers/net/ns83820.c | |||
@@ -772,7 +772,7 @@ static int ns83820_setup_rx(struct net_device *ndev) | |||
772 | phy_intr(ndev); | 772 | phy_intr(ndev); |
773 | 773 | ||
774 | /* Okay, let it rip */ | 774 | /* Okay, let it rip */ |
775 | spin_lock_irq(&dev->misc_lock); | 775 | spin_lock(&dev->misc_lock); |
776 | dev->IMR_cache |= ISR_PHY; | 776 | dev->IMR_cache |= ISR_PHY; |
777 | dev->IMR_cache |= ISR_RXRCMP; | 777 | dev->IMR_cache |= ISR_RXRCMP; |
778 | //dev->IMR_cache |= ISR_RXERR; | 778 | //dev->IMR_cache |= ISR_RXERR; |
diff --git a/drivers/net/pch_gbe/pch_gbe_ethtool.c b/drivers/net/pch_gbe/pch_gbe_ethtool.c index e06c6aea4527..c8cc32c0edc9 100644 --- a/drivers/net/pch_gbe/pch_gbe_ethtool.c +++ b/drivers/net/pch_gbe/pch_gbe_ethtool.c | |||
@@ -113,9 +113,10 @@ static int pch_gbe_set_settings(struct net_device *netdev, | |||
113 | 113 | ||
114 | pch_gbe_hal_write_phy_reg(hw, MII_BMCR, BMCR_RESET); | 114 | pch_gbe_hal_write_phy_reg(hw, MII_BMCR, BMCR_RESET); |
115 | 115 | ||
116 | if (ecmd->speed == -1) | 116 | if (ecmd->speed == USHRT_MAX) { |
117 | ecmd->speed = SPEED_1000; | 117 | ecmd->speed = SPEED_1000; |
118 | ecmd->duplex = DUPLEX_FULL; | 118 | ecmd->duplex = DUPLEX_FULL; |
119 | } | ||
119 | ret = mii_ethtool_sset(&adapter->mii, ecmd); | 120 | ret = mii_ethtool_sset(&adapter->mii, ecmd); |
120 | if (ret) { | 121 | if (ret) { |
121 | pr_err("Error: mii_ethtool_sset\n"); | 122 | pr_err("Error: mii_ethtool_sset\n"); |
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c index e44644f169fd..cf4b49d6c6da 100644 --- a/drivers/net/pch_gbe/pch_gbe_main.c +++ b/drivers/net/pch_gbe/pch_gbe_main.c | |||
@@ -2394,7 +2394,7 @@ err_disable_device: | |||
2394 | return ret; | 2394 | return ret; |
2395 | } | 2395 | } |
2396 | 2396 | ||
2397 | static const struct pci_device_id pch_gbe_pcidev_id[] = { | 2397 | static DEFINE_PCI_DEVICE_TABLE(pch_gbe_pcidev_id) = { |
2398 | {.vendor = PCI_VENDOR_ID_INTEL, | 2398 | {.vendor = PCI_VENDOR_ID_INTEL, |
2399 | .device = PCI_DEVICE_ID_INTEL_IOH1_GBE, | 2399 | .device = PCI_DEVICE_ID_INTEL_IOH1_GBE, |
2400 | .subvendor = PCI_ANY_ID, | 2400 | .subvendor = PCI_ANY_ID, |
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c index 2568aa665024..25e93a53fca0 100644 --- a/drivers/net/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/qlcnic/qlcnic_ethtool.c | |||
@@ -78,7 +78,25 @@ static const struct qlcnic_stats qlcnic_gstrings_stats[] = { | |||
78 | 78 | ||
79 | }; | 79 | }; |
80 | 80 | ||
81 | static const char qlcnic_device_gstrings_stats[][ETH_GSTRING_LEN] = { | ||
82 | "rx unicast frames", | ||
83 | "rx multicast frames", | ||
84 | "rx broadcast frames", | ||
85 | "rx dropped frames", | ||
86 | "rx errors", | ||
87 | "rx local frames", | ||
88 | "rx numbytes", | ||
89 | "tx unicast frames", | ||
90 | "tx multicast frames", | ||
91 | "tx broadcast frames", | ||
92 | "tx dropped frames", | ||
93 | "tx errors", | ||
94 | "tx local frames", | ||
95 | "tx numbytes", | ||
96 | }; | ||
97 | |||
81 | #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) | 98 | #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) |
99 | #define QLCNIC_DEVICE_STATS_LEN ARRAY_SIZE(qlcnic_device_gstrings_stats) | ||
82 | 100 | ||
83 | static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { | 101 | static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { |
84 | "Register_Test_on_offline", | 102 | "Register_Test_on_offline", |
@@ -625,10 +643,13 @@ static int qlcnic_reg_test(struct net_device *dev) | |||
625 | 643 | ||
626 | static int qlcnic_get_sset_count(struct net_device *dev, int sset) | 644 | static int qlcnic_get_sset_count(struct net_device *dev, int sset) |
627 | { | 645 | { |
646 | struct qlcnic_adapter *adapter = netdev_priv(dev); | ||
628 | switch (sset) { | 647 | switch (sset) { |
629 | case ETH_SS_TEST: | 648 | case ETH_SS_TEST: |
630 | return QLCNIC_TEST_LEN; | 649 | return QLCNIC_TEST_LEN; |
631 | case ETH_SS_STATS: | 650 | case ETH_SS_STATS: |
651 | if (adapter->flags & QLCNIC_ESWITCH_ENABLED) | ||
652 | return QLCNIC_STATS_LEN + QLCNIC_DEVICE_STATS_LEN; | ||
632 | return QLCNIC_STATS_LEN; | 653 | return QLCNIC_STATS_LEN; |
633 | default: | 654 | default: |
634 | return -EOPNOTSUPP; | 655 | return -EOPNOTSUPP; |
@@ -795,7 +816,8 @@ qlcnic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, | |||
795 | static void | 816 | static void |
796 | qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | 817 | qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) |
797 | { | 818 | { |
798 | int index; | 819 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
820 | int index, i; | ||
799 | 821 | ||
800 | switch (stringset) { | 822 | switch (stringset) { |
801 | case ETH_SS_TEST: | 823 | case ETH_SS_TEST: |
@@ -808,16 +830,43 @@ qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | |||
808 | qlcnic_gstrings_stats[index].stat_string, | 830 | qlcnic_gstrings_stats[index].stat_string, |
809 | ETH_GSTRING_LEN); | 831 | ETH_GSTRING_LEN); |
810 | } | 832 | } |
811 | break; | 833 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) |
834 | return; | ||
835 | for (i = 0; i < QLCNIC_DEVICE_STATS_LEN; index++, i++) { | ||
836 | memcpy(data + index * ETH_GSTRING_LEN, | ||
837 | qlcnic_device_gstrings_stats[i], | ||
838 | ETH_GSTRING_LEN); | ||
839 | } | ||
812 | } | 840 | } |
813 | } | 841 | } |
814 | 842 | ||
843 | #define QLCNIC_FILL_ESWITCH_STATS(VAL1) \ | ||
844 | (((VAL1) == QLCNIC_ESW_STATS_NOT_AVAIL) ? 0 : VAL1) | ||
845 | |||
846 | static void | ||
847 | qlcnic_fill_device_stats(int *index, u64 *data, | ||
848 | struct __qlcnic_esw_statistics *stats) | ||
849 | { | ||
850 | int ind = *index; | ||
851 | |||
852 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->unicast_frames); | ||
853 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->multicast_frames); | ||
854 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->broadcast_frames); | ||
855 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->dropped_frames); | ||
856 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->errors); | ||
857 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->local_frames); | ||
858 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->numbytes); | ||
859 | |||
860 | *index = ind; | ||
861 | } | ||
862 | |||
815 | static void | 863 | static void |
816 | qlcnic_get_ethtool_stats(struct net_device *dev, | 864 | qlcnic_get_ethtool_stats(struct net_device *dev, |
817 | struct ethtool_stats *stats, u64 * data) | 865 | struct ethtool_stats *stats, u64 * data) |
818 | { | 866 | { |
819 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 867 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
820 | int index; | 868 | struct qlcnic_esw_statistics port_stats; |
869 | int index, ret; | ||
821 | 870 | ||
822 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { | 871 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { |
823 | char *p = | 872 | char *p = |
@@ -827,6 +876,24 @@ qlcnic_get_ethtool_stats(struct net_device *dev, | |||
827 | (qlcnic_gstrings_stats[index].sizeof_stat == | 876 | (qlcnic_gstrings_stats[index].sizeof_stat == |
828 | sizeof(u64)) ? *(u64 *)p:(*(u32 *)p); | 877 | sizeof(u64)) ? *(u64 *)p:(*(u32 *)p); |
829 | } | 878 | } |
879 | |||
880 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) | ||
881 | return; | ||
882 | |||
883 | memset(&port_stats, 0, sizeof(struct qlcnic_esw_statistics)); | ||
884 | ret = qlcnic_get_port_stats(adapter, adapter->ahw.pci_func, | ||
885 | QLCNIC_QUERY_RX_COUNTER, &port_stats.rx); | ||
886 | if (ret) | ||
887 | return; | ||
888 | |||
889 | qlcnic_fill_device_stats(&index, data, &port_stats.rx); | ||
890 | |||
891 | ret = qlcnic_get_port_stats(adapter, adapter->ahw.pci_func, | ||
892 | QLCNIC_QUERY_TX_COUNTER, &port_stats.tx); | ||
893 | if (ret) | ||
894 | return; | ||
895 | |||
896 | qlcnic_fill_device_stats(&index, data, &port_stats.tx); | ||
830 | } | 897 | } |
831 | 898 | ||
832 | static int qlcnic_set_tx_csum(struct net_device *dev, u32 data) | 899 | static int qlcnic_set_tx_csum(struct net_device *dev, u32 data) |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index bc669a40ae96..1760533852a4 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -187,12 +187,7 @@ static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = { | |||
187 | 187 | ||
188 | MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); | 188 | MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); |
189 | 189 | ||
190 | /* | 190 | static int rx_buf_sz = 16383; |
191 | * we set our copybreak very high so that we don't have | ||
192 | * to allocate 16k frames all the time (see note in | ||
193 | * rtl8169_open() | ||
194 | */ | ||
195 | static int rx_copybreak = 16383; | ||
196 | static int use_dac; | 191 | static int use_dac; |
197 | static struct { | 192 | static struct { |
198 | u32 msg_enable; | 193 | u32 msg_enable; |
@@ -484,10 +479,8 @@ struct rtl8169_private { | |||
484 | struct RxDesc *RxDescArray; /* 256-aligned Rx descriptor ring */ | 479 | struct RxDesc *RxDescArray; /* 256-aligned Rx descriptor ring */ |
485 | dma_addr_t TxPhyAddr; | 480 | dma_addr_t TxPhyAddr; |
486 | dma_addr_t RxPhyAddr; | 481 | dma_addr_t RxPhyAddr; |
487 | struct sk_buff *Rx_skbuff[NUM_RX_DESC]; /* Rx data buffers */ | 482 | void *Rx_databuff[NUM_RX_DESC]; /* Rx data buffers */ |
488 | struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */ | 483 | struct ring_info tx_skb[NUM_TX_DESC]; /* Tx data buffers */ |
489 | unsigned align; | ||
490 | unsigned rx_buf_sz; | ||
491 | struct timer_list timer; | 484 | struct timer_list timer; |
492 | u16 cp_cmd; | 485 | u16 cp_cmd; |
493 | u16 intr_event; | 486 | u16 intr_event; |
@@ -515,8 +508,6 @@ struct rtl8169_private { | |||
515 | 508 | ||
516 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); | 509 | MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); |
517 | MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); | 510 | MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); |
518 | module_param(rx_copybreak, int, 0); | ||
519 | MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); | ||
520 | module_param(use_dac, int, 0); | 511 | module_param(use_dac, int, 0); |
521 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); | 512 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); |
522 | module_param_named(debug, debug.msg_enable, int, 0); | 513 | module_param_named(debug, debug.msg_enable, int, 0); |
@@ -3196,7 +3187,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
3196 | dev->features |= NETIF_F_GRO; | 3187 | dev->features |= NETIF_F_GRO; |
3197 | 3188 | ||
3198 | tp->intr_mask = 0xffff; | 3189 | tp->intr_mask = 0xffff; |
3199 | tp->align = cfg->align; | ||
3200 | tp->hw_start = cfg->hw_start; | 3190 | tp->hw_start = cfg->hw_start; |
3201 | tp->intr_event = cfg->intr_event; | 3191 | tp->intr_event = cfg->intr_event; |
3202 | tp->napi_event = cfg->napi_event; | 3192 | tp->napi_event = cfg->napi_event; |
@@ -3266,18 +3256,6 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev) | |||
3266 | pci_set_drvdata(pdev, NULL); | 3256 | pci_set_drvdata(pdev, NULL); |
3267 | } | 3257 | } |
3268 | 3258 | ||
3269 | static void rtl8169_set_rxbufsize(struct rtl8169_private *tp, | ||
3270 | unsigned int mtu) | ||
3271 | { | ||
3272 | unsigned int max_frame = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN; | ||
3273 | |||
3274 | if (max_frame != 16383) | ||
3275 | printk(KERN_WARNING PFX "WARNING! Changing of MTU on this " | ||
3276 | "NIC may lead to frame reception errors!\n"); | ||
3277 | |||
3278 | tp->rx_buf_sz = (max_frame > RX_BUF_SIZE) ? max_frame : RX_BUF_SIZE; | ||
3279 | } | ||
3280 | |||
3281 | static int rtl8169_open(struct net_device *dev) | 3259 | static int rtl8169_open(struct net_device *dev) |
3282 | { | 3260 | { |
3283 | struct rtl8169_private *tp = netdev_priv(dev); | 3261 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -3287,18 +3265,6 @@ static int rtl8169_open(struct net_device *dev) | |||
3287 | pm_runtime_get_sync(&pdev->dev); | 3265 | pm_runtime_get_sync(&pdev->dev); |
3288 | 3266 | ||
3289 | /* | 3267 | /* |
3290 | * Note that we use a magic value here, its wierd I know | ||
3291 | * its done because, some subset of rtl8169 hardware suffers from | ||
3292 | * a problem in which frames received that are longer than | ||
3293 | * the size set in RxMaxSize register return garbage sizes | ||
3294 | * when received. To avoid this we need to turn off filtering, | ||
3295 | * which is done by setting a value of 16383 in the RxMaxSize register | ||
3296 | * and allocating 16k frames to handle the largest possible rx value | ||
3297 | * thats what the magic math below does. | ||
3298 | */ | ||
3299 | rtl8169_set_rxbufsize(tp, 16383 - VLAN_ETH_HLEN - ETH_FCS_LEN); | ||
3300 | |||
3301 | /* | ||
3302 | * Rx and Tx desscriptors needs 256 bytes alignment. | 3268 | * Rx and Tx desscriptors needs 256 bytes alignment. |
3303 | * dma_alloc_coherent provides more. | 3269 | * dma_alloc_coherent provides more. |
3304 | */ | 3270 | */ |
@@ -3474,7 +3440,7 @@ static void rtl_hw_start_8169(struct net_device *dev) | |||
3474 | 3440 | ||
3475 | RTL_W8(EarlyTxThres, EarlyTxThld); | 3441 | RTL_W8(EarlyTxThres, EarlyTxThld); |
3476 | 3442 | ||
3477 | rtl_set_rx_max_size(ioaddr, tp->rx_buf_sz); | 3443 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); |
3478 | 3444 | ||
3479 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || | 3445 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || |
3480 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || | 3446 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || |
@@ -3735,7 +3701,7 @@ static void rtl_hw_start_8168(struct net_device *dev) | |||
3735 | 3701 | ||
3736 | RTL_W8(EarlyTxThres, EarlyTxThld); | 3702 | RTL_W8(EarlyTxThres, EarlyTxThld); |
3737 | 3703 | ||
3738 | rtl_set_rx_max_size(ioaddr, tp->rx_buf_sz); | 3704 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); |
3739 | 3705 | ||
3740 | tp->cp_cmd |= RTL_R16(CPlusCmd) | PktCntrDisable | INTT_1; | 3706 | tp->cp_cmd |= RTL_R16(CPlusCmd) | PktCntrDisable | INTT_1; |
3741 | 3707 | ||
@@ -3915,7 +3881,7 @@ static void rtl_hw_start_8101(struct net_device *dev) | |||
3915 | 3881 | ||
3916 | RTL_W8(EarlyTxThres, EarlyTxThld); | 3882 | RTL_W8(EarlyTxThres, EarlyTxThld); |
3917 | 3883 | ||
3918 | rtl_set_rx_max_size(ioaddr, tp->rx_buf_sz); | 3884 | rtl_set_rx_max_size(ioaddr, rx_buf_sz); |
3919 | 3885 | ||
3920 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; | 3886 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; |
3921 | 3887 | ||
@@ -3956,8 +3922,6 @@ static int rtl8169_change_mtu(struct net_device *dev, int new_mtu) | |||
3956 | 3922 | ||
3957 | rtl8169_down(dev); | 3923 | rtl8169_down(dev); |
3958 | 3924 | ||
3959 | rtl8169_set_rxbufsize(tp, dev->mtu); | ||
3960 | |||
3961 | ret = rtl8169_init_ring(dev); | 3925 | ret = rtl8169_init_ring(dev); |
3962 | if (ret < 0) | 3926 | if (ret < 0) |
3963 | goto out; | 3927 | goto out; |
@@ -3978,15 +3942,15 @@ static inline void rtl8169_make_unusable_by_asic(struct RxDesc *desc) | |||
3978 | desc->opts1 &= ~cpu_to_le32(DescOwn | RsvdMask); | 3942 | desc->opts1 &= ~cpu_to_le32(DescOwn | RsvdMask); |
3979 | } | 3943 | } |
3980 | 3944 | ||
3981 | static void rtl8169_free_rx_skb(struct rtl8169_private *tp, | 3945 | static void rtl8169_free_rx_databuff(struct rtl8169_private *tp, |
3982 | struct sk_buff **sk_buff, struct RxDesc *desc) | 3946 | void **data_buff, struct RxDesc *desc) |
3983 | { | 3947 | { |
3984 | struct pci_dev *pdev = tp->pci_dev; | 3948 | struct pci_dev *pdev = tp->pci_dev; |
3985 | 3949 | ||
3986 | dma_unmap_single(&pdev->dev, le64_to_cpu(desc->addr), tp->rx_buf_sz, | 3950 | dma_unmap_single(&pdev->dev, le64_to_cpu(desc->addr), rx_buf_sz, |
3987 | PCI_DMA_FROMDEVICE); | 3951 | PCI_DMA_FROMDEVICE); |
3988 | dev_kfree_skb(*sk_buff); | 3952 | kfree(*data_buff); |
3989 | *sk_buff = NULL; | 3953 | *data_buff = NULL; |
3990 | rtl8169_make_unusable_by_asic(desc); | 3954 | rtl8169_make_unusable_by_asic(desc); |
3991 | } | 3955 | } |
3992 | 3956 | ||
@@ -4005,33 +3969,34 @@ static inline void rtl8169_map_to_asic(struct RxDesc *desc, dma_addr_t mapping, | |||
4005 | rtl8169_mark_to_asic(desc, rx_buf_sz); | 3969 | rtl8169_mark_to_asic(desc, rx_buf_sz); |
4006 | } | 3970 | } |
4007 | 3971 | ||
4008 | static struct sk_buff *rtl8169_alloc_rx_skb(struct pci_dev *pdev, | 3972 | static inline void *rtl8169_align(void *data) |
3973 | { | ||
3974 | return (void *)ALIGN((long)data, 16); | ||
3975 | } | ||
3976 | |||
3977 | static struct sk_buff *rtl8169_alloc_rx_data(struct pci_dev *pdev, | ||
4009 | struct net_device *dev, | 3978 | struct net_device *dev, |
4010 | struct RxDesc *desc, int rx_buf_sz, | 3979 | struct RxDesc *desc) |
4011 | unsigned int align, gfp_t gfp) | ||
4012 | { | 3980 | { |
4013 | struct sk_buff *skb; | 3981 | void *data; |
4014 | dma_addr_t mapping; | 3982 | dma_addr_t mapping; |
4015 | unsigned int pad; | 3983 | int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1; |
4016 | 3984 | ||
4017 | pad = align ? align : NET_IP_ALIGN; | 3985 | data = kmalloc_node(rx_buf_sz, GFP_KERNEL, node); |
3986 | if (!data) | ||
3987 | return NULL; | ||
4018 | 3988 | ||
4019 | skb = __netdev_alloc_skb(dev, rx_buf_sz + pad, gfp); | 3989 | if (rtl8169_align(data) != data) { |
4020 | if (!skb) | 3990 | kfree(data); |
4021 | goto err_out; | 3991 | data = kmalloc_node(rx_buf_sz + 15, GFP_KERNEL, node); |
4022 | 3992 | if (!data) | |
4023 | skb_reserve(skb, align ? ((pad - 1) & (unsigned long)skb->data) : pad); | 3993 | return NULL; |
4024 | 3994 | } | |
4025 | mapping = dma_map_single(&pdev->dev, skb->data, rx_buf_sz, | 3995 | mapping = dma_map_single(&pdev->dev, rtl8169_align(data), rx_buf_sz, |
4026 | PCI_DMA_FROMDEVICE); | 3996 | PCI_DMA_FROMDEVICE); |
4027 | 3997 | ||
4028 | rtl8169_map_to_asic(desc, mapping, rx_buf_sz); | 3998 | rtl8169_map_to_asic(desc, mapping, rx_buf_sz); |
4029 | out: | 3999 | return data; |
4030 | return skb; | ||
4031 | |||
4032 | err_out: | ||
4033 | rtl8169_make_unusable_by_asic(desc); | ||
4034 | goto out; | ||
4035 | } | 4000 | } |
4036 | 4001 | ||
4037 | static void rtl8169_rx_clear(struct rtl8169_private *tp) | 4002 | static void rtl8169_rx_clear(struct rtl8169_private *tp) |
@@ -4039,8 +4004,8 @@ static void rtl8169_rx_clear(struct rtl8169_private *tp) | |||
4039 | unsigned int i; | 4004 | unsigned int i; |
4040 | 4005 | ||
4041 | for (i = 0; i < NUM_RX_DESC; i++) { | 4006 | for (i = 0; i < NUM_RX_DESC; i++) { |
4042 | if (tp->Rx_skbuff[i]) { | 4007 | if (tp->Rx_databuff[i]) { |
4043 | rtl8169_free_rx_skb(tp, tp->Rx_skbuff + i, | 4008 | rtl8169_free_rx_databuff(tp, tp->Rx_databuff + i, |
4044 | tp->RxDescArray + i); | 4009 | tp->RxDescArray + i); |
4045 | } | 4010 | } |
4046 | } | 4011 | } |
@@ -4052,21 +4017,21 @@ static u32 rtl8169_rx_fill(struct rtl8169_private *tp, struct net_device *dev, | |||
4052 | u32 cur; | 4017 | u32 cur; |
4053 | 4018 | ||
4054 | for (cur = start; end - cur != 0; cur++) { | 4019 | for (cur = start; end - cur != 0; cur++) { |
4055 | struct sk_buff *skb; | 4020 | void *data; |
4056 | unsigned int i = cur % NUM_RX_DESC; | 4021 | unsigned int i = cur % NUM_RX_DESC; |
4057 | 4022 | ||
4058 | WARN_ON((s32)(end - cur) < 0); | 4023 | WARN_ON((s32)(end - cur) < 0); |
4059 | 4024 | ||
4060 | if (tp->Rx_skbuff[i]) | 4025 | if (tp->Rx_databuff[i]) |
4061 | continue; | 4026 | continue; |
4062 | 4027 | ||
4063 | skb = rtl8169_alloc_rx_skb(tp->pci_dev, dev, | 4028 | data = rtl8169_alloc_rx_data(tp->pci_dev, dev, |
4064 | tp->RxDescArray + i, | 4029 | tp->RxDescArray + i); |
4065 | tp->rx_buf_sz, tp->align, gfp); | 4030 | if (!data) { |
4066 | if (!skb) | 4031 | rtl8169_make_unusable_by_asic(tp->RxDescArray + i); |
4067 | break; | 4032 | break; |
4068 | 4033 | } | |
4069 | tp->Rx_skbuff[i] = skb; | 4034 | tp->Rx_databuff[i] = data; |
4070 | } | 4035 | } |
4071 | return cur - start; | 4036 | return cur - start; |
4072 | } | 4037 | } |
@@ -4088,7 +4053,7 @@ static int rtl8169_init_ring(struct net_device *dev) | |||
4088 | rtl8169_init_ring_indexes(tp); | 4053 | rtl8169_init_ring_indexes(tp); |
4089 | 4054 | ||
4090 | memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info)); | 4055 | memset(tp->tx_skb, 0x0, NUM_TX_DESC * sizeof(struct ring_info)); |
4091 | memset(tp->Rx_skbuff, 0x0, NUM_RX_DESC * sizeof(struct sk_buff *)); | 4056 | memset(tp->Rx_databuff, 0x0, NUM_RX_DESC * sizeof(void *)); |
4092 | 4057 | ||
4093 | if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC, GFP_KERNEL) != NUM_RX_DESC) | 4058 | if (rtl8169_rx_fill(tp, dev, 0, NUM_RX_DESC, GFP_KERNEL) != NUM_RX_DESC) |
4094 | goto err_out; | 4059 | goto err_out; |
@@ -4473,27 +4438,23 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1) | |||
4473 | skb_checksum_none_assert(skb); | 4438 | skb_checksum_none_assert(skb); |
4474 | } | 4439 | } |
4475 | 4440 | ||
4476 | static inline bool rtl8169_try_rx_copy(struct sk_buff **sk_buff, | 4441 | static struct sk_buff *rtl8169_try_rx_copy(void *data, |
4477 | struct rtl8169_private *tp, int pkt_size, | 4442 | struct rtl8169_private *tp, |
4478 | dma_addr_t addr) | 4443 | int pkt_size, |
4444 | dma_addr_t addr) | ||
4479 | { | 4445 | { |
4480 | struct sk_buff *skb; | 4446 | struct sk_buff *skb; |
4481 | bool done = false; | ||
4482 | |||
4483 | if (pkt_size >= rx_copybreak) | ||
4484 | goto out; | ||
4485 | |||
4486 | skb = netdev_alloc_skb_ip_align(tp->dev, pkt_size); | ||
4487 | if (!skb) | ||
4488 | goto out; | ||
4489 | 4447 | ||
4448 | data = rtl8169_align(data); | ||
4490 | dma_sync_single_for_cpu(&tp->pci_dev->dev, addr, pkt_size, | 4449 | dma_sync_single_for_cpu(&tp->pci_dev->dev, addr, pkt_size, |
4491 | PCI_DMA_FROMDEVICE); | 4450 | PCI_DMA_FROMDEVICE); |
4492 | skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size); | 4451 | prefetch(data); |
4493 | *sk_buff = skb; | 4452 | skb = netdev_alloc_skb_ip_align(tp->dev, pkt_size); |
4494 | done = true; | 4453 | if (skb) |
4495 | out: | 4454 | memcpy(skb->data, data, pkt_size); |
4496 | return done; | 4455 | dma_sync_single_for_device(&tp->pci_dev->dev, addr, pkt_size, |
4456 | PCI_DMA_FROMDEVICE); | ||
4457 | return skb; | ||
4497 | } | 4458 | } |
4498 | 4459 | ||
4499 | /* | 4460 | /* |
@@ -4508,7 +4469,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4508 | void __iomem *ioaddr, u32 budget) | 4469 | void __iomem *ioaddr, u32 budget) |
4509 | { | 4470 | { |
4510 | unsigned int cur_rx, rx_left; | 4471 | unsigned int cur_rx, rx_left; |
4511 | unsigned int delta, count; | 4472 | unsigned int count; |
4512 | int polling = (budget != ~(u32)0) ? 1 : 0; | 4473 | int polling = (budget != ~(u32)0) ? 1 : 0; |
4513 | 4474 | ||
4514 | cur_rx = tp->cur_rx; | 4475 | cur_rx = tp->cur_rx; |
@@ -4537,12 +4498,11 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4537 | rtl8169_schedule_work(dev, rtl8169_reset_task); | 4498 | rtl8169_schedule_work(dev, rtl8169_reset_task); |
4538 | dev->stats.rx_fifo_errors++; | 4499 | dev->stats.rx_fifo_errors++; |
4539 | } | 4500 | } |
4540 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | 4501 | rtl8169_mark_to_asic(desc, rx_buf_sz); |
4541 | } else { | 4502 | } else { |
4542 | struct sk_buff *skb = tp->Rx_skbuff[entry]; | 4503 | struct sk_buff *skb; |
4543 | dma_addr_t addr = le64_to_cpu(desc->addr); | 4504 | dma_addr_t addr = le64_to_cpu(desc->addr); |
4544 | int pkt_size = (status & 0x00001FFF) - 4; | 4505 | int pkt_size = (status & 0x00001FFF) - 4; |
4545 | struct pci_dev *pdev = tp->pci_dev; | ||
4546 | 4506 | ||
4547 | /* | 4507 | /* |
4548 | * The driver does not support incoming fragmented | 4508 | * The driver does not support incoming fragmented |
@@ -4552,18 +4512,16 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4552 | if (unlikely(rtl8169_fragmented_frame(status))) { | 4512 | if (unlikely(rtl8169_fragmented_frame(status))) { |
4553 | dev->stats.rx_dropped++; | 4513 | dev->stats.rx_dropped++; |
4554 | dev->stats.rx_length_errors++; | 4514 | dev->stats.rx_length_errors++; |
4555 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | 4515 | rtl8169_mark_to_asic(desc, rx_buf_sz); |
4556 | continue; | 4516 | continue; |
4557 | } | 4517 | } |
4558 | 4518 | ||
4559 | if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) { | 4519 | skb = rtl8169_try_rx_copy(tp->Rx_databuff[entry], |
4560 | dma_sync_single_for_device(&pdev->dev, addr, | 4520 | tp, pkt_size, addr); |
4561 | pkt_size, PCI_DMA_FROMDEVICE); | 4521 | rtl8169_mark_to_asic(desc, rx_buf_sz); |
4562 | rtl8169_mark_to_asic(desc, tp->rx_buf_sz); | 4522 | if (!skb) { |
4563 | } else { | 4523 | dev->stats.rx_dropped++; |
4564 | dma_unmap_single(&pdev->dev, addr, tp->rx_buf_sz, | 4524 | continue; |
4565 | PCI_DMA_FROMDEVICE); | ||
4566 | tp->Rx_skbuff[entry] = NULL; | ||
4567 | } | 4525 | } |
4568 | 4526 | ||
4569 | rtl8169_rx_csum(skb, status); | 4527 | rtl8169_rx_csum(skb, status); |
@@ -4592,20 +4550,7 @@ static int rtl8169_rx_interrupt(struct net_device *dev, | |||
4592 | count = cur_rx - tp->cur_rx; | 4550 | count = cur_rx - tp->cur_rx; |
4593 | tp->cur_rx = cur_rx; | 4551 | tp->cur_rx = cur_rx; |
4594 | 4552 | ||
4595 | delta = rtl8169_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx, GFP_ATOMIC); | 4553 | tp->dirty_rx += count; |
4596 | if (!delta && count) | ||
4597 | netif_info(tp, intr, dev, "no Rx buffer allocated\n"); | ||
4598 | tp->dirty_rx += delta; | ||
4599 | |||
4600 | /* | ||
4601 | * FIXME: until there is periodic timer to try and refill the ring, | ||
4602 | * a temporary shortage may definitely kill the Rx process. | ||
4603 | * - disable the asic to try and avoid an overflow and kick it again | ||
4604 | * after refill ? | ||
4605 | * - how do others driver handle this condition (Uh oh...). | ||
4606 | */ | ||
4607 | if (tp->dirty_rx + NUM_RX_DESC == tp->cur_rx) | ||
4608 | netif_emerg(tp, intr, dev, "Rx buffers exhausted\n"); | ||
4609 | 4554 | ||
4610 | return count; | 4555 | return count; |
4611 | } | 4556 | } |
diff --git a/drivers/net/stmmac/common.h b/drivers/net/stmmac/common.h index dec7ce40c27a..375ea193e139 100644 --- a/drivers/net/stmmac/common.h +++ b/drivers/net/stmmac/common.h | |||
@@ -235,9 +235,9 @@ struct mii_regs { | |||
235 | }; | 235 | }; |
236 | 236 | ||
237 | struct mac_device_info { | 237 | struct mac_device_info { |
238 | struct stmmac_ops *mac; | 238 | const struct stmmac_ops *mac; |
239 | struct stmmac_desc_ops *desc; | 239 | const struct stmmac_desc_ops *desc; |
240 | struct stmmac_dma_ops *dma; | 240 | const struct stmmac_dma_ops *dma; |
241 | struct mii_regs mii; /* MII register Addresses */ | 241 | struct mii_regs mii; /* MII register Addresses */ |
242 | struct mac_link link; | 242 | struct mac_link link; |
243 | }; | 243 | }; |
diff --git a/drivers/net/stmmac/dwmac100.h b/drivers/net/stmmac/dwmac100.h index 97956cbf1cb4..7c6d857a9cc7 100644 --- a/drivers/net/stmmac/dwmac100.h +++ b/drivers/net/stmmac/dwmac100.h | |||
@@ -118,4 +118,4 @@ enum ttc_control { | |||
118 | #define DMA_MISSED_FRAME_OVE_M 0x00010000 /* Missed Frame Overflow */ | 118 | #define DMA_MISSED_FRAME_OVE_M 0x00010000 /* Missed Frame Overflow */ |
119 | #define DMA_MISSED_FRAME_M_CNTR 0x0000ffff /* Missed Frame Couinter */ | 119 | #define DMA_MISSED_FRAME_M_CNTR 0x0000ffff /* Missed Frame Couinter */ |
120 | 120 | ||
121 | extern struct stmmac_dma_ops dwmac100_dma_ops; | 121 | extern const struct stmmac_dma_ops dwmac100_dma_ops; |
diff --git a/drivers/net/stmmac/dwmac1000.h b/drivers/net/stmmac/dwmac1000.h index 81ee4fd04386..cfcef0ea0fa5 100644 --- a/drivers/net/stmmac/dwmac1000.h +++ b/drivers/net/stmmac/dwmac1000.h | |||
@@ -205,4 +205,4 @@ enum rtc_control { | |||
205 | #define GMAC_MMC_TX_INTR 0x108 | 205 | #define GMAC_MMC_TX_INTR 0x108 |
206 | #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208 | 206 | #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208 |
207 | 207 | ||
208 | extern struct stmmac_dma_ops dwmac1000_dma_ops; | 208 | extern const struct stmmac_dma_ops dwmac1000_dma_ops; |
diff --git a/drivers/net/stmmac/dwmac1000_core.c b/drivers/net/stmmac/dwmac1000_core.c index 65667b692024..6ae4c3f4c63c 100644 --- a/drivers/net/stmmac/dwmac1000_core.c +++ b/drivers/net/stmmac/dwmac1000_core.c | |||
@@ -212,7 +212,7 @@ static void dwmac1000_irq_status(void __iomem *ioaddr) | |||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | struct stmmac_ops dwmac1000_ops = { | 215 | static const struct stmmac_ops dwmac1000_ops = { |
216 | .core_init = dwmac1000_core_init, | 216 | .core_init = dwmac1000_core_init, |
217 | .rx_coe = dwmac1000_rx_coe_supported, | 217 | .rx_coe = dwmac1000_rx_coe_supported, |
218 | .dump_regs = dwmac1000_dump_regs, | 218 | .dump_regs = dwmac1000_dump_regs, |
diff --git a/drivers/net/stmmac/dwmac1000_dma.c b/drivers/net/stmmac/dwmac1000_dma.c index ce6163e39cd5..2c47712d45d0 100644 --- a/drivers/net/stmmac/dwmac1000_dma.c +++ b/drivers/net/stmmac/dwmac1000_dma.c | |||
@@ -138,7 +138,7 @@ static void dwmac1000_dump_dma_regs(void __iomem *ioaddr) | |||
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | struct stmmac_dma_ops dwmac1000_dma_ops = { | 141 | const struct stmmac_dma_ops dwmac1000_dma_ops = { |
142 | .init = dwmac1000_dma_init, | 142 | .init = dwmac1000_dma_init, |
143 | .dump_regs = dwmac1000_dump_dma_regs, | 143 | .dump_regs = dwmac1000_dump_dma_regs, |
144 | .dma_mode = dwmac1000_dma_operation_mode, | 144 | .dma_mode = dwmac1000_dma_operation_mode, |
diff --git a/drivers/net/stmmac/dwmac100_core.c b/drivers/net/stmmac/dwmac100_core.c index 94eeccf3a8a0..c724fc36a24f 100644 --- a/drivers/net/stmmac/dwmac100_core.c +++ b/drivers/net/stmmac/dwmac100_core.c | |||
@@ -168,7 +168,7 @@ static void dwmac100_pmt(void __iomem *ioaddr, unsigned long mode) | |||
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | struct stmmac_ops dwmac100_ops = { | 171 | static const struct stmmac_ops dwmac100_ops = { |
172 | .core_init = dwmac100_core_init, | 172 | .core_init = dwmac100_core_init, |
173 | .rx_coe = dwmac100_rx_coe_supported, | 173 | .rx_coe = dwmac100_rx_coe_supported, |
174 | .dump_regs = dwmac100_dump_mac_regs, | 174 | .dump_regs = dwmac100_dump_mac_regs, |
diff --git a/drivers/net/stmmac/dwmac100_dma.c b/drivers/net/stmmac/dwmac100_dma.c index 96aac93b789b..e3e224b7d9e2 100644 --- a/drivers/net/stmmac/dwmac100_dma.c +++ b/drivers/net/stmmac/dwmac100_dma.c | |||
@@ -126,7 +126,7 @@ static void dwmac100_dma_diagnostic_fr(void *data, struct stmmac_extra_stats *x, | |||
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | struct stmmac_dma_ops dwmac100_dma_ops = { | 129 | const struct stmmac_dma_ops dwmac100_dma_ops = { |
130 | .init = dwmac100_dma_init, | 130 | .init = dwmac100_dma_init, |
131 | .dump_regs = dwmac100_dump_dma_regs, | 131 | .dump_regs = dwmac100_dump_dma_regs, |
132 | .dma_mode = dwmac100_dma_operation_mode, | 132 | .dma_mode = dwmac100_dma_operation_mode, |
diff --git a/drivers/net/stmmac/enh_desc.c b/drivers/net/stmmac/enh_desc.c index 5d1471d8f8f6..e5dfb6a30182 100644 --- a/drivers/net/stmmac/enh_desc.c +++ b/drivers/net/stmmac/enh_desc.c | |||
@@ -318,7 +318,7 @@ static int enh_desc_get_rx_frame_len(struct dma_desc *p) | |||
318 | return p->des01.erx.frame_length; | 318 | return p->des01.erx.frame_length; |
319 | } | 319 | } |
320 | 320 | ||
321 | struct stmmac_desc_ops enh_desc_ops = { | 321 | const struct stmmac_desc_ops enh_desc_ops = { |
322 | .tx_status = enh_desc_get_tx_status, | 322 | .tx_status = enh_desc_get_tx_status, |
323 | .rx_status = enh_desc_get_rx_status, | 323 | .rx_status = enh_desc_get_rx_status, |
324 | .get_tx_len = enh_desc_get_tx_len, | 324 | .get_tx_len = enh_desc_get_tx_len, |
diff --git a/drivers/net/stmmac/norm_desc.c b/drivers/net/stmmac/norm_desc.c index 0dce90cb8124..cd0cc76f7a1c 100644 --- a/drivers/net/stmmac/norm_desc.c +++ b/drivers/net/stmmac/norm_desc.c | |||
@@ -202,7 +202,7 @@ static int ndesc_get_rx_frame_len(struct dma_desc *p) | |||
202 | return p->des01.rx.frame_length; | 202 | return p->des01.rx.frame_length; |
203 | } | 203 | } |
204 | 204 | ||
205 | struct stmmac_desc_ops ndesc_ops = { | 205 | const struct stmmac_desc_ops ndesc_ops = { |
206 | .tx_status = ndesc_get_tx_status, | 206 | .tx_status = ndesc_get_tx_status, |
207 | .rx_status = ndesc_get_rx_status, | 207 | .rx_status = ndesc_get_rx_status, |
208 | .get_tx_len = ndesc_get_tx_len, | 208 | .get_tx_len = ndesc_get_tx_len, |
diff --git a/drivers/net/stmmac/stmmac.h b/drivers/net/stmmac/stmmac.h index 92154ff7d702..79bdc2e13224 100644 --- a/drivers/net/stmmac/stmmac.h +++ b/drivers/net/stmmac/stmmac.h | |||
@@ -121,5 +121,5 @@ static inline int stmmac_claim_resource(struct platform_device *pdev) | |||
121 | extern int stmmac_mdio_unregister(struct net_device *ndev); | 121 | extern int stmmac_mdio_unregister(struct net_device *ndev); |
122 | extern int stmmac_mdio_register(struct net_device *ndev); | 122 | extern int stmmac_mdio_register(struct net_device *ndev); |
123 | extern void stmmac_set_ethtool_ops(struct net_device *netdev); | 123 | extern void stmmac_set_ethtool_ops(struct net_device *netdev); |
124 | extern struct stmmac_desc_ops enh_desc_ops; | 124 | extern const struct stmmac_desc_ops enh_desc_ops; |
125 | extern struct stmmac_desc_ops ndesc_ops; | 125 | extern const struct stmmac_desc_ops ndesc_ops; |
diff --git a/drivers/net/stmmac/stmmac_ethtool.c b/drivers/net/stmmac/stmmac_ethtool.c index 25a7e385f8ec..6d65482e789a 100644 --- a/drivers/net/stmmac/stmmac_ethtool.c +++ b/drivers/net/stmmac/stmmac_ethtool.c | |||
@@ -89,8 +89,8 @@ static const struct stmmac_stats stmmac_gstrings_stats[] = { | |||
89 | }; | 89 | }; |
90 | #define STMMAC_STATS_LEN ARRAY_SIZE(stmmac_gstrings_stats) | 90 | #define STMMAC_STATS_LEN ARRAY_SIZE(stmmac_gstrings_stats) |
91 | 91 | ||
92 | void stmmac_ethtool_getdrvinfo(struct net_device *dev, | 92 | static void stmmac_ethtool_getdrvinfo(struct net_device *dev, |
93 | struct ethtool_drvinfo *info) | 93 | struct ethtool_drvinfo *info) |
94 | { | 94 | { |
95 | struct stmmac_priv *priv = netdev_priv(dev); | 95 | struct stmmac_priv *priv = netdev_priv(dev); |
96 | 96 | ||
@@ -104,7 +104,8 @@ void stmmac_ethtool_getdrvinfo(struct net_device *dev, | |||
104 | info->n_stats = STMMAC_STATS_LEN; | 104 | info->n_stats = STMMAC_STATS_LEN; |
105 | } | 105 | } |
106 | 106 | ||
107 | int stmmac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) | 107 | static int stmmac_ethtool_getsettings(struct net_device *dev, |
108 | struct ethtool_cmd *cmd) | ||
108 | { | 109 | { |
109 | struct stmmac_priv *priv = netdev_priv(dev); | 110 | struct stmmac_priv *priv = netdev_priv(dev); |
110 | struct phy_device *phy = priv->phydev; | 111 | struct phy_device *phy = priv->phydev; |
@@ -126,7 +127,8 @@ int stmmac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
126 | return rc; | 127 | return rc; |
127 | } | 128 | } |
128 | 129 | ||
129 | int stmmac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd) | 130 | static int stmmac_ethtool_setsettings(struct net_device *dev, |
131 | struct ethtool_cmd *cmd) | ||
130 | { | 132 | { |
131 | struct stmmac_priv *priv = netdev_priv(dev); | 133 | struct stmmac_priv *priv = netdev_priv(dev); |
132 | struct phy_device *phy = priv->phydev; | 134 | struct phy_device *phy = priv->phydev; |
@@ -139,32 +141,32 @@ int stmmac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
139 | return rc; | 141 | return rc; |
140 | } | 142 | } |
141 | 143 | ||
142 | u32 stmmac_ethtool_getmsglevel(struct net_device *dev) | 144 | static u32 stmmac_ethtool_getmsglevel(struct net_device *dev) |
143 | { | 145 | { |
144 | struct stmmac_priv *priv = netdev_priv(dev); | 146 | struct stmmac_priv *priv = netdev_priv(dev); |
145 | return priv->msg_enable; | 147 | return priv->msg_enable; |
146 | } | 148 | } |
147 | 149 | ||
148 | void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level) | 150 | static void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level) |
149 | { | 151 | { |
150 | struct stmmac_priv *priv = netdev_priv(dev); | 152 | struct stmmac_priv *priv = netdev_priv(dev); |
151 | priv->msg_enable = level; | 153 | priv->msg_enable = level; |
152 | 154 | ||
153 | } | 155 | } |
154 | 156 | ||
155 | int stmmac_check_if_running(struct net_device *dev) | 157 | static int stmmac_check_if_running(struct net_device *dev) |
156 | { | 158 | { |
157 | if (!netif_running(dev)) | 159 | if (!netif_running(dev)) |
158 | return -EBUSY; | 160 | return -EBUSY; |
159 | return 0; | 161 | return 0; |
160 | } | 162 | } |
161 | 163 | ||
162 | int stmmac_ethtool_get_regs_len(struct net_device *dev) | 164 | static int stmmac_ethtool_get_regs_len(struct net_device *dev) |
163 | { | 165 | { |
164 | return REG_SPACE_SIZE; | 166 | return REG_SPACE_SIZE; |
165 | } | 167 | } |
166 | 168 | ||
167 | void stmmac_ethtool_gregs(struct net_device *dev, | 169 | static void stmmac_ethtool_gregs(struct net_device *dev, |
168 | struct ethtool_regs *regs, void *space) | 170 | struct ethtool_regs *regs, void *space) |
169 | { | 171 | { |
170 | int i; | 172 | int i; |
@@ -195,7 +197,7 @@ void stmmac_ethtool_gregs(struct net_device *dev, | |||
195 | } | 197 | } |
196 | } | 198 | } |
197 | 199 | ||
198 | int stmmac_ethtool_set_tx_csum(struct net_device *netdev, u32 data) | 200 | static int stmmac_ethtool_set_tx_csum(struct net_device *netdev, u32 data) |
199 | { | 201 | { |
200 | if (data) | 202 | if (data) |
201 | netdev->features |= NETIF_F_HW_CSUM; | 203 | netdev->features |= NETIF_F_HW_CSUM; |
@@ -205,7 +207,7 @@ int stmmac_ethtool_set_tx_csum(struct net_device *netdev, u32 data) | |||
205 | return 0; | 207 | return 0; |
206 | } | 208 | } |
207 | 209 | ||
208 | u32 stmmac_ethtool_get_rx_csum(struct net_device *dev) | 210 | static u32 stmmac_ethtool_get_rx_csum(struct net_device *dev) |
209 | { | 211 | { |
210 | struct stmmac_priv *priv = netdev_priv(dev); | 212 | struct stmmac_priv *priv = netdev_priv(dev); |
211 | 213 | ||
@@ -378,10 +380,8 @@ static struct ethtool_ops stmmac_ethtool_ops = { | |||
378 | .get_wol = stmmac_get_wol, | 380 | .get_wol = stmmac_get_wol, |
379 | .set_wol = stmmac_set_wol, | 381 | .set_wol = stmmac_set_wol, |
380 | .get_sset_count = stmmac_get_sset_count, | 382 | .get_sset_count = stmmac_get_sset_count, |
381 | #ifdef NETIF_F_TSO | ||
382 | .get_tso = ethtool_op_get_tso, | 383 | .get_tso = ethtool_op_get_tso, |
383 | .set_tso = ethtool_op_set_tso, | 384 | .set_tso = ethtool_op_set_tso, |
384 | #endif | ||
385 | }; | 385 | }; |
386 | 386 | ||
387 | void stmmac_set_ethtool_ops(struct net_device *netdev) | 387 | void stmmac_set_ethtool_ops(struct net_device *netdev) |
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index 4283cc52a8c9..3ed2a67bd6d3 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c | |||
@@ -363,6 +363,19 @@ struct netdev_private { | |||
363 | dma_addr_t tx_ring_dma; | 363 | dma_addr_t tx_ring_dma; |
364 | dma_addr_t rx_ring_dma; | 364 | dma_addr_t rx_ring_dma; |
365 | struct timer_list timer; /* Media monitoring timer. */ | 365 | struct timer_list timer; /* Media monitoring timer. */ |
366 | /* ethtool extra stats */ | ||
367 | struct { | ||
368 | u64 tx_multiple_collisions; | ||
369 | u64 tx_single_collisions; | ||
370 | u64 tx_late_collisions; | ||
371 | u64 tx_deferred; | ||
372 | u64 tx_deferred_excessive; | ||
373 | u64 tx_aborted; | ||
374 | u64 tx_bcasts; | ||
375 | u64 rx_bcasts; | ||
376 | u64 tx_mcasts; | ||
377 | u64 rx_mcasts; | ||
378 | } xstats; | ||
366 | /* Frequently used values: keep some adjacent for cache effect. */ | 379 | /* Frequently used values: keep some adjacent for cache effect. */ |
367 | spinlock_t lock; | 380 | spinlock_t lock; |
368 | int msg_enable; | 381 | int msg_enable; |
@@ -1486,21 +1499,34 @@ static struct net_device_stats *get_stats(struct net_device *dev) | |||
1486 | { | 1499 | { |
1487 | struct netdev_private *np = netdev_priv(dev); | 1500 | struct netdev_private *np = netdev_priv(dev); |
1488 | void __iomem *ioaddr = np->base; | 1501 | void __iomem *ioaddr = np->base; |
1489 | int i; | ||
1490 | unsigned long flags; | 1502 | unsigned long flags; |
1503 | u8 late_coll, single_coll, mult_coll; | ||
1491 | 1504 | ||
1492 | spin_lock_irqsave(&np->statlock, flags); | 1505 | spin_lock_irqsave(&np->statlock, flags); |
1493 | /* The chip only need report frame silently dropped. */ | 1506 | /* The chip only need report frame silently dropped. */ |
1494 | dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed); | 1507 | dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed); |
1495 | dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK); | 1508 | dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK); |
1496 | dev->stats.rx_packets += ioread16(ioaddr + RxFramesOK); | 1509 | dev->stats.rx_packets += ioread16(ioaddr + RxFramesOK); |
1497 | dev->stats.collisions += ioread8(ioaddr + StatsLateColl); | ||
1498 | dev->stats.collisions += ioread8(ioaddr + StatsMultiColl); | ||
1499 | dev->stats.collisions += ioread8(ioaddr + StatsOneColl); | ||
1500 | dev->stats.tx_carrier_errors += ioread8(ioaddr + StatsCarrierError); | 1510 | dev->stats.tx_carrier_errors += ioread8(ioaddr + StatsCarrierError); |
1501 | ioread8(ioaddr + StatsTxDefer); | 1511 | |
1502 | for (i = StatsTxDefer; i <= StatsMcastRx; i++) | 1512 | mult_coll = ioread8(ioaddr + StatsMultiColl); |
1503 | ioread8(ioaddr + i); | 1513 | np->xstats.tx_multiple_collisions += mult_coll; |
1514 | single_coll = ioread8(ioaddr + StatsOneColl); | ||
1515 | np->xstats.tx_single_collisions += single_coll; | ||
1516 | late_coll = ioread8(ioaddr + StatsLateColl); | ||
1517 | np->xstats.tx_late_collisions += late_coll; | ||
1518 | dev->stats.collisions += mult_coll | ||
1519 | + single_coll | ||
1520 | + late_coll; | ||
1521 | |||
1522 | np->xstats.tx_deferred += ioread8(ioaddr + StatsTxDefer); | ||
1523 | np->xstats.tx_deferred_excessive += ioread8(ioaddr + StatsTxXSDefer); | ||
1524 | np->xstats.tx_aborted += ioread8(ioaddr + StatsTxAbort); | ||
1525 | np->xstats.tx_bcasts += ioread8(ioaddr + StatsBcastTx); | ||
1526 | np->xstats.rx_bcasts += ioread8(ioaddr + StatsBcastRx); | ||
1527 | np->xstats.tx_mcasts += ioread8(ioaddr + StatsMcastTx); | ||
1528 | np->xstats.rx_mcasts += ioread8(ioaddr + StatsMcastRx); | ||
1529 | |||
1504 | dev->stats.tx_bytes += ioread16(ioaddr + TxOctetsLow); | 1530 | dev->stats.tx_bytes += ioread16(ioaddr + TxOctetsLow); |
1505 | dev->stats.tx_bytes += ioread16(ioaddr + TxOctetsHigh) << 16; | 1531 | dev->stats.tx_bytes += ioread16(ioaddr + TxOctetsHigh) << 16; |
1506 | dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow); | 1532 | dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow); |
@@ -1566,6 +1592,21 @@ static int __set_mac_addr(struct net_device *dev) | |||
1566 | return 0; | 1592 | return 0; |
1567 | } | 1593 | } |
1568 | 1594 | ||
1595 | static const struct { | ||
1596 | const char name[ETH_GSTRING_LEN]; | ||
1597 | } sundance_stats[] = { | ||
1598 | { "tx_multiple_collisions" }, | ||
1599 | { "tx_single_collisions" }, | ||
1600 | { "tx_late_collisions" }, | ||
1601 | { "tx_deferred" }, | ||
1602 | { "tx_deferred_excessive" }, | ||
1603 | { "tx_aborted" }, | ||
1604 | { "tx_bcasts" }, | ||
1605 | { "rx_bcasts" }, | ||
1606 | { "tx_mcasts" }, | ||
1607 | { "rx_mcasts" }, | ||
1608 | }; | ||
1609 | |||
1569 | static int check_if_running(struct net_device *dev) | 1610 | static int check_if_running(struct net_device *dev) |
1570 | { | 1611 | { |
1571 | if (!netif_running(dev)) | 1612 | if (!netif_running(dev)) |
@@ -1624,6 +1665,42 @@ static void set_msglevel(struct net_device *dev, u32 val) | |||
1624 | np->msg_enable = val; | 1665 | np->msg_enable = val; |
1625 | } | 1666 | } |
1626 | 1667 | ||
1668 | static void get_strings(struct net_device *dev, u32 stringset, | ||
1669 | u8 *data) | ||
1670 | { | ||
1671 | if (stringset == ETH_SS_STATS) | ||
1672 | memcpy(data, sundance_stats, sizeof(sundance_stats)); | ||
1673 | } | ||
1674 | |||
1675 | static int get_sset_count(struct net_device *dev, int sset) | ||
1676 | { | ||
1677 | switch (sset) { | ||
1678 | case ETH_SS_STATS: | ||
1679 | return ARRAY_SIZE(sundance_stats); | ||
1680 | default: | ||
1681 | return -EOPNOTSUPP; | ||
1682 | } | ||
1683 | } | ||
1684 | |||
1685 | static void get_ethtool_stats(struct net_device *dev, | ||
1686 | struct ethtool_stats *stats, u64 *data) | ||
1687 | { | ||
1688 | struct netdev_private *np = netdev_priv(dev); | ||
1689 | int i = 0; | ||
1690 | |||
1691 | get_stats(dev); | ||
1692 | data[i++] = np->xstats.tx_multiple_collisions; | ||
1693 | data[i++] = np->xstats.tx_single_collisions; | ||
1694 | data[i++] = np->xstats.tx_late_collisions; | ||
1695 | data[i++] = np->xstats.tx_deferred; | ||
1696 | data[i++] = np->xstats.tx_deferred_excessive; | ||
1697 | data[i++] = np->xstats.tx_aborted; | ||
1698 | data[i++] = np->xstats.tx_bcasts; | ||
1699 | data[i++] = np->xstats.rx_bcasts; | ||
1700 | data[i++] = np->xstats.tx_mcasts; | ||
1701 | data[i++] = np->xstats.rx_mcasts; | ||
1702 | } | ||
1703 | |||
1627 | static const struct ethtool_ops ethtool_ops = { | 1704 | static const struct ethtool_ops ethtool_ops = { |
1628 | .begin = check_if_running, | 1705 | .begin = check_if_running, |
1629 | .get_drvinfo = get_drvinfo, | 1706 | .get_drvinfo = get_drvinfo, |
@@ -1633,6 +1710,9 @@ static const struct ethtool_ops ethtool_ops = { | |||
1633 | .get_link = get_link, | 1710 | .get_link = get_link, |
1634 | .get_msglevel = get_msglevel, | 1711 | .get_msglevel = get_msglevel, |
1635 | .set_msglevel = set_msglevel, | 1712 | .set_msglevel = set_msglevel, |
1713 | .get_strings = get_strings, | ||
1714 | .get_sset_count = get_sset_count, | ||
1715 | .get_ethtool_stats = get_ethtool_stats, | ||
1636 | }; | 1716 | }; |
1637 | 1717 | ||
1638 | static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 1718 | static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 943c28325444..5b4c510dbced 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -69,10 +69,10 @@ | |||
69 | 69 | ||
70 | #define DRV_MODULE_NAME "tg3" | 70 | #define DRV_MODULE_NAME "tg3" |
71 | #define TG3_MAJ_NUM 3 | 71 | #define TG3_MAJ_NUM 3 |
72 | #define TG3_MIN_NUM 114 | 72 | #define TG3_MIN_NUM 115 |
73 | #define DRV_MODULE_VERSION \ | 73 | #define DRV_MODULE_VERSION \ |
74 | __stringify(TG3_MAJ_NUM) "." __stringify(TG3_MIN_NUM) | 74 | __stringify(TG3_MAJ_NUM) "." __stringify(TG3_MIN_NUM) |
75 | #define DRV_MODULE_RELDATE "September 30, 2010" | 75 | #define DRV_MODULE_RELDATE "October 14, 2010" |
76 | 76 | ||
77 | #define TG3_DEF_MAC_MODE 0 | 77 | #define TG3_DEF_MAC_MODE 0 |
78 | #define TG3_DEF_RX_MODE 0 | 78 | #define TG3_DEF_RX_MODE 0 |
@@ -1162,6 +1162,52 @@ static void tg3_mdio_fini(struct tg3 *tp) | |||
1162 | } | 1162 | } |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | static int tg3_phy_cl45_write(struct tg3 *tp, u32 devad, u32 addr, u32 val) | ||
1166 | { | ||
1167 | int err; | ||
1168 | |||
1169 | err = tg3_writephy(tp, MII_TG3_MMD_CTRL, devad); | ||
1170 | if (err) | ||
1171 | goto done; | ||
1172 | |||
1173 | err = tg3_writephy(tp, MII_TG3_MMD_ADDRESS, addr); | ||
1174 | if (err) | ||
1175 | goto done; | ||
1176 | |||
1177 | err = tg3_writephy(tp, MII_TG3_MMD_CTRL, | ||
1178 | MII_TG3_MMD_CTRL_DATA_NOINC | devad); | ||
1179 | if (err) | ||
1180 | goto done; | ||
1181 | |||
1182 | err = tg3_writephy(tp, MII_TG3_MMD_ADDRESS, val); | ||
1183 | |||
1184 | done: | ||
1185 | return err; | ||
1186 | } | ||
1187 | |||
1188 | static int tg3_phy_cl45_read(struct tg3 *tp, u32 devad, u32 addr, u32 *val) | ||
1189 | { | ||
1190 | int err; | ||
1191 | |||
1192 | err = tg3_writephy(tp, MII_TG3_MMD_CTRL, devad); | ||
1193 | if (err) | ||
1194 | goto done; | ||
1195 | |||
1196 | err = tg3_writephy(tp, MII_TG3_MMD_ADDRESS, addr); | ||
1197 | if (err) | ||
1198 | goto done; | ||
1199 | |||
1200 | err = tg3_writephy(tp, MII_TG3_MMD_CTRL, | ||
1201 | MII_TG3_MMD_CTRL_DATA_NOINC | devad); | ||
1202 | if (err) | ||
1203 | goto done; | ||
1204 | |||
1205 | err = tg3_readphy(tp, MII_TG3_MMD_ADDRESS, val); | ||
1206 | |||
1207 | done: | ||
1208 | return err; | ||
1209 | } | ||
1210 | |||
1165 | /* tp->lock is held. */ | 1211 | /* tp->lock is held. */ |
1166 | static inline void tg3_generate_fw_event(struct tg3 *tp) | 1212 | static inline void tg3_generate_fw_event(struct tg3 *tp) |
1167 | { | 1213 | { |
@@ -1538,6 +1584,17 @@ static void tg3_phy_fini(struct tg3 *tp) | |||
1538 | } | 1584 | } |
1539 | } | 1585 | } |
1540 | 1586 | ||
1587 | static int tg3_phydsp_read(struct tg3 *tp, u32 reg, u32 *val) | ||
1588 | { | ||
1589 | int err; | ||
1590 | |||
1591 | err = tg3_writephy(tp, MII_TG3_DSP_ADDRESS, reg); | ||
1592 | if (!err) | ||
1593 | err = tg3_readphy(tp, MII_TG3_DSP_RW_PORT, val); | ||
1594 | |||
1595 | return err; | ||
1596 | } | ||
1597 | |||
1541 | static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val) | 1598 | static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val) |
1542 | { | 1599 | { |
1543 | int err; | 1600 | int err; |
@@ -1701,6 +1758,42 @@ static void tg3_phy_apply_otp(struct tg3 *tp) | |||
1701 | tg3_writephy(tp, MII_TG3_AUX_CTRL, phy); | 1758 | tg3_writephy(tp, MII_TG3_AUX_CTRL, phy); |
1702 | } | 1759 | } |
1703 | 1760 | ||
1761 | static void tg3_phy_eee_adjust(struct tg3 *tp, u32 current_link_up) | ||
1762 | { | ||
1763 | u32 val; | ||
1764 | |||
1765 | if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP)) | ||
1766 | return; | ||
1767 | |||
1768 | tp->setlpicnt = 0; | ||
1769 | |||
1770 | if (tp->link_config.autoneg == AUTONEG_ENABLE && | ||
1771 | current_link_up == 1 && | ||
1772 | (tp->link_config.active_speed == SPEED_1000 || | ||
1773 | (tp->link_config.active_speed == SPEED_100 && | ||
1774 | tp->link_config.active_duplex == DUPLEX_FULL))) { | ||
1775 | u32 eeectl; | ||
1776 | |||
1777 | if (tp->link_config.active_speed == SPEED_1000) | ||
1778 | eeectl = TG3_CPMU_EEE_CTRL_EXIT_16_5_US; | ||
1779 | else | ||
1780 | eeectl = TG3_CPMU_EEE_CTRL_EXIT_36_US; | ||
1781 | |||
1782 | tw32(TG3_CPMU_EEE_CTRL, eeectl); | ||
1783 | |||
1784 | tg3_phy_cl45_read(tp, 0x7, TG3_CL45_D7_EEERES_STAT, &val); | ||
1785 | |||
1786 | if (val == TG3_CL45_D7_EEERES_STAT_LP_1000T || | ||
1787 | val == TG3_CL45_D7_EEERES_STAT_LP_100TX) | ||
1788 | tp->setlpicnt = 2; | ||
1789 | } | ||
1790 | |||
1791 | if (!tp->setlpicnt) { | ||
1792 | val = tr32(TG3_CPMU_EEE_MODE); | ||
1793 | tw32(TG3_CPMU_EEE_MODE, val & ~TG3_CPMU_EEEMD_LPI_ENABLE); | ||
1794 | } | ||
1795 | } | ||
1796 | |||
1704 | static int tg3_wait_macro_done(struct tg3 *tp) | 1797 | static int tg3_wait_macro_done(struct tg3 *tp) |
1705 | { | 1798 | { |
1706 | int limit = 100; | 1799 | int limit = 100; |
@@ -2875,6 +2968,44 @@ static void tg3_phy_copper_begin(struct tg3 *tp) | |||
2875 | tg3_writephy(tp, MII_TG3_CTRL, new_adv); | 2968 | tg3_writephy(tp, MII_TG3_CTRL, new_adv); |
2876 | } | 2969 | } |
2877 | 2970 | ||
2971 | if (tp->phy_flags & TG3_PHYFLG_EEE_CAP) { | ||
2972 | u32 val = 0; | ||
2973 | |||
2974 | tw32(TG3_CPMU_EEE_MODE, | ||
2975 | tr32(TG3_CPMU_EEE_MODE) & ~TG3_CPMU_EEEMD_LPI_ENABLE); | ||
2976 | |||
2977 | /* Enable SM_DSP clock and tx 6dB coding. */ | ||
2978 | val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL | | ||
2979 | MII_TG3_AUXCTL_ACTL_SMDSP_ENA | | ||
2980 | MII_TG3_AUXCTL_ACTL_TX_6DB; | ||
2981 | tg3_writephy(tp, MII_TG3_AUX_CTRL, val); | ||
2982 | |||
2983 | if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || | ||
2984 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765) && | ||
2985 | !tg3_phydsp_read(tp, MII_TG3_DSP_CH34TP2, &val)) | ||
2986 | tg3_phydsp_write(tp, MII_TG3_DSP_CH34TP2, | ||
2987 | val | MII_TG3_DSP_CH34TP2_HIBW01); | ||
2988 | |||
2989 | if (tp->link_config.autoneg == AUTONEG_ENABLE) { | ||
2990 | /* Advertise 100-BaseTX EEE ability */ | ||
2991 | if (tp->link_config.advertising & | ||
2992 | (ADVERTISED_100baseT_Half | | ||
2993 | ADVERTISED_100baseT_Full)) | ||
2994 | val |= TG3_CL45_D7_EEEADV_CAP_100TX; | ||
2995 | /* Advertise 1000-BaseT EEE ability */ | ||
2996 | if (tp->link_config.advertising & | ||
2997 | (ADVERTISED_1000baseT_Half | | ||
2998 | ADVERTISED_1000baseT_Full)) | ||
2999 | val |= TG3_CL45_D7_EEEADV_CAP_1000T; | ||
3000 | } | ||
3001 | tg3_phy_cl45_write(tp, 0x7, TG3_CL45_D7_EEEADV_CAP, val); | ||
3002 | |||
3003 | /* Turn off SM_DSP clock. */ | ||
3004 | val = MII_TG3_AUXCTL_SHDWSEL_AUXCTL | | ||
3005 | MII_TG3_AUXCTL_ACTL_TX_6DB; | ||
3006 | tg3_writephy(tp, MII_TG3_AUX_CTRL, val); | ||
3007 | } | ||
3008 | |||
2878 | if (tp->link_config.autoneg == AUTONEG_DISABLE && | 3009 | if (tp->link_config.autoneg == AUTONEG_DISABLE && |
2879 | tp->link_config.speed != SPEED_INVALID) { | 3010 | tp->link_config.speed != SPEED_INVALID) { |
2880 | u32 bmcr, orig_bmcr; | 3011 | u32 bmcr, orig_bmcr; |
@@ -3236,6 +3367,8 @@ relink: | |||
3236 | tw32_f(MAC_MODE, tp->mac_mode); | 3367 | tw32_f(MAC_MODE, tp->mac_mode); |
3237 | udelay(40); | 3368 | udelay(40); |
3238 | 3369 | ||
3370 | tg3_phy_eee_adjust(tp, current_link_up); | ||
3371 | |||
3239 | if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { | 3372 | if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { |
3240 | /* Polled via timer. */ | 3373 | /* Polled via timer. */ |
3241 | tw32_f(MAC_EVENT, 0); | 3374 | tw32_f(MAC_EVENT, 0); |
@@ -4440,12 +4573,11 @@ static int tg3_alloc_rx_skb(struct tg3 *tp, struct tg3_rx_prodring_set *tpr, | |||
4440 | u32 opaque_key, u32 dest_idx_unmasked) | 4573 | u32 opaque_key, u32 dest_idx_unmasked) |
4441 | { | 4574 | { |
4442 | struct tg3_rx_buffer_desc *desc; | 4575 | struct tg3_rx_buffer_desc *desc; |
4443 | struct ring_info *map, *src_map; | 4576 | struct ring_info *map; |
4444 | struct sk_buff *skb; | 4577 | struct sk_buff *skb; |
4445 | dma_addr_t mapping; | 4578 | dma_addr_t mapping; |
4446 | int skb_size, dest_idx; | 4579 | int skb_size, dest_idx; |
4447 | 4580 | ||
4448 | src_map = NULL; | ||
4449 | switch (opaque_key) { | 4581 | switch (opaque_key) { |
4450 | case RXD_OPAQUE_RING_STD: | 4582 | case RXD_OPAQUE_RING_STD: |
4451 | dest_idx = dest_idx_unmasked & tp->rx_std_ring_mask; | 4583 | dest_idx = dest_idx_unmasked & tp->rx_std_ring_mask; |
@@ -6087,7 +6219,8 @@ static void tg3_rx_prodring_free(struct tg3 *tp, | |||
6087 | tg3_rx_skb_free(tp, &tpr->rx_std_buffers[i], | 6219 | tg3_rx_skb_free(tp, &tpr->rx_std_buffers[i], |
6088 | tp->rx_pkt_map_sz); | 6220 | tp->rx_pkt_map_sz); |
6089 | 6221 | ||
6090 | if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { | 6222 | if ((tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) && |
6223 | !(tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) { | ||
6091 | for (i = 0; i <= tp->rx_jmb_ring_mask; i++) | 6224 | for (i = 0; i <= tp->rx_jmb_ring_mask; i++) |
6092 | tg3_rx_skb_free(tp, &tpr->rx_jmb_buffers[i], | 6225 | tg3_rx_skb_free(tp, &tpr->rx_jmb_buffers[i], |
6093 | TG3_RX_JMB_MAP_SZ); | 6226 | TG3_RX_JMB_MAP_SZ); |
@@ -6114,7 +6247,7 @@ static int tg3_rx_prodring_alloc(struct tg3 *tp, | |||
6114 | if (tpr != &tp->napi[0].prodring) { | 6247 | if (tpr != &tp->napi[0].prodring) { |
6115 | memset(&tpr->rx_std_buffers[0], 0, | 6248 | memset(&tpr->rx_std_buffers[0], 0, |
6116 | TG3_RX_STD_BUFF_RING_SIZE(tp)); | 6249 | TG3_RX_STD_BUFF_RING_SIZE(tp)); |
6117 | if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) | 6250 | if (tpr->rx_jmb_buffers) |
6118 | memset(&tpr->rx_jmb_buffers[0], 0, | 6251 | memset(&tpr->rx_jmb_buffers[0], 0, |
6119 | TG3_RX_JMB_BUFF_RING_SIZE(tp)); | 6252 | TG3_RX_JMB_BUFF_RING_SIZE(tp)); |
6120 | goto done; | 6253 | goto done; |
@@ -6157,7 +6290,8 @@ static int tg3_rx_prodring_alloc(struct tg3 *tp, | |||
6157 | } | 6290 | } |
6158 | } | 6291 | } |
6159 | 6292 | ||
6160 | if (!(tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE)) | 6293 | if (!(tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) || |
6294 | (tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) | ||
6161 | goto done; | 6295 | goto done; |
6162 | 6296 | ||
6163 | memset(tpr->rx_jmb, 0, TG3_RX_JMB_RING_BYTES(tp)); | 6297 | memset(tpr->rx_jmb, 0, TG3_RX_JMB_RING_BYTES(tp)); |
@@ -6229,7 +6363,8 @@ static int tg3_rx_prodring_init(struct tg3 *tp, | |||
6229 | if (!tpr->rx_std) | 6363 | if (!tpr->rx_std) |
6230 | goto err_out; | 6364 | goto err_out; |
6231 | 6365 | ||
6232 | if (tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) { | 6366 | if ((tp->tg3_flags & TG3_FLAG_JUMBO_CAPABLE) && |
6367 | !(tp->tg3_flags2 & TG3_FLG2_5780_CLASS)) { | ||
6233 | tpr->rx_jmb_buffers = kzalloc(TG3_RX_JMB_BUFF_RING_SIZE(tp), | 6368 | tpr->rx_jmb_buffers = kzalloc(TG3_RX_JMB_BUFF_RING_SIZE(tp), |
6234 | GFP_KERNEL); | 6369 | GFP_KERNEL); |
6235 | if (!tpr->rx_jmb_buffers) | 6370 | if (!tpr->rx_jmb_buffers) |
@@ -7536,6 +7671,9 @@ static void tg3_rings_reset(struct tg3 *tp) | |||
7536 | /* Disable all transmit rings but the first. */ | 7671 | /* Disable all transmit rings but the first. */ |
7537 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) | 7672 | if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) |
7538 | limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 16; | 7673 | limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 16; |
7674 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717 || | ||
7675 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719) | ||
7676 | limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 4; | ||
7539 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765) | 7677 | else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765) |
7540 | limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 2; | 7678 | limit = NIC_SRAM_SEND_RCB + TG3_BDINFO_SIZE * 2; |
7541 | else | 7679 | else |
@@ -7741,6 +7879,22 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy) | |||
7741 | tw32(TG3_CPMU_LSPD_10MB_CLK, val); | 7879 | tw32(TG3_CPMU_LSPD_10MB_CLK, val); |
7742 | } | 7880 | } |
7743 | 7881 | ||
7882 | /* Enable MAC control of LPI */ | ||
7883 | if (tp->phy_flags & TG3_PHYFLG_EEE_CAP) { | ||
7884 | tw32_f(TG3_CPMU_EEE_LNKIDL_CTRL, | ||
7885 | TG3_CPMU_EEE_LNKIDL_PCIE_NL0 | | ||
7886 | TG3_CPMU_EEE_LNKIDL_UART_IDL); | ||
7887 | |||
7888 | tw32_f(TG3_CPMU_EEE_CTRL, | ||
7889 | TG3_CPMU_EEE_CTRL_EXIT_20_1_US); | ||
7890 | |||
7891 | tw32_f(TG3_CPMU_EEE_MODE, | ||
7892 | TG3_CPMU_EEEMD_ERLY_L1_XIT_DET | | ||
7893 | TG3_CPMU_EEEMD_LPI_IN_TX | | ||
7894 | TG3_CPMU_EEEMD_LPI_IN_RX | | ||
7895 | TG3_CPMU_EEEMD_EEE_ENABLE); | ||
7896 | } | ||
7897 | |||
7744 | /* This works around an issue with Athlon chipsets on | 7898 | /* This works around an issue with Athlon chipsets on |
7745 | * B3 tigon3 silicon. This bit has no effect on any | 7899 | * B3 tigon3 silicon. This bit has no effect on any |
7746 | * other revision. But do not set this on PCI Express | 7900 | * other revision. But do not set this on PCI Express |
@@ -8549,6 +8703,12 @@ static void tg3_timer(unsigned long __opaque) | |||
8549 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) | 8703 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) |
8550 | tg3_periodic_fetch_stats(tp); | 8704 | tg3_periodic_fetch_stats(tp); |
8551 | 8705 | ||
8706 | if (tp->setlpicnt && !--tp->setlpicnt) { | ||
8707 | u32 val = tr32(TG3_CPMU_EEE_MODE); | ||
8708 | tw32(TG3_CPMU_EEE_MODE, | ||
8709 | val | TG3_CPMU_EEEMD_LPI_ENABLE); | ||
8710 | } | ||
8711 | |||
8552 | if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { | 8712 | if (tp->tg3_flags & TG3_FLAG_USE_LINKCHG_REG) { |
8553 | u32 mac_stat; | 8713 | u32 mac_stat; |
8554 | int phy_event; | 8714 | int phy_event; |
@@ -9647,6 +9807,9 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
9647 | if (netif_running(dev)) { | 9807 | if (netif_running(dev)) { |
9648 | cmd->speed = tp->link_config.active_speed; | 9808 | cmd->speed = tp->link_config.active_speed; |
9649 | cmd->duplex = tp->link_config.active_duplex; | 9809 | cmd->duplex = tp->link_config.active_duplex; |
9810 | } else { | ||
9811 | cmd->speed = SPEED_INVALID; | ||
9812 | cmd->duplex = DUPLEX_INVALID; | ||
9650 | } | 9813 | } |
9651 | cmd->phy_address = tp->phy_addr; | 9814 | cmd->phy_address = tp->phy_addr; |
9652 | cmd->transceiver = XCVR_INTERNAL; | 9815 | cmd->transceiver = XCVR_INTERNAL; |
@@ -12383,6 +12546,11 @@ static int __devinit tg3_phy_probe(struct tg3 *tp) | |||
12383 | } | 12546 | } |
12384 | } | 12547 | } |
12385 | 12548 | ||
12549 | if (tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 || | ||
12550 | (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 && | ||
12551 | tp->pci_chip_rev_id != CHIPREV_ID_57765_A0)) | ||
12552 | tp->phy_flags |= TG3_PHYFLG_EEE_CAP; | ||
12553 | |||
12386 | if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) && | 12554 | if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) && |
12387 | !(tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) && | 12555 | !(tp->tg3_flags3 & TG3_FLG3_ENABLE_APE) && |
12388 | !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) { | 12556 | !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) { |
@@ -12702,6 +12870,9 @@ static void __devinit tg3_read_sb_ver(struct tg3 *tp, u32 val) | |||
12702 | case TG3_EEPROM_SB_REVISION_5: | 12870 | case TG3_EEPROM_SB_REVISION_5: |
12703 | offset = TG3_EEPROM_SB_F1R5_EDH_OFF; | 12871 | offset = TG3_EEPROM_SB_F1R5_EDH_OFF; |
12704 | break; | 12872 | break; |
12873 | case TG3_EEPROM_SB_REVISION_6: | ||
12874 | offset = TG3_EEPROM_SB_F1R6_EDH_OFF; | ||
12875 | break; | ||
12705 | default: | 12876 | default: |
12706 | return; | 12877 | return; |
12707 | } | 12878 | } |
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index f6b709a3ca32..8342190df0ff 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -1091,7 +1091,26 @@ | |||
1091 | #define CPMU_MUTEX_GNT_DRIVER 0x00001000 | 1091 | #define CPMU_MUTEX_GNT_DRIVER 0x00001000 |
1092 | #define TG3_CPMU_PHY_STRAP 0x00003664 | 1092 | #define TG3_CPMU_PHY_STRAP 0x00003664 |
1093 | #define TG3_CPMU_PHY_STRAP_IS_SERDES 0x00000020 | 1093 | #define TG3_CPMU_PHY_STRAP_IS_SERDES 0x00000020 |
1094 | /* 0x3664 --> 0x3800 unused */ | 1094 | /* 0x3664 --> 0x36b0 unused */ |
1095 | |||
1096 | #define TG3_CPMU_EEE_MODE 0x000036b0 | ||
1097 | #define TG3_CPMU_EEEMD_ERLY_L1_XIT_DET 0x00000008 | ||
1098 | #define TG3_CPMU_EEEMD_LPI_ENABLE 0x00000080 | ||
1099 | #define TG3_CPMU_EEEMD_LPI_IN_TX 0x00000100 | ||
1100 | #define TG3_CPMU_EEEMD_LPI_IN_RX 0x00000200 | ||
1101 | #define TG3_CPMU_EEEMD_EEE_ENABLE 0x00100000 | ||
1102 | /* 0x36b4 --> 0x36b8 unused */ | ||
1103 | |||
1104 | #define TG3_CPMU_EEE_LNKIDL_CTRL 0x000036bc | ||
1105 | #define TG3_CPMU_EEE_LNKIDL_PCIE_NL0 0x01000000 | ||
1106 | #define TG3_CPMU_EEE_LNKIDL_UART_IDL 0x00000004 | ||
1107 | /* 0x36c0 --> 0x36d0 unused */ | ||
1108 | |||
1109 | #define TG3_CPMU_EEE_CTRL 0x000036d0 | ||
1110 | #define TG3_CPMU_EEE_CTRL_EXIT_16_5_US 0x0000019d | ||
1111 | #define TG3_CPMU_EEE_CTRL_EXIT_36_US 0x00000384 | ||
1112 | #define TG3_CPMU_EEE_CTRL_EXIT_20_1_US 0x000001f8 | ||
1113 | /* 0x36d4 --> 0x3800 unused */ | ||
1095 | 1114 | ||
1096 | /* Mbuf cluster free registers */ | 1115 | /* Mbuf cluster free registers */ |
1097 | #define MBFREE_MODE 0x00003800 | 1116 | #define MBFREE_MODE 0x00003800 |
@@ -1915,6 +1934,7 @@ | |||
1915 | #define TG3_EEPROM_SB_REVISION_3 0x00030000 | 1934 | #define TG3_EEPROM_SB_REVISION_3 0x00030000 |
1916 | #define TG3_EEPROM_SB_REVISION_4 0x00040000 | 1935 | #define TG3_EEPROM_SB_REVISION_4 0x00040000 |
1917 | #define TG3_EEPROM_SB_REVISION_5 0x00050000 | 1936 | #define TG3_EEPROM_SB_REVISION_5 0x00050000 |
1937 | #define TG3_EEPROM_SB_REVISION_6 0x00060000 | ||
1918 | #define TG3_EEPROM_MAGIC_HW 0xabcd | 1938 | #define TG3_EEPROM_MAGIC_HW 0xabcd |
1919 | #define TG3_EEPROM_MAGIC_HW_MSK 0xffff | 1939 | #define TG3_EEPROM_MAGIC_HW_MSK 0xffff |
1920 | 1940 | ||
@@ -1934,6 +1954,7 @@ | |||
1934 | #define TG3_EEPROM_SB_F1R3_EDH_OFF 0x18 | 1954 | #define TG3_EEPROM_SB_F1R3_EDH_OFF 0x18 |
1935 | #define TG3_EEPROM_SB_F1R4_EDH_OFF 0x1c | 1955 | #define TG3_EEPROM_SB_F1R4_EDH_OFF 0x1c |
1936 | #define TG3_EEPROM_SB_F1R5_EDH_OFF 0x20 | 1956 | #define TG3_EEPROM_SB_F1R5_EDH_OFF 0x20 |
1957 | #define TG3_EEPROM_SB_F1R6_EDH_OFF 0x4c | ||
1937 | #define TG3_EEPROM_SB_EDH_MAJ_MASK 0x00000700 | 1958 | #define TG3_EEPROM_SB_EDH_MAJ_MASK 0x00000700 |
1938 | #define TG3_EEPROM_SB_EDH_MAJ_SHFT 8 | 1959 | #define TG3_EEPROM_SB_EDH_MAJ_SHFT 8 |
1939 | #define TG3_EEPROM_SB_EDH_MIN_MASK 0x000000ff | 1960 | #define TG3_EEPROM_SB_EDH_MIN_MASK 0x000000ff |
@@ -2059,6 +2080,10 @@ | |||
2059 | #define MII_TG3_CTRL_AS_MASTER 0x0800 | 2080 | #define MII_TG3_CTRL_AS_MASTER 0x0800 |
2060 | #define MII_TG3_CTRL_ENABLE_AS_MASTER 0x1000 | 2081 | #define MII_TG3_CTRL_ENABLE_AS_MASTER 0x1000 |
2061 | 2082 | ||
2083 | #define MII_TG3_MMD_CTRL 0x0d /* MMD Access Control register */ | ||
2084 | #define MII_TG3_MMD_CTRL_DATA_NOINC 0x4000 | ||
2085 | #define MII_TG3_MMD_ADDRESS 0x0e /* MMD Address Data register */ | ||
2086 | |||
2062 | #define MII_TG3_EXT_CTRL 0x10 /* Extended control register */ | 2087 | #define MII_TG3_EXT_CTRL 0x10 /* Extended control register */ |
2063 | #define MII_TG3_EXT_CTRL_FIFO_ELASTIC 0x0001 | 2088 | #define MII_TG3_EXT_CTRL_FIFO_ELASTIC 0x0001 |
2064 | #define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002 | 2089 | #define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002 |
@@ -2076,6 +2101,8 @@ | |||
2076 | #define MII_TG3_DSP_TAP1 0x0001 | 2101 | #define MII_TG3_DSP_TAP1 0x0001 |
2077 | #define MII_TG3_DSP_TAP1_AGCTGT_DFLT 0x0007 | 2102 | #define MII_TG3_DSP_TAP1_AGCTGT_DFLT 0x0007 |
2078 | #define MII_TG3_DSP_AADJ1CH0 0x001f | 2103 | #define MII_TG3_DSP_AADJ1CH0 0x001f |
2104 | #define MII_TG3_DSP_CH34TP2 0x4022 | ||
2105 | #define MII_TG3_DSP_CH34TP2_HIBW01 0x0010 | ||
2079 | #define MII_TG3_DSP_AADJ1CH3 0x601f | 2106 | #define MII_TG3_DSP_AADJ1CH3 0x601f |
2080 | #define MII_TG3_DSP_AADJ1CH3_ADCCKADJ 0x0002 | 2107 | #define MII_TG3_DSP_AADJ1CH3_ADCCKADJ 0x0002 |
2081 | #define MII_TG3_DSP_EXP1_INT_STAT 0x0f01 | 2108 | #define MII_TG3_DSP_EXP1_INT_STAT 0x0f01 |
@@ -2142,6 +2169,14 @@ | |||
2142 | #define MII_TG3_TEST1_TRIM_EN 0x0010 | 2169 | #define MII_TG3_TEST1_TRIM_EN 0x0010 |
2143 | #define MII_TG3_TEST1_CRC_EN 0x8000 | 2170 | #define MII_TG3_TEST1_CRC_EN 0x8000 |
2144 | 2171 | ||
2172 | /* Clause 45 expansion registers */ | ||
2173 | #define TG3_CL45_D7_EEEADV_CAP 0x003c | ||
2174 | #define TG3_CL45_D7_EEEADV_CAP_100TX 0x0002 | ||
2175 | #define TG3_CL45_D7_EEEADV_CAP_1000T 0x0004 | ||
2176 | #define TG3_CL45_D7_EEERES_STAT 0x803e | ||
2177 | #define TG3_CL45_D7_EEERES_STAT_LP_100TX 0x0002 | ||
2178 | #define TG3_CL45_D7_EEERES_STAT_LP_1000T 0x0004 | ||
2179 | |||
2145 | 2180 | ||
2146 | /* Fast Ethernet Tranceiver definitions */ | 2181 | /* Fast Ethernet Tranceiver definitions */ |
2147 | #define MII_TG3_FET_PTEST 0x17 | 2182 | #define MII_TG3_FET_PTEST 0x17 |
@@ -2986,9 +3021,11 @@ struct tg3 { | |||
2986 | #define TG3_PHYFLG_BER_BUG 0x00008000 | 3021 | #define TG3_PHYFLG_BER_BUG 0x00008000 |
2987 | #define TG3_PHYFLG_SERDES_PREEMPHASIS 0x00010000 | 3022 | #define TG3_PHYFLG_SERDES_PREEMPHASIS 0x00010000 |
2988 | #define TG3_PHYFLG_PARALLEL_DETECT 0x00020000 | 3023 | #define TG3_PHYFLG_PARALLEL_DETECT 0x00020000 |
3024 | #define TG3_PHYFLG_EEE_CAP 0x00040000 | ||
2989 | 3025 | ||
2990 | u32 led_ctrl; | 3026 | u32 led_ctrl; |
2991 | u32 phy_otp; | 3027 | u32 phy_otp; |
3028 | u32 setlpicnt; | ||
2992 | 3029 | ||
2993 | #define TG3_BPN_SIZE 24 | 3030 | #define TG3_BPN_SIZE 24 |
2994 | char board_part_number[TG3_BPN_SIZE]; | 3031 | char board_part_number[TG3_BPN_SIZE]; |
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index 6884813b809c..f1995615dc84 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c | |||
@@ -312,13 +312,14 @@ VELOCITY_PARAM(flow_control, "Enable flow control ability"); | |||
312 | 312 | ||
313 | #define MED_LNK_DEF 0 | 313 | #define MED_LNK_DEF 0 |
314 | #define MED_LNK_MIN 0 | 314 | #define MED_LNK_MIN 0 |
315 | #define MED_LNK_MAX 4 | 315 | #define MED_LNK_MAX 5 |
316 | /* speed_duplex[] is used for setting the speed and duplex mode of NIC. | 316 | /* speed_duplex[] is used for setting the speed and duplex mode of NIC. |
317 | 0: indicate autonegotiation for both speed and duplex mode | 317 | 0: indicate autonegotiation for both speed and duplex mode |
318 | 1: indicate 100Mbps half duplex mode | 318 | 1: indicate 100Mbps half duplex mode |
319 | 2: indicate 100Mbps full duplex mode | 319 | 2: indicate 100Mbps full duplex mode |
320 | 3: indicate 10Mbps half duplex mode | 320 | 3: indicate 10Mbps half duplex mode |
321 | 4: indicate 10Mbps full duplex mode | 321 | 4: indicate 10Mbps full duplex mode |
322 | 5: indicate 1000Mbps full duplex mode | ||
322 | 323 | ||
323 | Note: | 324 | Note: |
324 | if EEPROM have been set to the force mode, this option is ignored | 325 | if EEPROM have been set to the force mode, this option is ignored |
@@ -617,6 +618,9 @@ static u32 velocity_get_opt_media_mode(struct velocity_info *vptr) | |||
617 | case SPD_DPX_10_HALF: | 618 | case SPD_DPX_10_HALF: |
618 | status = VELOCITY_SPEED_10; | 619 | status = VELOCITY_SPEED_10; |
619 | break; | 620 | break; |
621 | case SPD_DPX_1000_FULL: | ||
622 | status = VELOCITY_SPEED_1000 | VELOCITY_DUPLEX_FULL; | ||
623 | break; | ||
620 | } | 624 | } |
621 | vptr->mii_status = status; | 625 | vptr->mii_status = status; |
622 | return status; | 626 | return status; |
@@ -922,6 +926,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status) | |||
922 | /* enable AUTO-NEGO mode */ | 926 | /* enable AUTO-NEGO mode */ |
923 | mii_set_auto_on(vptr); | 927 | mii_set_auto_on(vptr); |
924 | } else { | 928 | } else { |
929 | u16 CTRL1000; | ||
925 | u16 ANAR; | 930 | u16 ANAR; |
926 | u8 CHIPGCR; | 931 | u8 CHIPGCR; |
927 | 932 | ||
@@ -936,7 +941,11 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status) | |||
936 | BYTE_REG_BITS_ON(CHIPGCR_FCMODE, ®s->CHIPGCR); | 941 | BYTE_REG_BITS_ON(CHIPGCR_FCMODE, ®s->CHIPGCR); |
937 | 942 | ||
938 | CHIPGCR = readb(®s->CHIPGCR); | 943 | CHIPGCR = readb(®s->CHIPGCR); |
939 | CHIPGCR &= ~CHIPGCR_FCGMII; | 944 | |
945 | if (mii_status & VELOCITY_SPEED_1000) | ||
946 | CHIPGCR |= CHIPGCR_FCGMII; | ||
947 | else | ||
948 | CHIPGCR &= ~CHIPGCR_FCGMII; | ||
940 | 949 | ||
941 | if (mii_status & VELOCITY_DUPLEX_FULL) { | 950 | if (mii_status & VELOCITY_DUPLEX_FULL) { |
942 | CHIPGCR |= CHIPGCR_FCFDX; | 951 | CHIPGCR |= CHIPGCR_FCFDX; |
@@ -952,7 +961,13 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status) | |||
952 | BYTE_REG_BITS_ON(TCR_TB2BDIS, ®s->TCR); | 961 | BYTE_REG_BITS_ON(TCR_TB2BDIS, ®s->TCR); |
953 | } | 962 | } |
954 | 963 | ||
955 | MII_REG_BITS_OFF(ADVERTISE_1000FULL | ADVERTISE_1000HALF, MII_CTRL1000, vptr->mac_regs); | 964 | velocity_mii_read(vptr->mac_regs, MII_CTRL1000, &CTRL1000); |
965 | CTRL1000 &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); | ||
966 | if ((mii_status & VELOCITY_SPEED_1000) && | ||
967 | (mii_status & VELOCITY_DUPLEX_FULL)) { | ||
968 | CTRL1000 |= ADVERTISE_1000FULL; | ||
969 | } | ||
970 | velocity_mii_write(vptr->mac_regs, MII_CTRL1000, CTRL1000); | ||
956 | 971 | ||
957 | if (!(mii_status & VELOCITY_DUPLEX_FULL) && (mii_status & VELOCITY_SPEED_10)) | 972 | if (!(mii_status & VELOCITY_DUPLEX_FULL) && (mii_status & VELOCITY_SPEED_10)) |
958 | BYTE_REG_BITS_OFF(TESTCFG_HBDIS, ®s->TESTCFG); | 973 | BYTE_REG_BITS_OFF(TESTCFG_HBDIS, ®s->TESTCFG); |
@@ -967,7 +982,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status) | |||
967 | ANAR |= ADVERTISE_100FULL; | 982 | ANAR |= ADVERTISE_100FULL; |
968 | else | 983 | else |
969 | ANAR |= ADVERTISE_100HALF; | 984 | ANAR |= ADVERTISE_100HALF; |
970 | } else { | 985 | } else if (mii_status & VELOCITY_SPEED_10) { |
971 | if (mii_status & VELOCITY_DUPLEX_FULL) | 986 | if (mii_status & VELOCITY_DUPLEX_FULL) |
972 | ANAR |= ADVERTISE_10FULL; | 987 | ANAR |= ADVERTISE_10FULL; |
973 | else | 988 | else |
@@ -1013,6 +1028,9 @@ static void velocity_print_link_status(struct velocity_info *vptr) | |||
1013 | } else { | 1028 | } else { |
1014 | VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link forced", vptr->dev->name); | 1029 | VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link forced", vptr->dev->name); |
1015 | switch (vptr->options.spd_dpx) { | 1030 | switch (vptr->options.spd_dpx) { |
1031 | case SPD_DPX_1000_FULL: | ||
1032 | VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps full duplex\n"); | ||
1033 | break; | ||
1016 | case SPD_DPX_100_HALF: | 1034 | case SPD_DPX_100_HALF: |
1017 | VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps half duplex\n"); | 1035 | VELOCITY_PRT(MSG_LEVEL_INFO, " speed 100M bps half duplex\n"); |
1018 | break; | 1036 | break; |
@@ -3170,6 +3188,37 @@ static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd | |||
3170 | SUPPORTED_100baseT_Full | | 3188 | SUPPORTED_100baseT_Full | |
3171 | SUPPORTED_1000baseT_Half | | 3189 | SUPPORTED_1000baseT_Half | |
3172 | SUPPORTED_1000baseT_Full; | 3190 | SUPPORTED_1000baseT_Full; |
3191 | |||
3192 | cmd->advertising = ADVERTISED_TP | ADVERTISED_Autoneg; | ||
3193 | if (vptr->options.spd_dpx == SPD_DPX_AUTO) { | ||
3194 | cmd->advertising |= | ||
3195 | ADVERTISED_10baseT_Half | | ||
3196 | ADVERTISED_10baseT_Full | | ||
3197 | ADVERTISED_100baseT_Half | | ||
3198 | ADVERTISED_100baseT_Full | | ||
3199 | ADVERTISED_1000baseT_Half | | ||
3200 | ADVERTISED_1000baseT_Full; | ||
3201 | } else { | ||
3202 | switch (vptr->options.spd_dpx) { | ||
3203 | case SPD_DPX_1000_FULL: | ||
3204 | cmd->advertising |= ADVERTISED_1000baseT_Full; | ||
3205 | break; | ||
3206 | case SPD_DPX_100_HALF: | ||
3207 | cmd->advertising |= ADVERTISED_100baseT_Half; | ||
3208 | break; | ||
3209 | case SPD_DPX_100_FULL: | ||
3210 | cmd->advertising |= ADVERTISED_100baseT_Full; | ||
3211 | break; | ||
3212 | case SPD_DPX_10_HALF: | ||
3213 | cmd->advertising |= ADVERTISED_10baseT_Half; | ||
3214 | break; | ||
3215 | case SPD_DPX_10_FULL: | ||
3216 | cmd->advertising |= ADVERTISED_10baseT_Full; | ||
3217 | break; | ||
3218 | default: | ||
3219 | break; | ||
3220 | } | ||
3221 | } | ||
3173 | if (status & VELOCITY_SPEED_1000) | 3222 | if (status & VELOCITY_SPEED_1000) |
3174 | cmd->speed = SPEED_1000; | 3223 | cmd->speed = SPEED_1000; |
3175 | else if (status & VELOCITY_SPEED_100) | 3224 | else if (status & VELOCITY_SPEED_100) |
@@ -3200,14 +3249,35 @@ static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd | |||
3200 | curr_status &= (~VELOCITY_LINK_FAIL); | 3249 | curr_status &= (~VELOCITY_LINK_FAIL); |
3201 | 3250 | ||
3202 | new_status |= ((cmd->autoneg) ? VELOCITY_AUTONEG_ENABLE : 0); | 3251 | new_status |= ((cmd->autoneg) ? VELOCITY_AUTONEG_ENABLE : 0); |
3252 | new_status |= ((cmd->speed == SPEED_1000) ? VELOCITY_SPEED_1000 : 0); | ||
3203 | new_status |= ((cmd->speed == SPEED_100) ? VELOCITY_SPEED_100 : 0); | 3253 | new_status |= ((cmd->speed == SPEED_100) ? VELOCITY_SPEED_100 : 0); |
3204 | new_status |= ((cmd->speed == SPEED_10) ? VELOCITY_SPEED_10 : 0); | 3254 | new_status |= ((cmd->speed == SPEED_10) ? VELOCITY_SPEED_10 : 0); |
3205 | new_status |= ((cmd->duplex == DUPLEX_FULL) ? VELOCITY_DUPLEX_FULL : 0); | 3255 | new_status |= ((cmd->duplex == DUPLEX_FULL) ? VELOCITY_DUPLEX_FULL : 0); |
3206 | 3256 | ||
3207 | if ((new_status & VELOCITY_AUTONEG_ENABLE) && (new_status != (curr_status | VELOCITY_AUTONEG_ENABLE))) | 3257 | if ((new_status & VELOCITY_AUTONEG_ENABLE) && |
3258 | (new_status != (curr_status | VELOCITY_AUTONEG_ENABLE))) { | ||
3208 | ret = -EINVAL; | 3259 | ret = -EINVAL; |
3209 | else | 3260 | } else { |
3261 | enum speed_opt spd_dpx; | ||
3262 | |||
3263 | if (new_status & VELOCITY_AUTONEG_ENABLE) | ||
3264 | spd_dpx = SPD_DPX_AUTO; | ||
3265 | else if ((new_status & VELOCITY_SPEED_1000) && | ||
3266 | (new_status & VELOCITY_DUPLEX_FULL)) { | ||
3267 | spd_dpx = SPD_DPX_1000_FULL; | ||
3268 | } else if (new_status & VELOCITY_SPEED_100) | ||
3269 | spd_dpx = (new_status & VELOCITY_DUPLEX_FULL) ? | ||
3270 | SPD_DPX_100_FULL : SPD_DPX_100_HALF; | ||
3271 | else if (new_status & VELOCITY_SPEED_10) | ||
3272 | spd_dpx = (new_status & VELOCITY_DUPLEX_FULL) ? | ||
3273 | SPD_DPX_10_FULL : SPD_DPX_10_HALF; | ||
3274 | else | ||
3275 | return -EOPNOTSUPP; | ||
3276 | |||
3277 | vptr->options.spd_dpx = spd_dpx; | ||
3278 | |||
3210 | velocity_set_media_mode(vptr, new_status); | 3279 | velocity_set_media_mode(vptr, new_status); |
3280 | } | ||
3211 | 3281 | ||
3212 | return ret; | 3282 | return ret; |
3213 | } | 3283 | } |
diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h index b5e120b0074b..aa2e69b9ff61 100644 --- a/drivers/net/via-velocity.h +++ b/drivers/net/via-velocity.h | |||
@@ -848,7 +848,7 @@ enum velocity_owner { | |||
848 | * Bits in CHIPGCR register | 848 | * Bits in CHIPGCR register |
849 | */ | 849 | */ |
850 | 850 | ||
851 | #define CHIPGCR_FCGMII 0x80 | 851 | #define CHIPGCR_FCGMII 0x80 /* enable GMII mode */ |
852 | #define CHIPGCR_FCFDX 0x40 | 852 | #define CHIPGCR_FCFDX 0x40 |
853 | #define CHIPGCR_FCRESV 0x20 | 853 | #define CHIPGCR_FCRESV 0x20 |
854 | #define CHIPGCR_FCMODE 0x10 | 854 | #define CHIPGCR_FCMODE 0x10 |
@@ -1390,7 +1390,8 @@ enum speed_opt { | |||
1390 | SPD_DPX_100_HALF = 1, | 1390 | SPD_DPX_100_HALF = 1, |
1391 | SPD_DPX_100_FULL = 2, | 1391 | SPD_DPX_100_FULL = 2, |
1392 | SPD_DPX_10_HALF = 3, | 1392 | SPD_DPX_10_HALF = 3, |
1393 | SPD_DPX_10_FULL = 4 | 1393 | SPD_DPX_10_FULL = 4, |
1394 | SPD_DPX_1000_FULL = 5 | ||
1394 | }; | 1395 | }; |
1395 | 1396 | ||
1396 | enum velocity_init_type { | 1397 | enum velocity_init_type { |
diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h index dba28268e651..8e20540043f5 100644 --- a/include/linux/can/platform/mcp251x.h +++ b/include/linux/can/platform/mcp251x.h | |||
@@ -12,7 +12,6 @@ | |||
12 | /** | 12 | /** |
13 | * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data | 13 | * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data |
14 | * @oscillator_frequency: - oscillator frequency in Hz | 14 | * @oscillator_frequency: - oscillator frequency in Hz |
15 | * @model: - actual type of chip | ||
16 | * @board_specific_setup: - called before probing the chip (power,reset) | 15 | * @board_specific_setup: - called before probing the chip (power,reset) |
17 | * @transceiver_enable: - called to power on/off the transceiver | 16 | * @transceiver_enable: - called to power on/off the transceiver |
18 | * @power_enable: - called to power on/off the mcp *and* the | 17 | * @power_enable: - called to power on/off the mcp *and* the |
@@ -25,9 +24,6 @@ | |||
25 | 24 | ||
26 | struct mcp251x_platform_data { | 25 | struct mcp251x_platform_data { |
27 | unsigned long oscillator_frequency; | 26 | unsigned long oscillator_frequency; |
28 | int model; | ||
29 | #define CAN_MCP251X_MCP2510 0x2510 | ||
30 | #define CAN_MCP251X_MCP2515 0x2515 | ||
31 | int (*board_specific_setup)(struct spi_device *spi); | 27 | int (*board_specific_setup)(struct spi_device *spi); |
32 | int (*transceiver_enable)(int enable); | 28 | int (*transceiver_enable)(int enable); |
33 | int (*power_enable) (int enable); | 29 | int (*power_enable) (int enable); |
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 50d8009be86c..79358bb712c6 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | struct netpoll { | 15 | struct netpoll { |
16 | struct net_device *dev; | 16 | struct net_device *dev; |
17 | struct net_device *real_dev; | ||
18 | char dev_name[IFNAMSIZ]; | 17 | char dev_name[IFNAMSIZ]; |
19 | const char *name; | 18 | const char *name; |
20 | void (*rx_hook)(struct netpoll *, int, char *, int); | 19 | void (*rx_hook)(struct netpoll *, int, char *, int); |
@@ -53,7 +52,13 @@ void netpoll_set_trap(int trap); | |||
53 | void __netpoll_cleanup(struct netpoll *np); | 52 | void __netpoll_cleanup(struct netpoll *np); |
54 | void netpoll_cleanup(struct netpoll *np); | 53 | void netpoll_cleanup(struct netpoll *np); |
55 | int __netpoll_rx(struct sk_buff *skb); | 54 | int __netpoll_rx(struct sk_buff *skb); |
56 | void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb); | 55 | void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, |
56 | struct net_device *dev); | ||
57 | static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) | ||
58 | { | ||
59 | netpoll_send_skb_on_dev(np, skb, np->dev); | ||
60 | } | ||
61 | |||
57 | 62 | ||
58 | 63 | ||
59 | #ifdef CONFIG_NETPOLL | 64 | #ifdef CONFIG_NETPOLL |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 0b53c43ac92e..05a358f1ba11 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -496,13 +496,13 @@ extern struct sk_buff *__alloc_skb(unsigned int size, | |||
496 | static inline struct sk_buff *alloc_skb(unsigned int size, | 496 | static inline struct sk_buff *alloc_skb(unsigned int size, |
497 | gfp_t priority) | 497 | gfp_t priority) |
498 | { | 498 | { |
499 | return __alloc_skb(size, priority, 0, -1); | 499 | return __alloc_skb(size, priority, 0, NUMA_NO_NODE); |
500 | } | 500 | } |
501 | 501 | ||
502 | static inline struct sk_buff *alloc_skb_fclone(unsigned int size, | 502 | static inline struct sk_buff *alloc_skb_fclone(unsigned int size, |
503 | gfp_t priority) | 503 | gfp_t priority) |
504 | { | 504 | { |
505 | return __alloc_skb(size, priority, 1, -1); | 505 | return __alloc_skb(size, priority, 1, NUMA_NO_NODE); |
506 | } | 506 | } |
507 | 507 | ||
508 | extern bool skb_recycle_check(struct sk_buff *skb, int skb_size); | 508 | extern bool skb_recycle_check(struct sk_buff *skb, int skb_size); |
@@ -1563,13 +1563,25 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, | |||
1563 | return skb; | 1563 | return skb; |
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | extern struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask); | 1566 | /** |
1567 | * __netdev_alloc_page - allocate a page for ps-rx on a specific device | ||
1568 | * @dev: network device to receive on | ||
1569 | * @gfp_mask: alloc_pages_node mask | ||
1570 | * | ||
1571 | * Allocate a new page. dev currently unused. | ||
1572 | * | ||
1573 | * %NULL is returned if there is no free memory. | ||
1574 | */ | ||
1575 | static inline struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask) | ||
1576 | { | ||
1577 | return alloc_pages_node(NUMA_NO_NODE, gfp_mask, 0); | ||
1578 | } | ||
1567 | 1579 | ||
1568 | /** | 1580 | /** |
1569 | * netdev_alloc_page - allocate a page for ps-rx on a specific device | 1581 | * netdev_alloc_page - allocate a page for ps-rx on a specific device |
1570 | * @dev: network device to receive on | 1582 | * @dev: network device to receive on |
1571 | * | 1583 | * |
1572 | * Allocate a new page node local to the specified device. | 1584 | * Allocate a new page. dev currently unused. |
1573 | * | 1585 | * |
1574 | * %NULL is returned if there is no free memory. | 1586 | * %NULL is returned if there is no free memory. |
1575 | */ | 1587 | */ |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index bd10a7908993..65af9a07cf76 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -41,6 +41,8 @@ struct net { | |||
41 | * destroy on demand | 41 | * destroy on demand |
42 | */ | 42 | */ |
43 | #endif | 43 | #endif |
44 | spinlock_t rules_mod_lock; | ||
45 | |||
44 | struct list_head list; /* list of network namespaces */ | 46 | struct list_head list; /* list of network namespaces */ |
45 | struct list_head cleanup_list; /* namespaces on death row */ | 47 | struct list_head cleanup_list; /* namespaces on death row */ |
46 | struct list_head exit_list; /* Use only net_mutex */ | 48 | struct list_head exit_list; /* Use only net_mutex */ |
@@ -52,7 +54,8 @@ struct net { | |||
52 | struct ctl_table_set sysctls; | 54 | struct ctl_table_set sysctls; |
53 | #endif | 55 | #endif |
54 | 56 | ||
55 | struct net_device *loopback_dev; /* The loopback */ | 57 | struct sock *rtnl; /* rtnetlink socket */ |
58 | struct sock *genl_sock; | ||
56 | 59 | ||
57 | struct list_head dev_base_head; | 60 | struct list_head dev_base_head; |
58 | struct hlist_head *dev_name_head; | 61 | struct hlist_head *dev_name_head; |
@@ -60,11 +63,9 @@ struct net { | |||
60 | 63 | ||
61 | /* core fib_rules */ | 64 | /* core fib_rules */ |
62 | struct list_head rules_ops; | 65 | struct list_head rules_ops; |
63 | spinlock_t rules_mod_lock; | ||
64 | 66 | ||
65 | struct sock *rtnl; /* rtnetlink socket */ | ||
66 | struct sock *genl_sock; | ||
67 | 67 | ||
68 | struct net_device *loopback_dev; /* The loopback */ | ||
68 | struct netns_core core; | 69 | struct netns_core core; |
69 | struct netns_mib mib; | 70 | struct netns_mib mib; |
70 | struct netns_packet packet; | 71 | struct netns_packet packet; |
@@ -84,13 +85,15 @@ struct net { | |||
84 | struct sock *nfnl; | 85 | struct sock *nfnl; |
85 | struct sock *nfnl_stash; | 86 | struct sock *nfnl_stash; |
86 | #endif | 87 | #endif |
87 | #ifdef CONFIG_XFRM | ||
88 | struct netns_xfrm xfrm; | ||
89 | #endif | ||
90 | #ifdef CONFIG_WEXT_CORE | 88 | #ifdef CONFIG_WEXT_CORE |
91 | struct sk_buff_head wext_nlevents; | 89 | struct sk_buff_head wext_nlevents; |
92 | #endif | 90 | #endif |
93 | struct net_generic *gen; | 91 | struct net_generic *gen; |
92 | |||
93 | /* Note : following structs are cache line aligned */ | ||
94 | #ifdef CONFIG_XFRM | ||
95 | struct netns_xfrm xfrm; | ||
96 | #endif | ||
94 | }; | 97 | }; |
95 | 98 | ||
96 | 99 | ||
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h index 74f119a2829a..748f91f87cd5 100644 --- a/include/net/netns/xfrm.h +++ b/include/net/netns/xfrm.h | |||
@@ -43,10 +43,6 @@ struct netns_xfrm { | |||
43 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; | 43 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; |
44 | struct work_struct policy_hash_work; | 44 | struct work_struct policy_hash_work; |
45 | 45 | ||
46 | struct dst_ops xfrm4_dst_ops; | ||
47 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
48 | struct dst_ops xfrm6_dst_ops; | ||
49 | #endif | ||
50 | 46 | ||
51 | struct sock *nlsk; | 47 | struct sock *nlsk; |
52 | struct sock *nlsk_stash; | 48 | struct sock *nlsk_stash; |
@@ -58,6 +54,11 @@ struct netns_xfrm { | |||
58 | #ifdef CONFIG_SYSCTL | 54 | #ifdef CONFIG_SYSCTL |
59 | struct ctl_table_header *sysctl_hdr; | 55 | struct ctl_table_header *sysctl_hdr; |
60 | #endif | 56 | #endif |
57 | |||
58 | struct dst_ops xfrm4_dst_ops; | ||
59 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
60 | struct dst_ops xfrm6_dst_ops; | ||
61 | #endif | ||
61 | }; | 62 | }; |
62 | 63 | ||
63 | #endif | 64 | #endif |
diff --git a/include/net/tipc/tipc.h b/include/net/tipc/tipc.h index 15af6dca0b49..1e0645e1eed2 100644 --- a/include/net/tipc/tipc.h +++ b/include/net/tipc/tipc.h | |||
@@ -50,8 +50,6 @@ | |||
50 | * TIPC operating mode routines | 50 | * TIPC operating mode routines |
51 | */ | 51 | */ |
52 | 52 | ||
53 | u32 tipc_get_addr(void); | ||
54 | |||
55 | #define TIPC_NOT_RUNNING 0 | 53 | #define TIPC_NOT_RUNNING 0 |
56 | #define TIPC_NODE_MODE 1 | 54 | #define TIPC_NODE_MODE 1 |
57 | #define TIPC_NET_MODE 2 | 55 | #define TIPC_NET_MODE 2 |
@@ -62,8 +60,6 @@ int tipc_attach(unsigned int *userref, tipc_mode_event, void *usr_handle); | |||
62 | 60 | ||
63 | void tipc_detach(unsigned int userref); | 61 | void tipc_detach(unsigned int userref); |
64 | 62 | ||
65 | int tipc_get_mode(void); | ||
66 | |||
67 | /* | 63 | /* |
68 | * TIPC port manipulation routines | 64 | * TIPC port manipulation routines |
69 | */ | 65 | */ |
@@ -153,12 +149,6 @@ int tipc_disconnect(u32 portref); | |||
153 | 149 | ||
154 | int tipc_shutdown(u32 ref); | 150 | int tipc_shutdown(u32 ref); |
155 | 151 | ||
156 | int tipc_isconnected(u32 portref, int *isconnected); | ||
157 | |||
158 | int tipc_peer(u32 portref, struct tipc_portid *peer); | ||
159 | |||
160 | int tipc_ref_valid(u32 portref); | ||
161 | |||
162 | /* | 152 | /* |
163 | * TIPC messaging routines | 153 | * TIPC messaging routines |
164 | */ | 154 | */ |
@@ -170,38 +160,12 @@ int tipc_send(u32 portref, | |||
170 | unsigned int num_sect, | 160 | unsigned int num_sect, |
171 | struct iovec const *msg_sect); | 161 | struct iovec const *msg_sect); |
172 | 162 | ||
173 | int tipc_send_buf(u32 portref, | ||
174 | struct sk_buff *buf, | ||
175 | unsigned int dsz); | ||
176 | |||
177 | int tipc_send2name(u32 portref, | 163 | int tipc_send2name(u32 portref, |
178 | struct tipc_name const *name, | 164 | struct tipc_name const *name, |
179 | u32 domain, | 165 | u32 domain, |
180 | unsigned int num_sect, | 166 | unsigned int num_sect, |
181 | struct iovec const *msg_sect); | 167 | struct iovec const *msg_sect); |
182 | 168 | ||
183 | int tipc_send_buf2name(u32 portref, | ||
184 | struct tipc_name const *name, | ||
185 | u32 domain, | ||
186 | struct sk_buff *buf, | ||
187 | unsigned int dsz); | ||
188 | |||
189 | int tipc_forward2name(u32 portref, | ||
190 | struct tipc_name const *name, | ||
191 | u32 domain, | ||
192 | unsigned int section_count, | ||
193 | struct iovec const *msg_sect, | ||
194 | struct tipc_portid const *origin, | ||
195 | unsigned int importance); | ||
196 | |||
197 | int tipc_forward_buf2name(u32 portref, | ||
198 | struct tipc_name const *name, | ||
199 | u32 domain, | ||
200 | struct sk_buff *buf, | ||
201 | unsigned int dsz, | ||
202 | struct tipc_portid const *orig, | ||
203 | unsigned int importance); | ||
204 | |||
205 | int tipc_send2port(u32 portref, | 169 | int tipc_send2port(u32 portref, |
206 | struct tipc_portid const *dest, | 170 | struct tipc_portid const *dest, |
207 | unsigned int num_sect, | 171 | unsigned int num_sect, |
@@ -212,46 +176,11 @@ int tipc_send_buf2port(u32 portref, | |||
212 | struct sk_buff *buf, | 176 | struct sk_buff *buf, |
213 | unsigned int dsz); | 177 | unsigned int dsz); |
214 | 178 | ||
215 | int tipc_forward2port(u32 portref, | ||
216 | struct tipc_portid const *dest, | ||
217 | unsigned int num_sect, | ||
218 | struct iovec const *msg_sect, | ||
219 | struct tipc_portid const *origin, | ||
220 | unsigned int importance); | ||
221 | |||
222 | int tipc_forward_buf2port(u32 portref, | ||
223 | struct tipc_portid const *dest, | ||
224 | struct sk_buff *buf, | ||
225 | unsigned int dsz, | ||
226 | struct tipc_portid const *orig, | ||
227 | unsigned int importance); | ||
228 | |||
229 | int tipc_multicast(u32 portref, | 179 | int tipc_multicast(u32 portref, |
230 | struct tipc_name_seq const *seq, | 180 | struct tipc_name_seq const *seq, |
231 | u32 domain, /* currently unused */ | 181 | u32 domain, /* currently unused */ |
232 | unsigned int section_count, | 182 | unsigned int section_count, |
233 | struct iovec const *msg); | 183 | struct iovec const *msg); |
234 | |||
235 | #if 0 | ||
236 | int tipc_multicast_buf(u32 portref, | ||
237 | struct tipc_name_seq const *seq, | ||
238 | u32 domain, | ||
239 | void *buf, | ||
240 | unsigned int size); | ||
241 | #endif | ||
242 | |||
243 | /* | ||
244 | * TIPC subscription routines | ||
245 | */ | ||
246 | |||
247 | int tipc_ispublished(struct tipc_name const *name); | ||
248 | |||
249 | /* | ||
250 | * Get number of available nodes within specified domain (excluding own node) | ||
251 | */ | ||
252 | |||
253 | unsigned int tipc_available_nodes(const u32 domain); | ||
254 | |||
255 | #endif | 184 | #endif |
256 | 185 | ||
257 | #endif | 186 | #endif |
diff --git a/include/net/tipc/tipc_port.h b/include/net/tipc/tipc_port.h index c54917cbfa48..1893aaf49426 100644 --- a/include/net/tipc/tipc_port.h +++ b/include/net/tipc/tipc_port.h | |||
@@ -88,8 +88,6 @@ void tipc_acknowledge(u32 port_ref,u32 ack); | |||
88 | 88 | ||
89 | struct tipc_port *tipc_get_port(const u32 ref); | 89 | struct tipc_port *tipc_get_port(const u32 ref); |
90 | 90 | ||
91 | void *tipc_get_handle(const u32 ref); | ||
92 | |||
93 | /* | 91 | /* |
94 | * The following routines require that the port be locked on entry | 92 | * The following routines require that the port be locked on entry |
95 | */ | 93 | */ |
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index 21698f8c49ee..1bc3f253ba6c 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -494,7 +494,6 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | |||
494 | } | 494 | } |
495 | } | 495 | } |
496 | 496 | ||
497 | synchronize_rcu(); | ||
498 | notify_rule_change(RTM_DELRULE, rule, ops, nlh, | 497 | notify_rule_change(RTM_DELRULE, rule, ops, nlh, |
499 | NETLINK_CB(skb).pid); | 498 | NETLINK_CB(skb).pid); |
500 | fib_rule_put(rule); | 499 | fib_rule_put(rule); |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 537e01afd81b..4e98ffac3af0 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -288,11 +288,11 @@ static int netpoll_owner_active(struct net_device *dev) | |||
288 | return 0; | 288 | return 0; |
289 | } | 289 | } |
290 | 290 | ||
291 | void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) | 291 | void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, |
292 | struct net_device *dev) | ||
292 | { | 293 | { |
293 | int status = NETDEV_TX_BUSY; | 294 | int status = NETDEV_TX_BUSY; |
294 | unsigned long tries; | 295 | unsigned long tries; |
295 | struct net_device *dev = np->dev; | ||
296 | const struct net_device_ops *ops = dev->netdev_ops; | 296 | const struct net_device_ops *ops = dev->netdev_ops; |
297 | /* It is up to the caller to keep npinfo alive. */ | 297 | /* It is up to the caller to keep npinfo alive. */ |
298 | struct netpoll_info *npinfo = np->dev->npinfo; | 298 | struct netpoll_info *npinfo = np->dev->npinfo; |
@@ -346,7 +346,7 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) | |||
346 | schedule_delayed_work(&npinfo->tx_work,0); | 346 | schedule_delayed_work(&npinfo->tx_work,0); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | EXPORT_SYMBOL(netpoll_send_skb); | 349 | EXPORT_SYMBOL(netpoll_send_skb_on_dev); |
350 | 350 | ||
351 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len) | 351 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len) |
352 | { | 352 | { |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 752c1972b3a7..4e8b82e167d8 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -247,10 +247,9 @@ EXPORT_SYMBOL(__alloc_skb); | |||
247 | struct sk_buff *__netdev_alloc_skb(struct net_device *dev, | 247 | struct sk_buff *__netdev_alloc_skb(struct net_device *dev, |
248 | unsigned int length, gfp_t gfp_mask) | 248 | unsigned int length, gfp_t gfp_mask) |
249 | { | 249 | { |
250 | int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1; | ||
251 | struct sk_buff *skb; | 250 | struct sk_buff *skb; |
252 | 251 | ||
253 | skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node); | 252 | skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, NUMA_NO_NODE); |
254 | if (likely(skb)) { | 253 | if (likely(skb)) { |
255 | skb_reserve(skb, NET_SKB_PAD); | 254 | skb_reserve(skb, NET_SKB_PAD); |
256 | skb->dev = dev; | 255 | skb->dev = dev; |
@@ -259,16 +258,6 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, | |||
259 | } | 258 | } |
260 | EXPORT_SYMBOL(__netdev_alloc_skb); | 259 | EXPORT_SYMBOL(__netdev_alloc_skb); |
261 | 260 | ||
262 | struct page *__netdev_alloc_page(struct net_device *dev, gfp_t gfp_mask) | ||
263 | { | ||
264 | int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1; | ||
265 | struct page *page; | ||
266 | |||
267 | page = alloc_pages_node(node, gfp_mask, 0); | ||
268 | return page; | ||
269 | } | ||
270 | EXPORT_SYMBOL(__netdev_alloc_page); | ||
271 | |||
272 | void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, | 261 | void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, |
273 | int size) | 262 | int size) |
274 | { | 263 | { |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index c2ff48fa18c7..dc94b0316b78 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -403,6 +403,9 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa) | |||
403 | return inet_insert_ifa(ifa); | 403 | return inet_insert_ifa(ifa); |
404 | } | 404 | } |
405 | 405 | ||
406 | /* Caller must hold RCU or RTNL : | ||
407 | * We dont take a reference on found in_device | ||
408 | */ | ||
406 | struct in_device *inetdev_by_index(struct net *net, int ifindex) | 409 | struct in_device *inetdev_by_index(struct net *net, int ifindex) |
407 | { | 410 | { |
408 | struct net_device *dev; | 411 | struct net_device *dev; |
@@ -411,7 +414,7 @@ struct in_device *inetdev_by_index(struct net *net, int ifindex) | |||
411 | rcu_read_lock(); | 414 | rcu_read_lock(); |
412 | dev = dev_get_by_index_rcu(net, ifindex); | 415 | dev = dev_get_by_index_rcu(net, ifindex); |
413 | if (dev) | 416 | if (dev) |
414 | in_dev = in_dev_get(dev); | 417 | in_dev = rcu_dereference_rtnl(dev->ip_ptr); |
415 | rcu_read_unlock(); | 418 | rcu_read_unlock(); |
416 | return in_dev; | 419 | return in_dev; |
417 | } | 420 | } |
@@ -453,8 +456,6 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg | |||
453 | goto errout; | 456 | goto errout; |
454 | } | 457 | } |
455 | 458 | ||
456 | __in_dev_put(in_dev); | ||
457 | |||
458 | for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL; | 459 | for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL; |
459 | ifap = &ifa->ifa_next) { | 460 | ifap = &ifa->ifa_next) { |
460 | if (tb[IFA_LOCAL] && | 461 | if (tb[IFA_LOCAL] && |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 919f2ad19b49..36e27c2107de 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -153,7 +153,7 @@ static void fib_flush(struct net *net) | |||
153 | * @addr: the source address | 153 | * @addr: the source address |
154 | * @devref: if true, take a reference on the found device | 154 | * @devref: if true, take a reference on the found device |
155 | * | 155 | * |
156 | * If a caller uses devref=false, it should be protected by RCU | 156 | * If a caller uses devref=false, it should be protected by RCU, or RTNL |
157 | */ | 157 | */ |
158 | struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref) | 158 | struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref) |
159 | { | 159 | { |
@@ -1016,16 +1016,15 @@ static struct notifier_block fib_netdev_notifier = { | |||
1016 | static int __net_init ip_fib_net_init(struct net *net) | 1016 | static int __net_init ip_fib_net_init(struct net *net) |
1017 | { | 1017 | { |
1018 | int err; | 1018 | int err; |
1019 | unsigned int i; | 1019 | size_t size = sizeof(struct hlist_head) * FIB_TABLE_HASHSZ; |
1020 | |||
1021 | /* Avoid false sharing : Use at least a full cache line */ | ||
1022 | size = max_t(size_t, size, L1_CACHE_BYTES); | ||
1020 | 1023 | ||
1021 | net->ipv4.fib_table_hash = kzalloc( | 1024 | net->ipv4.fib_table_hash = kzalloc(size, GFP_KERNEL); |
1022 | sizeof(struct hlist_head)*FIB_TABLE_HASHSZ, GFP_KERNEL); | ||
1023 | if (net->ipv4.fib_table_hash == NULL) | 1025 | if (net->ipv4.fib_table_hash == NULL) |
1024 | return -ENOMEM; | 1026 | return -ENOMEM; |
1025 | 1027 | ||
1026 | for (i = 0; i < FIB_TABLE_HASHSZ; i++) | ||
1027 | INIT_HLIST_HEAD(&net->ipv4.fib_table_hash[i]); | ||
1028 | |||
1029 | err = fib4_rules_init(net); | 1028 | err = fib4_rules_init(net); |
1030 | if (err < 0) | 1029 | if (err < 0) |
1031 | goto fail; | 1030 | goto fail; |
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c index 83cca68e259c..4f1aafd3ba89 100644 --- a/net/ipv4/fib_hash.c +++ b/net/ipv4/fib_hash.c | |||
@@ -54,36 +54,37 @@ struct fib_node { | |||
54 | struct fib_alias fn_embedded_alias; | 54 | struct fib_alias fn_embedded_alias; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | struct fn_zone { | 57 | #define EMBEDDED_HASH_SIZE (L1_CACHE_BYTES / sizeof(struct hlist_head)) |
58 | struct fn_zone *fz_next; /* Next not empty zone */ | ||
59 | struct hlist_head *fz_hash; /* Hash table pointer */ | ||
60 | int fz_nent; /* Number of entries */ | ||
61 | 58 | ||
62 | int fz_divisor; /* Hash divisor */ | 59 | struct fn_zone { |
60 | struct fn_zone __rcu *fz_next; /* Next not empty zone */ | ||
61 | struct hlist_head __rcu *fz_hash; /* Hash table pointer */ | ||
62 | seqlock_t fz_lock; | ||
63 | u32 fz_hashmask; /* (fz_divisor - 1) */ | 63 | u32 fz_hashmask; /* (fz_divisor - 1) */ |
64 | #define FZ_HASHMASK(fz) ((fz)->fz_hashmask) | ||
65 | 64 | ||
66 | int fz_order; /* Zone order */ | 65 | u8 fz_order; /* Zone order (0..32) */ |
67 | __be32 fz_mask; | 66 | u8 fz_revorder; /* 32 - fz_order */ |
67 | __be32 fz_mask; /* inet_make_mask(order) */ | ||
68 | #define FZ_MASK(fz) ((fz)->fz_mask) | 68 | #define FZ_MASK(fz) ((fz)->fz_mask) |
69 | }; | ||
70 | 69 | ||
71 | /* NOTE. On fast computers evaluation of fz_hashmask and fz_mask | 70 | struct hlist_head fz_embedded_hash[EMBEDDED_HASH_SIZE]; |
72 | * can be cheaper than memory lookup, so that FZ_* macros are used. | 71 | |
73 | */ | 72 | int fz_nent; /* Number of entries */ |
73 | int fz_divisor; /* Hash size (mask+1) */ | ||
74 | }; | ||
74 | 75 | ||
75 | struct fn_hash { | 76 | struct fn_hash { |
76 | struct fn_zone *fn_zones[33]; | 77 | struct fn_zone *fn_zones[33]; |
77 | struct fn_zone *fn_zone_list; | 78 | struct fn_zone __rcu *fn_zone_list; |
78 | }; | 79 | }; |
79 | 80 | ||
80 | static inline u32 fn_hash(__be32 key, struct fn_zone *fz) | 81 | static inline u32 fn_hash(__be32 key, struct fn_zone *fz) |
81 | { | 82 | { |
82 | u32 h = ntohl(key)>>(32 - fz->fz_order); | 83 | u32 h = ntohl(key) >> fz->fz_revorder; |
83 | h ^= (h>>20); | 84 | h ^= (h>>20); |
84 | h ^= (h>>10); | 85 | h ^= (h>>10); |
85 | h ^= (h>>5); | 86 | h ^= (h>>5); |
86 | h &= FZ_HASHMASK(fz); | 87 | h &= fz->fz_hashmask; |
87 | return h; | 88 | return h; |
88 | } | 89 | } |
89 | 90 | ||
@@ -92,7 +93,6 @@ static inline __be32 fz_key(__be32 dst, struct fn_zone *fz) | |||
92 | return dst & FZ_MASK(fz); | 93 | return dst & FZ_MASK(fz); |
93 | } | 94 | } |
94 | 95 | ||
95 | static DEFINE_RWLOCK(fib_hash_lock); | ||
96 | static unsigned int fib_hash_genid; | 96 | static unsigned int fib_hash_genid; |
97 | 97 | ||
98 | #define FZ_MAX_DIVISOR ((PAGE_SIZE<<MAX_ORDER) / sizeof(struct hlist_head)) | 98 | #define FZ_MAX_DIVISOR ((PAGE_SIZE<<MAX_ORDER) / sizeof(struct hlist_head)) |
@@ -101,12 +101,11 @@ static struct hlist_head *fz_hash_alloc(int divisor) | |||
101 | { | 101 | { |
102 | unsigned long size = divisor * sizeof(struct hlist_head); | 102 | unsigned long size = divisor * sizeof(struct hlist_head); |
103 | 103 | ||
104 | if (size <= PAGE_SIZE) { | 104 | if (size <= PAGE_SIZE) |
105 | return kzalloc(size, GFP_KERNEL); | 105 | return kzalloc(size, GFP_KERNEL); |
106 | } else { | 106 | |
107 | return (struct hlist_head *) | 107 | return (struct hlist_head *) |
108 | __get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(size)); | 108 | __get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(size)); |
109 | } | ||
110 | } | 109 | } |
111 | 110 | ||
112 | /* The fib hash lock must be held when this is called. */ | 111 | /* The fib hash lock must be held when this is called. */ |
@@ -121,12 +120,12 @@ static inline void fn_rebuild_zone(struct fn_zone *fz, | |||
121 | struct fib_node *f; | 120 | struct fib_node *f; |
122 | 121 | ||
123 | hlist_for_each_entry_safe(f, node, n, &old_ht[i], fn_hash) { | 122 | hlist_for_each_entry_safe(f, node, n, &old_ht[i], fn_hash) { |
124 | struct hlist_head *new_head; | 123 | struct hlist_head __rcu *new_head; |
125 | 124 | ||
126 | hlist_del(&f->fn_hash); | 125 | hlist_del_rcu(&f->fn_hash); |
127 | 126 | ||
128 | new_head = &fz->fz_hash[fn_hash(f->fn_key, fz)]; | 127 | new_head = &fz->fz_hash[fn_hash(f->fn_key, fz)]; |
129 | hlist_add_head(&f->fn_hash, new_head); | 128 | hlist_add_head_rcu(&f->fn_hash, new_head); |
130 | } | 129 | } |
131 | } | 130 | } |
132 | } | 131 | } |
@@ -147,14 +146,14 @@ static void fn_rehash_zone(struct fn_zone *fz) | |||
147 | int old_divisor, new_divisor; | 146 | int old_divisor, new_divisor; |
148 | u32 new_hashmask; | 147 | u32 new_hashmask; |
149 | 148 | ||
150 | old_divisor = fz->fz_divisor; | 149 | new_divisor = old_divisor = fz->fz_divisor; |
151 | 150 | ||
152 | switch (old_divisor) { | 151 | switch (old_divisor) { |
153 | case 16: | 152 | case EMBEDDED_HASH_SIZE: |
154 | new_divisor = 256; | 153 | new_divisor *= EMBEDDED_HASH_SIZE; |
155 | break; | 154 | break; |
156 | case 256: | 155 | case EMBEDDED_HASH_SIZE*EMBEDDED_HASH_SIZE: |
157 | new_divisor = 1024; | 156 | new_divisor *= (EMBEDDED_HASH_SIZE/2); |
158 | break; | 157 | break; |
159 | default: | 158 | default: |
160 | if ((old_divisor << 1) > FZ_MAX_DIVISOR) { | 159 | if ((old_divisor << 1) > FZ_MAX_DIVISOR) { |
@@ -175,31 +174,55 @@ static void fn_rehash_zone(struct fn_zone *fz) | |||
175 | ht = fz_hash_alloc(new_divisor); | 174 | ht = fz_hash_alloc(new_divisor); |
176 | 175 | ||
177 | if (ht) { | 176 | if (ht) { |
178 | write_lock_bh(&fib_hash_lock); | 177 | struct fn_zone nfz; |
178 | |||
179 | memcpy(&nfz, fz, sizeof(nfz)); | ||
180 | |||
181 | write_seqlock_bh(&fz->fz_lock); | ||
179 | old_ht = fz->fz_hash; | 182 | old_ht = fz->fz_hash; |
180 | fz->fz_hash = ht; | 183 | nfz.fz_hash = ht; |
184 | nfz.fz_hashmask = new_hashmask; | ||
185 | nfz.fz_divisor = new_divisor; | ||
186 | fn_rebuild_zone(&nfz, old_ht, old_divisor); | ||
187 | fib_hash_genid++; | ||
188 | rcu_assign_pointer(fz->fz_hash, ht); | ||
181 | fz->fz_hashmask = new_hashmask; | 189 | fz->fz_hashmask = new_hashmask; |
182 | fz->fz_divisor = new_divisor; | 190 | fz->fz_divisor = new_divisor; |
183 | fn_rebuild_zone(fz, old_ht, old_divisor); | 191 | write_sequnlock_bh(&fz->fz_lock); |
184 | fib_hash_genid++; | ||
185 | write_unlock_bh(&fib_hash_lock); | ||
186 | 192 | ||
187 | fz_hash_free(old_ht, old_divisor); | 193 | if (old_ht != fz->fz_embedded_hash) { |
194 | synchronize_rcu(); | ||
195 | fz_hash_free(old_ht, old_divisor); | ||
196 | } | ||
188 | } | 197 | } |
189 | } | 198 | } |
190 | 199 | ||
191 | static inline void fn_free_node(struct fib_node * f) | 200 | static void fn_free_node_rcu(struct rcu_head *head) |
192 | { | 201 | { |
202 | struct fib_node *f = container_of(head, struct fib_node, fn_embedded_alias.rcu); | ||
203 | |||
193 | kmem_cache_free(fn_hash_kmem, f); | 204 | kmem_cache_free(fn_hash_kmem, f); |
194 | } | 205 | } |
195 | 206 | ||
207 | static inline void fn_free_node(struct fib_node *f) | ||
208 | { | ||
209 | call_rcu(&f->fn_embedded_alias.rcu, fn_free_node_rcu); | ||
210 | } | ||
211 | |||
212 | static void fn_free_alias_rcu(struct rcu_head *head) | ||
213 | { | ||
214 | struct fib_alias *fa = container_of(head, struct fib_alias, rcu); | ||
215 | |||
216 | kmem_cache_free(fn_alias_kmem, fa); | ||
217 | } | ||
218 | |||
196 | static inline void fn_free_alias(struct fib_alias *fa, struct fib_node *f) | 219 | static inline void fn_free_alias(struct fib_alias *fa, struct fib_node *f) |
197 | { | 220 | { |
198 | fib_release_info(fa->fa_info); | 221 | fib_release_info(fa->fa_info); |
199 | if (fa == &f->fn_embedded_alias) | 222 | if (fa == &f->fn_embedded_alias) |
200 | fa->fa_info = NULL; | 223 | fa->fa_info = NULL; |
201 | else | 224 | else |
202 | kmem_cache_free(fn_alias_kmem, fa); | 225 | call_rcu(&fa->rcu, fn_free_alias_rcu); |
203 | } | 226 | } |
204 | 227 | ||
205 | static struct fn_zone * | 228 | static struct fn_zone * |
@@ -210,36 +233,30 @@ fn_new_zone(struct fn_hash *table, int z) | |||
210 | if (!fz) | 233 | if (!fz) |
211 | return NULL; | 234 | return NULL; |
212 | 235 | ||
213 | if (z) { | 236 | seqlock_init(&fz->fz_lock); |
214 | fz->fz_divisor = 16; | 237 | fz->fz_divisor = z ? EMBEDDED_HASH_SIZE : 1; |
215 | } else { | 238 | fz->fz_hashmask = fz->fz_divisor - 1; |
216 | fz->fz_divisor = 1; | 239 | fz->fz_hash = fz->fz_embedded_hash; |
217 | } | ||
218 | fz->fz_hashmask = (fz->fz_divisor - 1); | ||
219 | fz->fz_hash = fz_hash_alloc(fz->fz_divisor); | ||
220 | if (!fz->fz_hash) { | ||
221 | kfree(fz); | ||
222 | return NULL; | ||
223 | } | ||
224 | fz->fz_order = z; | 240 | fz->fz_order = z; |
241 | fz->fz_revorder = 32 - z; | ||
225 | fz->fz_mask = inet_make_mask(z); | 242 | fz->fz_mask = inet_make_mask(z); |
226 | 243 | ||
227 | /* Find the first not empty zone with more specific mask */ | 244 | /* Find the first not empty zone with more specific mask */ |
228 | for (i=z+1; i<=32; i++) | 245 | for (i = z + 1; i <= 32; i++) |
229 | if (table->fn_zones[i]) | 246 | if (table->fn_zones[i]) |
230 | break; | 247 | break; |
231 | write_lock_bh(&fib_hash_lock); | 248 | if (i > 32) { |
232 | if (i>32) { | ||
233 | /* No more specific masks, we are the first. */ | 249 | /* No more specific masks, we are the first. */ |
234 | fz->fz_next = table->fn_zone_list; | 250 | rcu_assign_pointer(fz->fz_next, |
235 | table->fn_zone_list = fz; | 251 | rtnl_dereference(table->fn_zone_list)); |
252 | rcu_assign_pointer(table->fn_zone_list, fz); | ||
236 | } else { | 253 | } else { |
237 | fz->fz_next = table->fn_zones[i]->fz_next; | 254 | rcu_assign_pointer(fz->fz_next, |
238 | table->fn_zones[i]->fz_next = fz; | 255 | rtnl_dereference(table->fn_zones[i]->fz_next)); |
256 | rcu_assign_pointer(table->fn_zones[i]->fz_next, fz); | ||
239 | } | 257 | } |
240 | table->fn_zones[z] = fz; | 258 | table->fn_zones[z] = fz; |
241 | fib_hash_genid++; | 259 | fib_hash_genid++; |
242 | write_unlock_bh(&fib_hash_lock); | ||
243 | return fz; | 260 | return fz; |
244 | } | 261 | } |
245 | 262 | ||
@@ -251,28 +268,36 @@ int fib_table_lookup(struct fib_table *tb, | |||
251 | struct fn_zone *fz; | 268 | struct fn_zone *fz; |
252 | struct fn_hash *t = (struct fn_hash *)tb->tb_data; | 269 | struct fn_hash *t = (struct fn_hash *)tb->tb_data; |
253 | 270 | ||
254 | read_lock(&fib_hash_lock); | 271 | rcu_read_lock(); |
255 | for (fz = t->fn_zone_list; fz; fz = fz->fz_next) { | 272 | for (fz = rcu_dereference(t->fn_zone_list); |
256 | struct hlist_head *head; | 273 | fz != NULL; |
274 | fz = rcu_dereference(fz->fz_next)) { | ||
275 | struct hlist_head __rcu *head; | ||
257 | struct hlist_node *node; | 276 | struct hlist_node *node; |
258 | struct fib_node *f; | 277 | struct fib_node *f; |
259 | __be32 k = fz_key(flp->fl4_dst, fz); | 278 | __be32 k; |
279 | unsigned int seq; | ||
260 | 280 | ||
261 | head = &fz->fz_hash[fn_hash(k, fz)]; | 281 | do { |
262 | hlist_for_each_entry(f, node, head, fn_hash) { | 282 | seq = read_seqbegin(&fz->fz_lock); |
263 | if (f->fn_key != k) | 283 | k = fz_key(flp->fl4_dst, fz); |
264 | continue; | ||
265 | 284 | ||
266 | err = fib_semantic_match(&f->fn_alias, | 285 | head = &fz->fz_hash[fn_hash(k, fz)]; |
286 | hlist_for_each_entry_rcu(f, node, head, fn_hash) { | ||
287 | if (f->fn_key != k) | ||
288 | continue; | ||
289 | |||
290 | err = fib_semantic_match(&f->fn_alias, | ||
267 | flp, res, | 291 | flp, res, |
268 | fz->fz_order, fib_flags); | 292 | fz->fz_order, fib_flags); |
269 | if (err <= 0) | 293 | if (err <= 0) |
270 | goto out; | 294 | goto out; |
271 | } | 295 | } |
296 | } while (read_seqretry(&fz->fz_lock, seq)); | ||
272 | } | 297 | } |
273 | err = 1; | 298 | err = 1; |
274 | out: | 299 | out: |
275 | read_unlock(&fib_hash_lock); | 300 | rcu_read_unlock(); |
276 | return err; | 301 | return err; |
277 | } | 302 | } |
278 | 303 | ||
@@ -294,11 +319,11 @@ void fib_table_select_default(struct fib_table *tb, | |||
294 | last_resort = NULL; | 319 | last_resort = NULL; |
295 | order = -1; | 320 | order = -1; |
296 | 321 | ||
297 | read_lock(&fib_hash_lock); | 322 | rcu_read_lock(); |
298 | hlist_for_each_entry(f, node, &fz->fz_hash[0], fn_hash) { | 323 | hlist_for_each_entry_rcu(f, node, &fz->fz_hash[0], fn_hash) { |
299 | struct fib_alias *fa; | 324 | struct fib_alias *fa; |
300 | 325 | ||
301 | list_for_each_entry(fa, &f->fn_alias, fa_list) { | 326 | list_for_each_entry_rcu(fa, &f->fn_alias, fa_list) { |
302 | struct fib_info *next_fi = fa->fa_info; | 327 | struct fib_info *next_fi = fa->fa_info; |
303 | 328 | ||
304 | if (fa->fa_scope != res->scope || | 329 | if (fa->fa_scope != res->scope || |
@@ -342,7 +367,7 @@ void fib_table_select_default(struct fib_table *tb, | |||
342 | fib_result_assign(res, last_resort); | 367 | fib_result_assign(res, last_resort); |
343 | tb->tb_default = last_idx; | 368 | tb->tb_default = last_idx; |
344 | out: | 369 | out: |
345 | read_unlock(&fib_hash_lock); | 370 | rcu_read_unlock(); |
346 | } | 371 | } |
347 | 372 | ||
348 | /* Insert node F to FZ. */ | 373 | /* Insert node F to FZ. */ |
@@ -350,7 +375,7 @@ static inline void fib_insert_node(struct fn_zone *fz, struct fib_node *f) | |||
350 | { | 375 | { |
351 | struct hlist_head *head = &fz->fz_hash[fn_hash(f->fn_key, fz)]; | 376 | struct hlist_head *head = &fz->fz_hash[fn_hash(f->fn_key, fz)]; |
352 | 377 | ||
353 | hlist_add_head(&f->fn_hash, head); | 378 | hlist_add_head_rcu(&f->fn_hash, head); |
354 | } | 379 | } |
355 | 380 | ||
356 | /* Return the node in FZ matching KEY. */ | 381 | /* Return the node in FZ matching KEY. */ |
@@ -360,7 +385,7 @@ static struct fib_node *fib_find_node(struct fn_zone *fz, __be32 key) | |||
360 | struct hlist_node *node; | 385 | struct hlist_node *node; |
361 | struct fib_node *f; | 386 | struct fib_node *f; |
362 | 387 | ||
363 | hlist_for_each_entry(f, node, head, fn_hash) { | 388 | hlist_for_each_entry_rcu(f, node, head, fn_hash) { |
364 | if (f->fn_key == key) | 389 | if (f->fn_key == key) |
365 | return f; | 390 | return f; |
366 | } | 391 | } |
@@ -368,6 +393,17 @@ static struct fib_node *fib_find_node(struct fn_zone *fz, __be32 key) | |||
368 | return NULL; | 393 | return NULL; |
369 | } | 394 | } |
370 | 395 | ||
396 | |||
397 | static struct fib_alias *fib_fast_alloc(struct fib_node *f) | ||
398 | { | ||
399 | struct fib_alias *fa = &f->fn_embedded_alias; | ||
400 | |||
401 | if (fa->fa_info != NULL) | ||
402 | fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL); | ||
403 | return fa; | ||
404 | } | ||
405 | |||
406 | /* Caller must hold RTNL. */ | ||
371 | int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) | 407 | int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) |
372 | { | 408 | { |
373 | struct fn_hash *table = (struct fn_hash *) tb->tb_data; | 409 | struct fn_hash *table = (struct fn_hash *) tb->tb_data; |
@@ -452,7 +488,6 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) | |||
452 | } | 488 | } |
453 | 489 | ||
454 | if (cfg->fc_nlflags & NLM_F_REPLACE) { | 490 | if (cfg->fc_nlflags & NLM_F_REPLACE) { |
455 | struct fib_info *fi_drop; | ||
456 | u8 state; | 491 | u8 state; |
457 | 492 | ||
458 | fa = fa_first; | 493 | fa = fa_first; |
@@ -461,21 +496,25 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) | |||
461 | err = 0; | 496 | err = 0; |
462 | goto out; | 497 | goto out; |
463 | } | 498 | } |
464 | write_lock_bh(&fib_hash_lock); | 499 | err = -ENOBUFS; |
465 | fi_drop = fa->fa_info; | 500 | new_fa = fib_fast_alloc(f); |
466 | fa->fa_info = fi; | 501 | if (new_fa == NULL) |
467 | fa->fa_type = cfg->fc_type; | 502 | goto out; |
468 | fa->fa_scope = cfg->fc_scope; | 503 | |
504 | new_fa->fa_tos = fa->fa_tos; | ||
505 | new_fa->fa_info = fi; | ||
506 | new_fa->fa_type = cfg->fc_type; | ||
507 | new_fa->fa_scope = cfg->fc_scope; | ||
469 | state = fa->fa_state; | 508 | state = fa->fa_state; |
470 | fa->fa_state &= ~FA_S_ACCESSED; | 509 | new_fa->fa_state = state & ~FA_S_ACCESSED; |
471 | fib_hash_genid++; | 510 | fib_hash_genid++; |
472 | write_unlock_bh(&fib_hash_lock); | 511 | list_replace_rcu(&fa->fa_list, &new_fa->fa_list); |
473 | 512 | ||
474 | fib_release_info(fi_drop); | 513 | fn_free_alias(fa, f); |
475 | if (state & FA_S_ACCESSED) | 514 | if (state & FA_S_ACCESSED) |
476 | rt_cache_flush(cfg->fc_nlinfo.nl_net, -1); | 515 | rt_cache_flush(cfg->fc_nlinfo.nl_net, -1); |
477 | rtmsg_fib(RTM_NEWROUTE, key, fa, cfg->fc_dst_len, tb->tb_id, | 516 | rtmsg_fib(RTM_NEWROUTE, key, new_fa, cfg->fc_dst_len, |
478 | &cfg->fc_nlinfo, NLM_F_REPLACE); | 517 | tb->tb_id, &cfg->fc_nlinfo, NLM_F_REPLACE); |
479 | return 0; | 518 | return 0; |
480 | } | 519 | } |
481 | 520 | ||
@@ -507,12 +546,10 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) | |||
507 | f = new_f; | 546 | f = new_f; |
508 | } | 547 | } |
509 | 548 | ||
510 | new_fa = &f->fn_embedded_alias; | 549 | new_fa = fib_fast_alloc(f); |
511 | if (new_fa->fa_info != NULL) { | 550 | if (new_fa == NULL) |
512 | new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL); | 551 | goto out; |
513 | if (new_fa == NULL) | 552 | |
514 | goto out; | ||
515 | } | ||
516 | new_fa->fa_info = fi; | 553 | new_fa->fa_info = fi; |
517 | new_fa->fa_tos = tos; | 554 | new_fa->fa_tos = tos; |
518 | new_fa->fa_type = cfg->fc_type; | 555 | new_fa->fa_type = cfg->fc_type; |
@@ -523,13 +560,11 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) | |||
523 | * Insert new entry to the list. | 560 | * Insert new entry to the list. |
524 | */ | 561 | */ |
525 | 562 | ||
526 | write_lock_bh(&fib_hash_lock); | ||
527 | if (new_f) | 563 | if (new_f) |
528 | fib_insert_node(fz, new_f); | 564 | fib_insert_node(fz, new_f); |
529 | list_add_tail(&new_fa->fa_list, | 565 | list_add_tail_rcu(&new_fa->fa_list, |
530 | (fa ? &fa->fa_list : &f->fn_alias)); | 566 | (fa ? &fa->fa_list : &f->fn_alias)); |
531 | fib_hash_genid++; | 567 | fib_hash_genid++; |
532 | write_unlock_bh(&fib_hash_lock); | ||
533 | 568 | ||
534 | if (new_f) | 569 | if (new_f) |
535 | fz->fz_nent++; | 570 | fz->fz_nent++; |
@@ -604,14 +639,12 @@ int fib_table_delete(struct fib_table *tb, struct fib_config *cfg) | |||
604 | tb->tb_id, &cfg->fc_nlinfo, 0); | 639 | tb->tb_id, &cfg->fc_nlinfo, 0); |
605 | 640 | ||
606 | kill_fn = 0; | 641 | kill_fn = 0; |
607 | write_lock_bh(&fib_hash_lock); | 642 | list_del_rcu(&fa->fa_list); |
608 | list_del(&fa->fa_list); | ||
609 | if (list_empty(&f->fn_alias)) { | 643 | if (list_empty(&f->fn_alias)) { |
610 | hlist_del(&f->fn_hash); | 644 | hlist_del_rcu(&f->fn_hash); |
611 | kill_fn = 1; | 645 | kill_fn = 1; |
612 | } | 646 | } |
613 | fib_hash_genid++; | 647 | fib_hash_genid++; |
614 | write_unlock_bh(&fib_hash_lock); | ||
615 | 648 | ||
616 | if (fa->fa_state & FA_S_ACCESSED) | 649 | if (fa->fa_state & FA_S_ACCESSED) |
617 | rt_cache_flush(cfg->fc_nlinfo.nl_net, -1); | 650 | rt_cache_flush(cfg->fc_nlinfo.nl_net, -1); |
@@ -642,14 +675,12 @@ static int fn_flush_list(struct fn_zone *fz, int idx) | |||
642 | struct fib_info *fi = fa->fa_info; | 675 | struct fib_info *fi = fa->fa_info; |
643 | 676 | ||
644 | if (fi && (fi->fib_flags&RTNH_F_DEAD)) { | 677 | if (fi && (fi->fib_flags&RTNH_F_DEAD)) { |
645 | write_lock_bh(&fib_hash_lock); | 678 | list_del_rcu(&fa->fa_list); |
646 | list_del(&fa->fa_list); | ||
647 | if (list_empty(&f->fn_alias)) { | 679 | if (list_empty(&f->fn_alias)) { |
648 | hlist_del(&f->fn_hash); | 680 | hlist_del_rcu(&f->fn_hash); |
649 | kill_f = 1; | 681 | kill_f = 1; |
650 | } | 682 | } |
651 | fib_hash_genid++; | 683 | fib_hash_genid++; |
652 | write_unlock_bh(&fib_hash_lock); | ||
653 | 684 | ||
654 | fn_free_alias(fa, f); | 685 | fn_free_alias(fa, f); |
655 | found++; | 686 | found++; |
@@ -663,13 +694,16 @@ static int fn_flush_list(struct fn_zone *fz, int idx) | |||
663 | return found; | 694 | return found; |
664 | } | 695 | } |
665 | 696 | ||
697 | /* caller must hold RTNL. */ | ||
666 | int fib_table_flush(struct fib_table *tb) | 698 | int fib_table_flush(struct fib_table *tb) |
667 | { | 699 | { |
668 | struct fn_hash *table = (struct fn_hash *) tb->tb_data; | 700 | struct fn_hash *table = (struct fn_hash *) tb->tb_data; |
669 | struct fn_zone *fz; | 701 | struct fn_zone *fz; |
670 | int found = 0; | 702 | int found = 0; |
671 | 703 | ||
672 | for (fz = table->fn_zone_list; fz; fz = fz->fz_next) { | 704 | for (fz = rtnl_dereference(table->fn_zone_list); |
705 | fz != NULL; | ||
706 | fz = rtnl_dereference(fz->fz_next)) { | ||
673 | int i; | 707 | int i; |
674 | 708 | ||
675 | for (i = fz->fz_divisor - 1; i >= 0; i--) | 709 | for (i = fz->fz_divisor - 1; i >= 0; i--) |
@@ -691,10 +725,10 @@ fn_hash_dump_bucket(struct sk_buff *skb, struct netlink_callback *cb, | |||
691 | 725 | ||
692 | s_i = cb->args[4]; | 726 | s_i = cb->args[4]; |
693 | i = 0; | 727 | i = 0; |
694 | hlist_for_each_entry(f, node, head, fn_hash) { | 728 | hlist_for_each_entry_rcu(f, node, head, fn_hash) { |
695 | struct fib_alias *fa; | 729 | struct fib_alias *fa; |
696 | 730 | ||
697 | list_for_each_entry(fa, &f->fn_alias, fa_list) { | 731 | list_for_each_entry_rcu(fa, &f->fn_alias, fa_list) { |
698 | if (i < s_i) | 732 | if (i < s_i) |
699 | goto next; | 733 | goto next; |
700 | 734 | ||
@@ -712,7 +746,7 @@ fn_hash_dump_bucket(struct sk_buff *skb, struct netlink_callback *cb, | |||
712 | cb->args[4] = i; | 746 | cb->args[4] = i; |
713 | return -1; | 747 | return -1; |
714 | } | 748 | } |
715 | next: | 749 | next: |
716 | i++; | 750 | i++; |
717 | } | 751 | } |
718 | } | 752 | } |
@@ -747,23 +781,26 @@ fn_hash_dump_zone(struct sk_buff *skb, struct netlink_callback *cb, | |||
747 | int fib_table_dump(struct fib_table *tb, struct sk_buff *skb, | 781 | int fib_table_dump(struct fib_table *tb, struct sk_buff *skb, |
748 | struct netlink_callback *cb) | 782 | struct netlink_callback *cb) |
749 | { | 783 | { |
750 | int m, s_m; | 784 | int m = 0, s_m; |
751 | struct fn_zone *fz; | 785 | struct fn_zone *fz; |
752 | struct fn_hash *table = (struct fn_hash *)tb->tb_data; | 786 | struct fn_hash *table = (struct fn_hash *)tb->tb_data; |
753 | 787 | ||
754 | s_m = cb->args[2]; | 788 | s_m = cb->args[2]; |
755 | read_lock(&fib_hash_lock); | 789 | rcu_read_lock(); |
756 | for (fz = table->fn_zone_list, m=0; fz; fz = fz->fz_next, m++) { | 790 | for (fz = rcu_dereference(table->fn_zone_list); |
757 | if (m < s_m) continue; | 791 | fz != NULL; |
792 | fz = rcu_dereference(fz->fz_next), m++) { | ||
793 | if (m < s_m) | ||
794 | continue; | ||
758 | if (fn_hash_dump_zone(skb, cb, tb, fz) < 0) { | 795 | if (fn_hash_dump_zone(skb, cb, tb, fz) < 0) { |
759 | cb->args[2] = m; | 796 | cb->args[2] = m; |
760 | read_unlock(&fib_hash_lock); | 797 | rcu_read_unlock(); |
761 | return -1; | 798 | return -1; |
762 | } | 799 | } |
763 | memset(&cb->args[3], 0, | 800 | memset(&cb->args[3], 0, |
764 | sizeof(cb->args) - 3*sizeof(cb->args[0])); | 801 | sizeof(cb->args) - 3*sizeof(cb->args[0])); |
765 | } | 802 | } |
766 | read_unlock(&fib_hash_lock); | 803 | rcu_read_unlock(); |
767 | cb->args[2] = m; | 804 | cb->args[2] = m; |
768 | return skb->len; | 805 | return skb->len; |
769 | } | 806 | } |
@@ -826,8 +863,9 @@ static struct fib_alias *fib_get_first(struct seq_file *seq) | |||
826 | iter->genid = fib_hash_genid; | 863 | iter->genid = fib_hash_genid; |
827 | iter->valid = 1; | 864 | iter->valid = 1; |
828 | 865 | ||
829 | for (iter->zone = table->fn_zone_list; iter->zone; | 866 | for (iter->zone = rcu_dereference(table->fn_zone_list); |
830 | iter->zone = iter->zone->fz_next) { | 867 | iter->zone != NULL; |
868 | iter->zone = rcu_dereference(iter->zone->fz_next)) { | ||
831 | int maxslot; | 869 | int maxslot; |
832 | 870 | ||
833 | if (!iter->zone->fz_nent) | 871 | if (!iter->zone->fz_nent) |
@@ -912,7 +950,7 @@ static struct fib_alias *fib_get_next(struct seq_file *seq) | |||
912 | } | 950 | } |
913 | } | 951 | } |
914 | 952 | ||
915 | iter->zone = iter->zone->fz_next; | 953 | iter->zone = rcu_dereference(iter->zone->fz_next); |
916 | 954 | ||
917 | if (!iter->zone) | 955 | if (!iter->zone) |
918 | goto out; | 956 | goto out; |
@@ -951,11 +989,11 @@ static struct fib_alias *fib_get_idx(struct seq_file *seq, loff_t pos) | |||
951 | } | 989 | } |
952 | 990 | ||
953 | static void *fib_seq_start(struct seq_file *seq, loff_t *pos) | 991 | static void *fib_seq_start(struct seq_file *seq, loff_t *pos) |
954 | __acquires(fib_hash_lock) | 992 | __acquires(RCU) |
955 | { | 993 | { |
956 | void *v = NULL; | 994 | void *v = NULL; |
957 | 995 | ||
958 | read_lock(&fib_hash_lock); | 996 | rcu_read_lock(); |
959 | if (fib_get_table(seq_file_net(seq), RT_TABLE_MAIN)) | 997 | if (fib_get_table(seq_file_net(seq), RT_TABLE_MAIN)) |
960 | v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; | 998 | v = *pos ? fib_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; |
961 | return v; | 999 | return v; |
@@ -968,15 +1006,16 @@ static void *fib_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
968 | } | 1006 | } |
969 | 1007 | ||
970 | static void fib_seq_stop(struct seq_file *seq, void *v) | 1008 | static void fib_seq_stop(struct seq_file *seq, void *v) |
971 | __releases(fib_hash_lock) | 1009 | __releases(RCU) |
972 | { | 1010 | { |
973 | read_unlock(&fib_hash_lock); | 1011 | rcu_read_unlock(); |
974 | } | 1012 | } |
975 | 1013 | ||
976 | static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi) | 1014 | static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi) |
977 | { | 1015 | { |
978 | static const unsigned type2flags[RTN_MAX + 1] = { | 1016 | static const unsigned type2flags[RTN_MAX + 1] = { |
979 | [7] = RTF_REJECT, [8] = RTF_REJECT, | 1017 | [7] = RTF_REJECT, |
1018 | [8] = RTF_REJECT, | ||
980 | }; | 1019 | }; |
981 | unsigned flags = type2flags[type]; | 1020 | unsigned flags = type2flags[type]; |
982 | 1021 | ||
diff --git a/net/ipv4/fib_lookup.h b/net/ipv4/fib_lookup.h index b9c9a9f2aee5..5072d8effd5d 100644 --- a/net/ipv4/fib_lookup.h +++ b/net/ipv4/fib_lookup.h | |||
@@ -12,9 +12,7 @@ struct fib_alias { | |||
12 | u8 fa_type; | 12 | u8 fa_type; |
13 | u8 fa_scope; | 13 | u8 fa_scope; |
14 | u8 fa_state; | 14 | u8 fa_state; |
15 | #ifdef CONFIG_IP_FIB_TRIE | ||
16 | struct rcu_head rcu; | 15 | struct rcu_head rcu; |
17 | #endif | ||
18 | }; | 16 | }; |
19 | 17 | ||
20 | #define FA_S_ACCESSED 0x01 | 18 | #define FA_S_ACCESSED 0x01 |
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 0f80dfc2f7fb..6734c9cab248 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -590,32 +590,29 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, | |||
590 | if (!dev) | 590 | if (!dev) |
591 | goto out; | 591 | goto out; |
592 | dev_hold(dev); | 592 | dev_hold(dev); |
593 | err = -ENETDOWN; | 593 | err = (dev->flags & IFF_UP) ? 0 : -ENETDOWN; |
594 | if (!(dev->flags & IFF_UP)) | ||
595 | goto out; | ||
596 | err = 0; | ||
597 | out: | ||
598 | rcu_read_unlock(); | ||
599 | return err; | ||
600 | } else { | 594 | } else { |
601 | struct in_device *in_dev; | 595 | struct in_device *in_dev; |
602 | 596 | ||
603 | if (nh->nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) | 597 | if (nh->nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) |
604 | return -EINVAL; | 598 | return -EINVAL; |
605 | 599 | ||
600 | rcu_read_lock(); | ||
601 | err = -ENODEV; | ||
606 | in_dev = inetdev_by_index(net, nh->nh_oif); | 602 | in_dev = inetdev_by_index(net, nh->nh_oif); |
607 | if (in_dev == NULL) | 603 | if (in_dev == NULL) |
608 | return -ENODEV; | 604 | goto out; |
609 | if (!(in_dev->dev->flags & IFF_UP)) { | 605 | err = -ENETDOWN; |
610 | in_dev_put(in_dev); | 606 | if (!(in_dev->dev->flags & IFF_UP)) |
611 | return -ENETDOWN; | 607 | goto out; |
612 | } | ||
613 | nh->nh_dev = in_dev->dev; | 608 | nh->nh_dev = in_dev->dev; |
614 | dev_hold(nh->nh_dev); | 609 | dev_hold(nh->nh_dev); |
615 | nh->nh_scope = RT_SCOPE_HOST; | 610 | nh->nh_scope = RT_SCOPE_HOST; |
616 | in_dev_put(in_dev); | 611 | err = 0; |
617 | } | 612 | } |
618 | return 0; | 613 | out: |
614 | rcu_read_unlock(); | ||
615 | return err; | ||
619 | } | 616 | } |
620 | 617 | ||
621 | static inline unsigned int fib_laddr_hashfn(__be32 val) | 618 | static inline unsigned int fib_laddr_hashfn(__be32 val) |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 271c89bdf049..31494f335686 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -1384,8 +1384,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, | |||
1384 | t_key cindex = 0; | 1384 | t_key cindex = 0; |
1385 | int current_prefix_length = KEYLENGTH; | 1385 | int current_prefix_length = KEYLENGTH; |
1386 | struct tnode *cn; | 1386 | struct tnode *cn; |
1387 | t_key node_prefix, key_prefix, pref_mismatch; | 1387 | t_key pref_mismatch; |
1388 | int mp; | ||
1389 | 1388 | ||
1390 | rcu_read_lock(); | 1389 | rcu_read_lock(); |
1391 | 1390 | ||
@@ -1500,10 +1499,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, | |||
1500 | * matching prefix. | 1499 | * matching prefix. |
1501 | */ | 1500 | */ |
1502 | 1501 | ||
1503 | node_prefix = mask_pfx(cn->key, cn->pos); | 1502 | pref_mismatch = mask_pfx(cn->key ^ key, cn->pos); |
1504 | key_prefix = mask_pfx(key, cn->pos); | ||
1505 | pref_mismatch = key_prefix^node_prefix; | ||
1506 | mp = 0; | ||
1507 | 1503 | ||
1508 | /* | 1504 | /* |
1509 | * In short: If skipped bits in this node do not match | 1505 | * In short: If skipped bits in this node do not match |
@@ -1511,13 +1507,9 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, | |||
1511 | * state.directly. | 1507 | * state.directly. |
1512 | */ | 1508 | */ |
1513 | if (pref_mismatch) { | 1509 | if (pref_mismatch) { |
1514 | while (!(pref_mismatch & (1<<(KEYLENGTH-1)))) { | 1510 | int mp = KEYLENGTH - fls(pref_mismatch); |
1515 | mp++; | ||
1516 | pref_mismatch = pref_mismatch << 1; | ||
1517 | } | ||
1518 | key_prefix = tkey_extract_bits(cn->key, mp, cn->pos-mp); | ||
1519 | 1511 | ||
1520 | if (key_prefix != 0) | 1512 | if (tkey_extract_bits(cn->key, mp, cn->pos - mp) != 0) |
1521 | goto backtrace; | 1513 | goto backtrace; |
1522 | 1514 | ||
1523 | if (current_prefix_length >= cn->pos) | 1515 | if (current_prefix_length >= cn->pos) |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 25f339672b28..c8877c6c7216 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -1418,6 +1418,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) | |||
1418 | write_unlock_bh(&in_dev->mc_list_lock); | 1418 | write_unlock_bh(&in_dev->mc_list_lock); |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | /* RTNL is locked */ | ||
1421 | static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) | 1422 | static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) |
1422 | { | 1423 | { |
1423 | struct flowi fl = { .nl_u = { .ip4_u = | 1424 | struct flowi fl = { .nl_u = { .ip4_u = |
@@ -1428,15 +1429,12 @@ static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) | |||
1428 | 1429 | ||
1429 | if (imr->imr_ifindex) { | 1430 | if (imr->imr_ifindex) { |
1430 | idev = inetdev_by_index(net, imr->imr_ifindex); | 1431 | idev = inetdev_by_index(net, imr->imr_ifindex); |
1431 | if (idev) | ||
1432 | __in_dev_put(idev); | ||
1433 | return idev; | 1432 | return idev; |
1434 | } | 1433 | } |
1435 | if (imr->imr_address.s_addr) { | 1434 | if (imr->imr_address.s_addr) { |
1436 | dev = ip_dev_find(net, imr->imr_address.s_addr); | 1435 | dev = __ip_dev_find(net, imr->imr_address.s_addr, false); |
1437 | if (!dev) | 1436 | if (!dev) |
1438 | return NULL; | 1437 | return NULL; |
1439 | dev_put(dev); | ||
1440 | } | 1438 | } |
1441 | 1439 | ||
1442 | if (!dev && !ip_route_output_key(net, &rt, &fl)) { | 1440 | if (!dev && !ip_route_output_key(net, &rt, &fl)) { |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 9d421f4cf3ef..d0ffcbe369b7 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -1245,10 +1245,8 @@ static int ipgre_close(struct net_device *dev) | |||
1245 | if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) { | 1245 | if (ipv4_is_multicast(t->parms.iph.daddr) && t->mlink) { |
1246 | struct in_device *in_dev; | 1246 | struct in_device *in_dev; |
1247 | in_dev = inetdev_by_index(dev_net(dev), t->mlink); | 1247 | in_dev = inetdev_by_index(dev_net(dev), t->mlink); |
1248 | if (in_dev) { | 1248 | if (in_dev) |
1249 | ip_mc_dec_group(in_dev, t->parms.iph.daddr); | 1249 | ip_mc_dec_group(in_dev, t->parms.iph.daddr); |
1250 | in_dev_put(in_dev); | ||
1251 | } | ||
1252 | } | 1250 | } |
1253 | return 0; | 1251 | return 0; |
1254 | } | 1252 | } |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 0755aa4af86c..ff98983d2a45 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2124,7 +2124,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
2124 | ipv4_is_loopback(saddr)) | 2124 | ipv4_is_loopback(saddr)) |
2125 | goto martian_source; | 2125 | goto martian_source; |
2126 | 2126 | ||
2127 | if (daddr == htonl(0xFFFFFFFF) || (saddr == 0 && daddr == 0)) | 2127 | if (ipv4_is_lbcast(daddr) || (saddr == 0 && daddr == 0)) |
2128 | goto brd_input; | 2128 | goto brd_input; |
2129 | 2129 | ||
2130 | /* Accept zero addresses only to limited broadcast; | 2130 | /* Accept zero addresses only to limited broadcast; |
@@ -2133,8 +2133,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
2133 | if (ipv4_is_zeronet(saddr)) | 2133 | if (ipv4_is_zeronet(saddr)) |
2134 | goto martian_source; | 2134 | goto martian_source; |
2135 | 2135 | ||
2136 | if (ipv4_is_lbcast(daddr) || ipv4_is_zeronet(daddr) || | 2136 | if (ipv4_is_zeronet(daddr) || ipv4_is_loopback(daddr)) |
2137 | ipv4_is_loopback(daddr)) | ||
2138 | goto martian_destination; | 2137 | goto martian_destination; |
2139 | 2138 | ||
2140 | /* | 2139 | /* |
@@ -2367,11 +2366,11 @@ static int __mkroute_output(struct rtable **result, | |||
2367 | if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags & IFF_LOOPBACK)) | 2366 | if (ipv4_is_loopback(fl->fl4_src) && !(dev_out->flags & IFF_LOOPBACK)) |
2368 | return -EINVAL; | 2367 | return -EINVAL; |
2369 | 2368 | ||
2370 | if (fl->fl4_dst == htonl(0xFFFFFFFF)) | 2369 | if (ipv4_is_lbcast(fl->fl4_dst)) |
2371 | res->type = RTN_BROADCAST; | 2370 | res->type = RTN_BROADCAST; |
2372 | else if (ipv4_is_multicast(fl->fl4_dst)) | 2371 | else if (ipv4_is_multicast(fl->fl4_dst)) |
2373 | res->type = RTN_MULTICAST; | 2372 | res->type = RTN_MULTICAST; |
2374 | else if (ipv4_is_lbcast(fl->fl4_dst) || ipv4_is_zeronet(fl->fl4_dst)) | 2373 | else if (ipv4_is_zeronet(fl->fl4_dst)) |
2375 | return -EINVAL; | 2374 | return -EINVAL; |
2376 | 2375 | ||
2377 | if (dev_out->flags & IFF_LOOPBACK) | 2376 | if (dev_out->flags & IFF_LOOPBACK) |
@@ -2530,7 +2529,7 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp, | |||
2530 | 2529 | ||
2531 | if (oldflp->oif == 0 && | 2530 | if (oldflp->oif == 0 && |
2532 | (ipv4_is_multicast(oldflp->fl4_dst) || | 2531 | (ipv4_is_multicast(oldflp->fl4_dst) || |
2533 | oldflp->fl4_dst == htonl(0xFFFFFFFF))) { | 2532 | ipv4_is_lbcast(oldflp->fl4_dst))) { |
2534 | /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ | 2533 | /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ |
2535 | dev_out = __ip_dev_find(net, oldflp->fl4_src, false); | 2534 | dev_out = __ip_dev_find(net, oldflp->fl4_src, false); |
2536 | if (dev_out == NULL) | 2535 | if (dev_out == NULL) |
@@ -2574,7 +2573,7 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp, | |||
2574 | goto out; /* Wrong error code */ | 2573 | goto out; /* Wrong error code */ |
2575 | 2574 | ||
2576 | if (ipv4_is_local_multicast(oldflp->fl4_dst) || | 2575 | if (ipv4_is_local_multicast(oldflp->fl4_dst) || |
2577 | oldflp->fl4_dst == htonl(0xFFFFFFFF)) { | 2576 | ipv4_is_lbcast(oldflp->fl4_dst)) { |
2578 | if (!fl.fl4_src) | 2577 | if (!fl.fl4_src) |
2579 | fl.fl4_src = inet_select_addr(dev_out, 0, | 2578 | fl.fl4_src = inet_select_addr(dev_out, 0, |
2580 | RT_SCOPE_LINK); | 2579 | RT_SCOPE_LINK); |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index e4fbdae066d5..ee0df4817498 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -2495,7 +2495,7 @@ static void tcp_timeout_skbs(struct sock *sk) | |||
2495 | /* Mark head of queue up as lost. With RFC3517 SACK, the packets is | 2495 | /* Mark head of queue up as lost. With RFC3517 SACK, the packets is |
2496 | * is against sacked "cnt", otherwise it's against facked "cnt" | 2496 | * is against sacked "cnt", otherwise it's against facked "cnt" |
2497 | */ | 2497 | */ |
2498 | static void tcp_mark_head_lost(struct sock *sk, int packets) | 2498 | static void tcp_mark_head_lost(struct sock *sk, int packets, int mark_head) |
2499 | { | 2499 | { |
2500 | struct tcp_sock *tp = tcp_sk(sk); | 2500 | struct tcp_sock *tp = tcp_sk(sk); |
2501 | struct sk_buff *skb; | 2501 | struct sk_buff *skb; |
@@ -2503,13 +2503,13 @@ static void tcp_mark_head_lost(struct sock *sk, int packets) | |||
2503 | int err; | 2503 | int err; |
2504 | unsigned int mss; | 2504 | unsigned int mss; |
2505 | 2505 | ||
2506 | if (packets == 0) | ||
2507 | return; | ||
2508 | |||
2509 | WARN_ON(packets > tp->packets_out); | 2506 | WARN_ON(packets > tp->packets_out); |
2510 | if (tp->lost_skb_hint) { | 2507 | if (tp->lost_skb_hint) { |
2511 | skb = tp->lost_skb_hint; | 2508 | skb = tp->lost_skb_hint; |
2512 | cnt = tp->lost_cnt_hint; | 2509 | cnt = tp->lost_cnt_hint; |
2510 | /* Head already handled? */ | ||
2511 | if (mark_head && skb != tcp_write_queue_head(sk)) | ||
2512 | return; | ||
2513 | } else { | 2513 | } else { |
2514 | skb = tcp_write_queue_head(sk); | 2514 | skb = tcp_write_queue_head(sk); |
2515 | cnt = 0; | 2515 | cnt = 0; |
@@ -2544,6 +2544,9 @@ static void tcp_mark_head_lost(struct sock *sk, int packets) | |||
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | tcp_skb_mark_lost(tp, skb); | 2546 | tcp_skb_mark_lost(tp, skb); |
2547 | |||
2548 | if (mark_head) | ||
2549 | break; | ||
2547 | } | 2550 | } |
2548 | tcp_verify_left_out(tp); | 2551 | tcp_verify_left_out(tp); |
2549 | } | 2552 | } |
@@ -2555,17 +2558,18 @@ static void tcp_update_scoreboard(struct sock *sk, int fast_rexmit) | |||
2555 | struct tcp_sock *tp = tcp_sk(sk); | 2558 | struct tcp_sock *tp = tcp_sk(sk); |
2556 | 2559 | ||
2557 | if (tcp_is_reno(tp)) { | 2560 | if (tcp_is_reno(tp)) { |
2558 | tcp_mark_head_lost(sk, 1); | 2561 | tcp_mark_head_lost(sk, 1, 1); |
2559 | } else if (tcp_is_fack(tp)) { | 2562 | } else if (tcp_is_fack(tp)) { |
2560 | int lost = tp->fackets_out - tp->reordering; | 2563 | int lost = tp->fackets_out - tp->reordering; |
2561 | if (lost <= 0) | 2564 | if (lost <= 0) |
2562 | lost = 1; | 2565 | lost = 1; |
2563 | tcp_mark_head_lost(sk, lost); | 2566 | tcp_mark_head_lost(sk, lost, 0); |
2564 | } else { | 2567 | } else { |
2565 | int sacked_upto = tp->sacked_out - tp->reordering; | 2568 | int sacked_upto = tp->sacked_out - tp->reordering; |
2566 | if (sacked_upto < fast_rexmit) | 2569 | if (sacked_upto >= 0) |
2567 | sacked_upto = fast_rexmit; | 2570 | tcp_mark_head_lost(sk, sacked_upto, 0); |
2568 | tcp_mark_head_lost(sk, sacked_upto); | 2571 | else if (fast_rexmit) |
2572 | tcp_mark_head_lost(sk, 1, 1); | ||
2569 | } | 2573 | } |
2570 | 2574 | ||
2571 | tcp_timeout_skbs(sk); | 2575 | tcp_timeout_skbs(sk); |
@@ -2971,7 +2975,7 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag) | |||
2971 | before(tp->snd_una, tp->high_seq) && | 2975 | before(tp->snd_una, tp->high_seq) && |
2972 | icsk->icsk_ca_state != TCP_CA_Open && | 2976 | icsk->icsk_ca_state != TCP_CA_Open && |
2973 | tp->fackets_out > tp->reordering) { | 2977 | tp->fackets_out > tp->reordering) { |
2974 | tcp_mark_head_lost(sk, tp->fackets_out - tp->reordering); | 2978 | tcp_mark_head_lost(sk, tp->fackets_out - tp->reordering, 0); |
2975 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPLOSS); | 2979 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPLOSS); |
2976 | } | 2980 | } |
2977 | 2981 | ||
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index f3c8c6c019ae..74a6aa003657 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -367,18 +367,19 @@ void tcp_retransmit_timer(struct sock *sk) | |||
367 | if (icsk->icsk_retransmits == 0) { | 367 | if (icsk->icsk_retransmits == 0) { |
368 | int mib_idx; | 368 | int mib_idx; |
369 | 369 | ||
370 | if (icsk->icsk_ca_state == TCP_CA_Disorder) { | 370 | if (icsk->icsk_ca_state == TCP_CA_Recovery) { |
371 | if (tcp_is_sack(tp)) | ||
372 | mib_idx = LINUX_MIB_TCPSACKFAILURES; | ||
373 | else | ||
374 | mib_idx = LINUX_MIB_TCPRENOFAILURES; | ||
375 | } else if (icsk->icsk_ca_state == TCP_CA_Recovery) { | ||
376 | if (tcp_is_sack(tp)) | 371 | if (tcp_is_sack(tp)) |
377 | mib_idx = LINUX_MIB_TCPSACKRECOVERYFAIL; | 372 | mib_idx = LINUX_MIB_TCPSACKRECOVERYFAIL; |
378 | else | 373 | else |
379 | mib_idx = LINUX_MIB_TCPRENORECOVERYFAIL; | 374 | mib_idx = LINUX_MIB_TCPRENORECOVERYFAIL; |
380 | } else if (icsk->icsk_ca_state == TCP_CA_Loss) { | 375 | } else if (icsk->icsk_ca_state == TCP_CA_Loss) { |
381 | mib_idx = LINUX_MIB_TCPLOSSFAILURES; | 376 | mib_idx = LINUX_MIB_TCPLOSSFAILURES; |
377 | } else if ((icsk->icsk_ca_state == TCP_CA_Disorder) || | ||
378 | tp->sacked_out) { | ||
379 | if (tcp_is_sack(tp)) | ||
380 | mib_idx = LINUX_MIB_TCPSACKFAILURES; | ||
381 | else | ||
382 | mib_idx = LINUX_MIB_TCPRENOFAILURES; | ||
382 | } else { | 383 | } else { |
383 | mib_idx = LINUX_MIB_TCPTIMEOUTS; | 384 | mib_idx = LINUX_MIB_TCPTIMEOUTS; |
384 | } | 385 | } |
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index b1108ede18e1..d829874d8946 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
@@ -34,11 +34,10 @@ struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl, | |||
34 | { | 34 | { |
35 | struct fib_lookup_arg arg = { | 35 | struct fib_lookup_arg arg = { |
36 | .lookup_ptr = lookup, | 36 | .lookup_ptr = lookup, |
37 | .flags = FIB_LOOKUP_NOREF, | ||
37 | }; | 38 | }; |
38 | 39 | ||
39 | fib_rules_lookup(net->ipv6.fib6_rules_ops, fl, flags, &arg); | 40 | fib_rules_lookup(net->ipv6.fib6_rules_ops, fl, flags, &arg); |
40 | if (arg.rule) | ||
41 | fib_rule_put(arg.rule); | ||
42 | 41 | ||
43 | if (arg.result) | 42 | if (arg.result) |
44 | return arg.result; | 43 | return arg.result; |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index b6a585909d35..de382114609b 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -1500,15 +1500,18 @@ static void fib6_gc_timer_cb(unsigned long arg) | |||
1500 | 1500 | ||
1501 | static int __net_init fib6_net_init(struct net *net) | 1501 | static int __net_init fib6_net_init(struct net *net) |
1502 | { | 1502 | { |
1503 | size_t size = sizeof(struct hlist_head) * FIB6_TABLE_HASHSZ; | ||
1504 | |||
1503 | setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); | 1505 | setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); |
1504 | 1506 | ||
1505 | net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL); | 1507 | net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL); |
1506 | if (!net->ipv6.rt6_stats) | 1508 | if (!net->ipv6.rt6_stats) |
1507 | goto out_timer; | 1509 | goto out_timer; |
1508 | 1510 | ||
1509 | net->ipv6.fib_table_hash = kcalloc(FIB6_TABLE_HASHSZ, | 1511 | /* Avoid false sharing : Use at least a full cache line */ |
1510 | sizeof(*net->ipv6.fib_table_hash), | 1512 | size = max_t(size_t, size, L1_CACHE_BYTES); |
1511 | GFP_KERNEL); | 1513 | |
1514 | net->ipv6.fib_table_hash = kzalloc(size, GFP_KERNEL); | ||
1512 | if (!net->ipv6.fib_table_hash) | 1515 | if (!net->ipv6.fib_table_hash) |
1513 | goto out_rt6_stats; | 1516 | goto out_rt6_stats; |
1514 | 1517 | ||
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 9c903f9e5079..3e60f2e4e6c2 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c | |||
@@ -300,7 +300,6 @@ static int pipe_handler_send_ind(struct sock *sk, u8 utid, u8 msg_id) | |||
300 | 300 | ||
301 | static int pipe_handler_enable_pipe(struct sock *sk, int enable) | 301 | static int pipe_handler_enable_pipe(struct sock *sk, int enable) |
302 | { | 302 | { |
303 | struct pep_sock *pn = pep_sk(sk); | ||
304 | int utid, req; | 303 | int utid, req; |
305 | 304 | ||
306 | if (enable) { | 305 | if (enable) { |
diff --git a/net/tipc/addr.c b/net/tipc/addr.c index 2ddc351b3be9..8a2e89bffde5 100644 --- a/net/tipc/addr.c +++ b/net/tipc/addr.c | |||
@@ -41,11 +41,6 @@ | |||
41 | #include "cluster.h" | 41 | #include "cluster.h" |
42 | #include "net.h" | 42 | #include "net.h" |
43 | 43 | ||
44 | u32 tipc_get_addr(void) | ||
45 | { | ||
46 | return tipc_own_addr; | ||
47 | } | ||
48 | |||
49 | /** | 44 | /** |
50 | * tipc_addr_domain_valid - validates a network domain address | 45 | * tipc_addr_domain_valid - validates a network domain address |
51 | * | 46 | * |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index ecfaac10d0b4..22a60fc98392 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -121,6 +121,9 @@ static DEFINE_SPINLOCK(bc_lock); | |||
121 | 121 | ||
122 | const char tipc_bclink_name[] = "broadcast-link"; | 122 | const char tipc_bclink_name[] = "broadcast-link"; |
123 | 123 | ||
124 | static void tipc_nmap_diff(struct tipc_node_map *nm_a, | ||
125 | struct tipc_node_map *nm_b, | ||
126 | struct tipc_node_map *nm_diff); | ||
124 | 127 | ||
125 | static u32 buf_seqno(struct sk_buff *buf) | 128 | static u32 buf_seqno(struct sk_buff *buf) |
126 | { | 129 | { |
@@ -287,7 +290,7 @@ static void bclink_send_nack(struct tipc_node *n_ptr) | |||
287 | if (!less(n_ptr->bclink.gap_after, n_ptr->bclink.gap_to)) | 290 | if (!less(n_ptr->bclink.gap_after, n_ptr->bclink.gap_to)) |
288 | return; | 291 | return; |
289 | 292 | ||
290 | buf = buf_acquire(INT_H_SIZE); | 293 | buf = tipc_buf_acquire(INT_H_SIZE); |
291 | if (buf) { | 294 | if (buf) { |
292 | msg = buf_msg(buf); | 295 | msg = buf_msg(buf); |
293 | tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, | 296 | tipc_msg_init(msg, BCAST_PROTOCOL, STATE_MSG, |
@@ -871,8 +874,9 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) | |||
871 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) | 874 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) |
872 | */ | 875 | */ |
873 | 876 | ||
874 | void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, | 877 | static void tipc_nmap_diff(struct tipc_node_map *nm_a, |
875 | struct tipc_node_map *nm_diff) | 878 | struct tipc_node_map *nm_b, |
879 | struct tipc_node_map *nm_diff) | ||
876 | { | 880 | { |
877 | int stop = ARRAY_SIZE(nm_a->map); | 881 | int stop = ARRAY_SIZE(nm_a->map); |
878 | int w; | 882 | int w; |
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index e8c2b81658c7..011c03f0a4ab 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
@@ -84,9 +84,6 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_m | |||
84 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); | 84 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); |
85 | } | 85 | } |
86 | 86 | ||
87 | void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, | ||
88 | struct tipc_node_map *nm_diff); | ||
89 | |||
90 | void tipc_port_list_add(struct port_list *pl_ptr, u32 port); | 87 | void tipc_port_list_add(struct port_list *pl_ptr, u32 port); |
91 | void tipc_port_list_free(struct port_list *pl_ptr); | 88 | void tipc_port_list_free(struct port_list *pl_ptr); |
92 | 89 | ||
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 9c10c6b7c12b..fd9c06c68281 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -288,9 +288,6 @@ static struct bearer *bearer_find(const char *name) | |||
288 | struct bearer *b_ptr; | 288 | struct bearer *b_ptr; |
289 | u32 i; | 289 | u32 i; |
290 | 290 | ||
291 | if (tipc_mode != TIPC_NET_MODE) | ||
292 | return NULL; | ||
293 | |||
294 | for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { | 291 | for (i = 0, b_ptr = tipc_bearers; i < MAX_BEARERS; i++, b_ptr++) { |
295 | if (b_ptr->active && (!strcmp(b_ptr->publ.name, name))) | 292 | if (b_ptr->active && (!strcmp(b_ptr->publ.name, name))) |
296 | return b_ptr; | 293 | return b_ptr; |
@@ -630,30 +627,17 @@ int tipc_block_bearer(const char *name) | |||
630 | * Note: This routine assumes caller holds tipc_net_lock. | 627 | * Note: This routine assumes caller holds tipc_net_lock. |
631 | */ | 628 | */ |
632 | 629 | ||
633 | static int bearer_disable(const char *name) | 630 | static int bearer_disable(struct bearer *b_ptr) |
634 | { | 631 | { |
635 | struct bearer *b_ptr; | ||
636 | struct link *l_ptr; | 632 | struct link *l_ptr; |
637 | struct link *temp_l_ptr; | 633 | struct link *temp_l_ptr; |
638 | 634 | ||
639 | b_ptr = bearer_find(name); | 635 | info("Disabling bearer <%s>\n", b_ptr->publ.name); |
640 | if (!b_ptr) { | ||
641 | warn("Attempt to disable unknown bearer <%s>\n", name); | ||
642 | return -EINVAL; | ||
643 | } | ||
644 | |||
645 | info("Disabling bearer <%s>\n", name); | ||
646 | tipc_disc_stop_link_req(b_ptr->link_req); | 636 | tipc_disc_stop_link_req(b_ptr->link_req); |
647 | spin_lock_bh(&b_ptr->publ.lock); | 637 | spin_lock_bh(&b_ptr->publ.lock); |
648 | b_ptr->link_req = NULL; | 638 | b_ptr->link_req = NULL; |
649 | b_ptr->publ.blocked = 1; | 639 | b_ptr->publ.blocked = 1; |
650 | if (b_ptr->media->disable_bearer) { | 640 | b_ptr->media->disable_bearer(&b_ptr->publ); |
651 | spin_unlock_bh(&b_ptr->publ.lock); | ||
652 | write_unlock_bh(&tipc_net_lock); | ||
653 | b_ptr->media->disable_bearer(&b_ptr->publ); | ||
654 | write_lock_bh(&tipc_net_lock); | ||
655 | spin_lock_bh(&b_ptr->publ.lock); | ||
656 | } | ||
657 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 641 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
658 | tipc_link_delete(l_ptr); | 642 | tipc_link_delete(l_ptr); |
659 | } | 643 | } |
@@ -664,10 +648,16 @@ static int bearer_disable(const char *name) | |||
664 | 648 | ||
665 | int tipc_disable_bearer(const char *name) | 649 | int tipc_disable_bearer(const char *name) |
666 | { | 650 | { |
651 | struct bearer *b_ptr; | ||
667 | int res; | 652 | int res; |
668 | 653 | ||
669 | write_lock_bh(&tipc_net_lock); | 654 | write_lock_bh(&tipc_net_lock); |
670 | res = bearer_disable(name); | 655 | b_ptr = bearer_find(name); |
656 | if (b_ptr == NULL) { | ||
657 | warn("Attempt to disable unknown bearer <%s>\n", name); | ||
658 | res = -EINVAL; | ||
659 | } else | ||
660 | res = bearer_disable(b_ptr); | ||
671 | write_unlock_bh(&tipc_net_lock); | 661 | write_unlock_bh(&tipc_net_lock); |
672 | return res; | 662 | return res; |
673 | } | 663 | } |
@@ -680,13 +670,7 @@ void tipc_bearer_stop(void) | |||
680 | 670 | ||
681 | for (i = 0; i < MAX_BEARERS; i++) { | 671 | for (i = 0; i < MAX_BEARERS; i++) { |
682 | if (tipc_bearers[i].active) | 672 | if (tipc_bearers[i].active) |
683 | tipc_bearers[i].publ.blocked = 1; | 673 | bearer_disable(&tipc_bearers[i]); |
684 | } | ||
685 | for (i = 0; i < MAX_BEARERS; i++) { | ||
686 | if (tipc_bearers[i].active) | ||
687 | bearer_disable(tipc_bearers[i].publ.name); | ||
688 | } | 674 | } |
689 | media_count = 0; | 675 | media_count = 0; |
690 | } | 676 | } |
691 | |||
692 | |||
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index e68f705381bc..7fea14b98b97 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
@@ -113,25 +113,6 @@ void tipc_cltr_delete(struct cluster *c_ptr) | |||
113 | kfree(c_ptr); | 113 | kfree(c_ptr); |
114 | } | 114 | } |
115 | 115 | ||
116 | u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr) | ||
117 | { | ||
118 | struct tipc_node *n_ptr; | ||
119 | u32 n_num = tipc_node(addr) + 1; | ||
120 | |||
121 | if (!c_ptr) | ||
122 | return addr; | ||
123 | for (; n_num <= c_ptr->highest_node; n_num++) { | ||
124 | n_ptr = c_ptr->nodes[n_num]; | ||
125 | if (n_ptr && tipc_node_has_active_links(n_ptr)) | ||
126 | return n_ptr->addr; | ||
127 | } | ||
128 | for (n_num = 1; n_num < tipc_node(addr); n_num++) { | ||
129 | n_ptr = c_ptr->nodes[n_num]; | ||
130 | if (n_ptr && tipc_node_has_active_links(n_ptr)) | ||
131 | return n_ptr->addr; | ||
132 | } | ||
133 | return 0; | ||
134 | } | ||
135 | 116 | ||
136 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr) | 117 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr) |
137 | { | 118 | { |
@@ -232,7 +213,7 @@ struct tipc_node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector) | |||
232 | static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest) | 213 | static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest) |
233 | { | 214 | { |
234 | u32 size = INT_H_SIZE + data_size; | 215 | u32 size = INT_H_SIZE + data_size; |
235 | struct sk_buff *buf = buf_acquire(size); | 216 | struct sk_buff *buf = tipc_buf_acquire(size); |
236 | struct tipc_msg *msg; | 217 | struct tipc_msg *msg; |
237 | 218 | ||
238 | if (buf) { | 219 | if (buf) { |
diff --git a/net/tipc/cluster.h b/net/tipc/cluster.h index 333efb0b9c44..32636d98c9c6 100644 --- a/net/tipc/cluster.h +++ b/net/tipc/cluster.h | |||
@@ -75,7 +75,7 @@ void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr); | |||
75 | void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest); | 75 | void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest); |
76 | void tipc_cltr_broadcast(struct sk_buff *buf); | 76 | void tipc_cltr_broadcast(struct sk_buff *buf); |
77 | int tipc_cltr_init(void); | 77 | int tipc_cltr_init(void); |
78 | u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr); | 78 | |
79 | void tipc_cltr_bcast_new_route(struct cluster *c_ptr, u32 dest, u32 lo, u32 hi); | 79 | void tipc_cltr_bcast_new_route(struct cluster *c_ptr, u32 dest, u32 lo, u32 hi); |
80 | void tipc_cltr_send_local_routes(struct cluster *c_ptr, u32 dest); | 80 | void tipc_cltr_send_local_routes(struct cluster *c_ptr, u32 dest); |
81 | void tipc_cltr_bcast_lost_route(struct cluster *c_ptr, u32 dest, u32 lo, u32 hi); | 81 | void tipc_cltr_bcast_lost_route(struct cluster *c_ptr, u32 dest, u32 lo, u32 hi); |
diff --git a/net/tipc/config.c b/net/tipc/config.c index c429b0d488a3..50a6133a3668 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -95,7 +95,7 @@ int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, | |||
95 | return 1; | 95 | return 1; |
96 | } | 96 | } |
97 | 97 | ||
98 | struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) | 98 | static struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) |
99 | { | 99 | { |
100 | struct sk_buff *buf; | 100 | struct sk_buff *buf; |
101 | __be32 value_net; | 101 | __be32 value_net; |
@@ -109,6 +109,11 @@ struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) | |||
109 | return buf; | 109 | return buf; |
110 | } | 110 | } |
111 | 111 | ||
112 | static struct sk_buff *tipc_cfg_reply_unsigned(u32 value) | ||
113 | { | ||
114 | return tipc_cfg_reply_unsigned_type(TIPC_TLV_UNSIGNED, value); | ||
115 | } | ||
116 | |||
112 | struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) | 117 | struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) |
113 | { | 118 | { |
114 | struct sk_buff *buf; | 119 | struct sk_buff *buf; |
diff --git a/net/tipc/config.h b/net/tipc/config.h index 5cd7cc56c54d..481e12ece715 100644 --- a/net/tipc/config.h +++ b/net/tipc/config.h | |||
@@ -45,7 +45,6 @@ | |||
45 | struct sk_buff *tipc_cfg_reply_alloc(int payload_size); | 45 | struct sk_buff *tipc_cfg_reply_alloc(int payload_size); |
46 | int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, | 46 | int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, |
47 | void *tlv_data, int tlv_data_size); | 47 | void *tlv_data, int tlv_data_size); |
48 | struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value); | ||
49 | struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string); | 48 | struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string); |
50 | 49 | ||
51 | static inline struct sk_buff *tipc_cfg_reply_none(void) | 50 | static inline struct sk_buff *tipc_cfg_reply_none(void) |
@@ -53,11 +52,6 @@ static inline struct sk_buff *tipc_cfg_reply_none(void) | |||
53 | return tipc_cfg_reply_alloc(0); | 52 | return tipc_cfg_reply_alloc(0); |
54 | } | 53 | } |
55 | 54 | ||
56 | static inline struct sk_buff *tipc_cfg_reply_unsigned(u32 value) | ||
57 | { | ||
58 | return tipc_cfg_reply_unsigned_type(TIPC_TLV_UNSIGNED, value); | ||
59 | } | ||
60 | |||
61 | static inline struct sk_buff *tipc_cfg_reply_error_string(char *string) | 55 | static inline struct sk_buff *tipc_cfg_reply_error_string(char *string) |
62 | { | 56 | { |
63 | return tipc_cfg_reply_string_type(TIPC_TLV_ERROR_STRING, string); | 57 | return tipc_cfg_reply_string_type(TIPC_TLV_ERROR_STRING, string); |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 466b861dab91..e2a09eb8efd4 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
@@ -96,13 +96,8 @@ int tipc_net_id; | |||
96 | int tipc_remote_management; | 96 | int tipc_remote_management; |
97 | 97 | ||
98 | 98 | ||
99 | int tipc_get_mode(void) | ||
100 | { | ||
101 | return tipc_mode; | ||
102 | } | ||
103 | |||
104 | /** | 99 | /** |
105 | * buf_acquire - creates a TIPC message buffer | 100 | * tipc_buf_acquire - creates a TIPC message buffer |
106 | * @size: message size (including TIPC header) | 101 | * @size: message size (including TIPC header) |
107 | * | 102 | * |
108 | * Returns a new buffer with data pointers set to the specified size. | 103 | * Returns a new buffer with data pointers set to the specified size. |
@@ -111,7 +106,7 @@ int tipc_get_mode(void) | |||
111 | * There may also be unrequested tailroom present at the buffer's end. | 106 | * There may also be unrequested tailroom present at the buffer's end. |
112 | */ | 107 | */ |
113 | 108 | ||
114 | struct sk_buff *buf_acquire(u32 size) | 109 | struct sk_buff *tipc_buf_acquire(u32 size) |
115 | { | 110 | { |
116 | struct sk_buff *skb; | 111 | struct sk_buff *skb; |
117 | unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u; | 112 | unsigned int buf_size = (BUF_HEADROOM + size + 3) & ~3u; |
@@ -129,7 +124,7 @@ struct sk_buff *buf_acquire(u32 size) | |||
129 | * tipc_core_stop_net - shut down TIPC networking sub-systems | 124 | * tipc_core_stop_net - shut down TIPC networking sub-systems |
130 | */ | 125 | */ |
131 | 126 | ||
132 | void tipc_core_stop_net(void) | 127 | static void tipc_core_stop_net(void) |
133 | { | 128 | { |
134 | tipc_eth_media_stop(); | 129 | tipc_eth_media_stop(); |
135 | tipc_net_stop(); | 130 | tipc_net_stop(); |
@@ -154,7 +149,7 @@ int tipc_core_start_net(unsigned long addr) | |||
154 | * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode | 149 | * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode |
155 | */ | 150 | */ |
156 | 151 | ||
157 | void tipc_core_stop(void) | 152 | static void tipc_core_stop(void) |
158 | { | 153 | { |
159 | if (tipc_mode != TIPC_NODE_MODE) | 154 | if (tipc_mode != TIPC_NODE_MODE) |
160 | return; | 155 | return; |
@@ -176,7 +171,7 @@ void tipc_core_stop(void) | |||
176 | * tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode | 171 | * tipc_core_start - switch TIPC from NOT RUNNING to SINGLE NODE mode |
177 | */ | 172 | */ |
178 | 173 | ||
179 | int tipc_core_start(void) | 174 | static int tipc_core_start(void) |
180 | { | 175 | { |
181 | int res; | 176 | int res; |
182 | 177 | ||
@@ -246,8 +241,6 @@ MODULE_VERSION(TIPC_MOD_VER); | |||
246 | 241 | ||
247 | EXPORT_SYMBOL(tipc_attach); | 242 | EXPORT_SYMBOL(tipc_attach); |
248 | EXPORT_SYMBOL(tipc_detach); | 243 | EXPORT_SYMBOL(tipc_detach); |
249 | EXPORT_SYMBOL(tipc_get_addr); | ||
250 | EXPORT_SYMBOL(tipc_get_mode); | ||
251 | EXPORT_SYMBOL(tipc_createport); | 244 | EXPORT_SYMBOL(tipc_createport); |
252 | EXPORT_SYMBOL(tipc_deleteport); | 245 | EXPORT_SYMBOL(tipc_deleteport); |
253 | EXPORT_SYMBOL(tipc_ownidentity); | 246 | EXPORT_SYMBOL(tipc_ownidentity); |
@@ -262,23 +255,10 @@ EXPORT_SYMBOL(tipc_withdraw); | |||
262 | EXPORT_SYMBOL(tipc_connect2port); | 255 | EXPORT_SYMBOL(tipc_connect2port); |
263 | EXPORT_SYMBOL(tipc_disconnect); | 256 | EXPORT_SYMBOL(tipc_disconnect); |
264 | EXPORT_SYMBOL(tipc_shutdown); | 257 | EXPORT_SYMBOL(tipc_shutdown); |
265 | EXPORT_SYMBOL(tipc_isconnected); | ||
266 | EXPORT_SYMBOL(tipc_peer); | ||
267 | EXPORT_SYMBOL(tipc_ref_valid); | ||
268 | EXPORT_SYMBOL(tipc_send); | 258 | EXPORT_SYMBOL(tipc_send); |
269 | EXPORT_SYMBOL(tipc_send_buf); | ||
270 | EXPORT_SYMBOL(tipc_send2name); | 259 | EXPORT_SYMBOL(tipc_send2name); |
271 | EXPORT_SYMBOL(tipc_forward2name); | ||
272 | EXPORT_SYMBOL(tipc_send_buf2name); | ||
273 | EXPORT_SYMBOL(tipc_forward_buf2name); | ||
274 | EXPORT_SYMBOL(tipc_send2port); | 260 | EXPORT_SYMBOL(tipc_send2port); |
275 | EXPORT_SYMBOL(tipc_forward2port); | ||
276 | EXPORT_SYMBOL(tipc_send_buf2port); | ||
277 | EXPORT_SYMBOL(tipc_forward_buf2port); | ||
278 | EXPORT_SYMBOL(tipc_multicast); | 261 | EXPORT_SYMBOL(tipc_multicast); |
279 | /* EXPORT_SYMBOL(tipc_multicast_buf); not available yet */ | ||
280 | EXPORT_SYMBOL(tipc_ispublished); | ||
281 | EXPORT_SYMBOL(tipc_available_nodes); | ||
282 | 262 | ||
283 | /* TIPC API for external bearers (see tipc_bearer.h) */ | 263 | /* TIPC API for external bearers (see tipc_bearer.h) */ |
284 | 264 | ||
@@ -295,6 +275,4 @@ EXPORT_SYMBOL(tipc_createport_raw); | |||
295 | EXPORT_SYMBOL(tipc_reject_msg); | 275 | EXPORT_SYMBOL(tipc_reject_msg); |
296 | EXPORT_SYMBOL(tipc_send_buf_fast); | 276 | EXPORT_SYMBOL(tipc_send_buf_fast); |
297 | EXPORT_SYMBOL(tipc_acknowledge); | 277 | EXPORT_SYMBOL(tipc_acknowledge); |
298 | EXPORT_SYMBOL(tipc_get_port); | ||
299 | EXPORT_SYMBOL(tipc_get_handle); | ||
300 | 278 | ||
diff --git a/net/tipc/core.h b/net/tipc/core.h index 188799017abd..e19389e57227 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -83,9 +83,7 @@ | |||
83 | * Note: TIPC_LOG is configured to echo its output to the system console; | 83 | * Note: TIPC_LOG is configured to echo its output to the system console; |
84 | * user-defined buffers can be configured to do the same thing. | 84 | * user-defined buffers can be configured to do the same thing. |
85 | */ | 85 | */ |
86 | |||
87 | extern struct print_buf *const TIPC_NULL; | 86 | extern struct print_buf *const TIPC_NULL; |
88 | extern struct print_buf *const TIPC_CONS; | ||
89 | extern struct print_buf *const TIPC_LOG; | 87 | extern struct print_buf *const TIPC_LOG; |
90 | 88 | ||
91 | void tipc_printf(struct print_buf *, const char *fmt, ...); | 89 | void tipc_printf(struct print_buf *, const char *fmt, ...); |
@@ -204,10 +202,7 @@ extern atomic_t tipc_user_count; | |||
204 | * Routines available to privileged subsystems | 202 | * Routines available to privileged subsystems |
205 | */ | 203 | */ |
206 | 204 | ||
207 | extern int tipc_core_start(void); | 205 | extern int tipc_core_start_net(unsigned long); |
208 | extern void tipc_core_stop(void); | ||
209 | extern int tipc_core_start_net(unsigned long addr); | ||
210 | extern void tipc_core_stop_net(void); | ||
211 | extern int tipc_handler_start(void); | 206 | extern int tipc_handler_start(void); |
212 | extern void tipc_handler_stop(void); | 207 | extern void tipc_handler_stop(void); |
213 | extern int tipc_netlink_start(void); | 208 | extern int tipc_netlink_start(void); |
@@ -328,7 +323,7 @@ static inline struct tipc_msg *buf_msg(struct sk_buff *skb) | |||
328 | return (struct tipc_msg *)skb->data; | 323 | return (struct tipc_msg *)skb->data; |
329 | } | 324 | } |
330 | 325 | ||
331 | extern struct sk_buff *buf_acquire(u32 size); | 326 | extern struct sk_buff *tipc_buf_acquire(u32 size); |
332 | 327 | ||
333 | /** | 328 | /** |
334 | * buf_discard - frees a TIPC message buffer | 329 | * buf_discard - frees a TIPC message buffer |
diff --git a/net/tipc/dbg.c b/net/tipc/dbg.c index 6569d45bfb9a..46f51d208e5e 100644 --- a/net/tipc/dbg.c +++ b/net/tipc/dbg.c | |||
@@ -52,7 +52,7 @@ static struct print_buf null_buf = { NULL, 0, NULL, 0 }; | |||
52 | struct print_buf *const TIPC_NULL = &null_buf; | 52 | struct print_buf *const TIPC_NULL = &null_buf; |
53 | 53 | ||
54 | static struct print_buf cons_buf = { NULL, 0, NULL, 1 }; | 54 | static struct print_buf cons_buf = { NULL, 0, NULL, 1 }; |
55 | struct print_buf *const TIPC_CONS = &cons_buf; | 55 | static struct print_buf *const TIPC_CONS = &cons_buf; |
56 | 56 | ||
57 | static struct print_buf log_buf = { NULL, 0, NULL, 1 }; | 57 | static struct print_buf log_buf = { NULL, 0, NULL, 1 }; |
58 | struct print_buf *const TIPC_LOG = &log_buf; | 58 | struct print_buf *const TIPC_LOG = &log_buf; |
@@ -76,6 +76,10 @@ struct print_buf *const TIPC_LOG = &log_buf; | |||
76 | static char print_string[TIPC_PB_MAX_STR]; | 76 | static char print_string[TIPC_PB_MAX_STR]; |
77 | static DEFINE_SPINLOCK(print_lock); | 77 | static DEFINE_SPINLOCK(print_lock); |
78 | 78 | ||
79 | static void tipc_printbuf_reset(struct print_buf *pb); | ||
80 | static int tipc_printbuf_empty(struct print_buf *pb); | ||
81 | static void tipc_printbuf_move(struct print_buf *pb_to, | ||
82 | struct print_buf *pb_from); | ||
79 | 83 | ||
80 | #define FORMAT(PTR,LEN,FMT) \ | 84 | #define FORMAT(PTR,LEN,FMT) \ |
81 | {\ | 85 | {\ |
@@ -116,7 +120,7 @@ void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size) | |||
116 | * @pb: pointer to print buffer structure | 120 | * @pb: pointer to print buffer structure |
117 | */ | 121 | */ |
118 | 122 | ||
119 | void tipc_printbuf_reset(struct print_buf *pb) | 123 | static void tipc_printbuf_reset(struct print_buf *pb) |
120 | { | 124 | { |
121 | if (pb->buf) { | 125 | if (pb->buf) { |
122 | pb->crs = pb->buf; | 126 | pb->crs = pb->buf; |
@@ -132,7 +136,7 @@ void tipc_printbuf_reset(struct print_buf *pb) | |||
132 | * Returns non-zero if print buffer is empty. | 136 | * Returns non-zero if print buffer is empty. |
133 | */ | 137 | */ |
134 | 138 | ||
135 | int tipc_printbuf_empty(struct print_buf *pb) | 139 | static int tipc_printbuf_empty(struct print_buf *pb) |
136 | { | 140 | { |
137 | return !pb->buf || (pb->crs == pb->buf); | 141 | return !pb->buf || (pb->crs == pb->buf); |
138 | } | 142 | } |
@@ -181,7 +185,8 @@ int tipc_printbuf_validate(struct print_buf *pb) | |||
181 | * Source print buffer becomes empty if a successful move occurs. | 185 | * Source print buffer becomes empty if a successful move occurs. |
182 | */ | 186 | */ |
183 | 187 | ||
184 | void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from) | 188 | static void tipc_printbuf_move(struct print_buf *pb_to, |
189 | struct print_buf *pb_from) | ||
185 | { | 190 | { |
186 | int len; | 191 | int len; |
187 | 192 | ||
diff --git a/net/tipc/dbg.h b/net/tipc/dbg.h index 5ef1bc8f64ef..3ba6ba8b434a 100644 --- a/net/tipc/dbg.h +++ b/net/tipc/dbg.h | |||
@@ -56,10 +56,7 @@ struct print_buf { | |||
56 | #define TIPC_PB_MAX_STR 512 /* max printable string (with trailing NUL) */ | 56 | #define TIPC_PB_MAX_STR 512 /* max printable string (with trailing NUL) */ |
57 | 57 | ||
58 | void tipc_printbuf_init(struct print_buf *pb, char *buf, u32 size); | 58 | void tipc_printbuf_init(struct print_buf *pb, char *buf, u32 size); |
59 | void tipc_printbuf_reset(struct print_buf *pb); | ||
60 | int tipc_printbuf_empty(struct print_buf *pb); | ||
61 | int tipc_printbuf_validate(struct print_buf *pb); | 59 | int tipc_printbuf_validate(struct print_buf *pb); |
62 | void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from); | ||
63 | 60 | ||
64 | int tipc_log_resize(int log_size); | 61 | int tipc_log_resize(int log_size); |
65 | 62 | ||
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index dbd79c67d7c0..4a7cd3719b78 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
@@ -68,20 +68,6 @@ struct link_req { | |||
68 | unsigned int timer_intv; | 68 | unsigned int timer_intv; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | |||
72 | /* | ||
73 | * disc_lost_link(): A link has lost contact | ||
74 | */ | ||
75 | |||
76 | void tipc_disc_link_event(u32 addr, char *name, int up) | ||
77 | { | ||
78 | if (in_own_cluster(addr)) | ||
79 | return; | ||
80 | /* | ||
81 | * Code for inter cluster link setup here | ||
82 | */ | ||
83 | } | ||
84 | |||
85 | /** | 71 | /** |
86 | * tipc_disc_init_msg - initialize a link setup message | 72 | * tipc_disc_init_msg - initialize a link setup message |
87 | * @type: message type (request or response) | 73 | * @type: message type (request or response) |
@@ -95,7 +81,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type, | |||
95 | u32 dest_domain, | 81 | u32 dest_domain, |
96 | struct bearer *b_ptr) | 82 | struct bearer *b_ptr) |
97 | { | 83 | { |
98 | struct sk_buff *buf = buf_acquire(DSC_H_SIZE); | 84 | struct sk_buff *buf = tipc_buf_acquire(DSC_H_SIZE); |
99 | struct tipc_msg *msg; | 85 | struct tipc_msg *msg; |
100 | 86 | ||
101 | if (buf) { | 87 | if (buf) { |
diff --git a/net/tipc/discover.h b/net/tipc/discover.h index 9d064c3639bf..f8e750636123 100644 --- a/net/tipc/discover.h +++ b/net/tipc/discover.h | |||
@@ -50,6 +50,4 @@ void tipc_disc_stop_link_req(struct link_req *req); | |||
50 | 50 | ||
51 | void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr); | 51 | void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr); |
52 | 52 | ||
53 | void tipc_disc_link_event(u32 addr, char *name, int up); | ||
54 | |||
55 | #endif | 53 | #endif |
diff --git a/net/tipc/link.c b/net/tipc/link.c index 4be78ecf4a67..b31992ccd5d3 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -112,6 +112,9 @@ static void link_state_event(struct link *l_ptr, u32 event); | |||
112 | static void link_reset_statistics(struct link *l_ptr); | 112 | static void link_reset_statistics(struct link *l_ptr); |
113 | static void link_print(struct link *l_ptr, struct print_buf *buf, | 113 | static void link_print(struct link *l_ptr, struct print_buf *buf, |
114 | const char *str); | 114 | const char *str); |
115 | static void link_start(struct link *l_ptr); | ||
116 | static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf); | ||
117 | |||
115 | 118 | ||
116 | /* | 119 | /* |
117 | * Debugging code used by link routines only | 120 | * Debugging code used by link routines only |
@@ -442,7 +445,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, | |||
442 | 445 | ||
443 | k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr); | 446 | k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr); |
444 | list_add_tail(&l_ptr->link_list, &b_ptr->links); | 447 | list_add_tail(&l_ptr->link_list, &b_ptr->links); |
445 | tipc_k_signal((Handler)tipc_link_start, (unsigned long)l_ptr); | 448 | tipc_k_signal((Handler)link_start, (unsigned long)l_ptr); |
446 | 449 | ||
447 | dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n", | 450 | dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n", |
448 | l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit); | 451 | l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit); |
@@ -482,9 +485,9 @@ void tipc_link_delete(struct link *l_ptr) | |||
482 | kfree(l_ptr); | 485 | kfree(l_ptr); |
483 | } | 486 | } |
484 | 487 | ||
485 | void tipc_link_start(struct link *l_ptr) | 488 | static void link_start(struct link *l_ptr) |
486 | { | 489 | { |
487 | dbg("tipc_link_start %x\n", l_ptr); | 490 | dbg("link_start %x\n", l_ptr); |
488 | link_state_event(l_ptr, STARTING_EVT); | 491 | link_state_event(l_ptr, STARTING_EVT); |
489 | } | 492 | } |
490 | 493 | ||
@@ -1000,7 +1003,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | |||
1000 | /* Fragmentation needed ? */ | 1003 | /* Fragmentation needed ? */ |
1001 | 1004 | ||
1002 | if (size > max_packet) | 1005 | if (size > max_packet) |
1003 | return tipc_link_send_long_buf(l_ptr, buf); | 1006 | return link_send_long_buf(l_ptr, buf); |
1004 | 1007 | ||
1005 | /* Packet can be queued or sent: */ | 1008 | /* Packet can be queued or sent: */ |
1006 | 1009 | ||
@@ -1036,7 +1039,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | |||
1036 | /* Try creating a new bundle */ | 1039 | /* Try creating a new bundle */ |
1037 | 1040 | ||
1038 | if (size <= max_packet * 2 / 3) { | 1041 | if (size <= max_packet * 2 / 3) { |
1039 | struct sk_buff *bundler = buf_acquire(max_packet); | 1042 | struct sk_buff *bundler = tipc_buf_acquire(max_packet); |
1040 | struct tipc_msg bundler_hdr; | 1043 | struct tipc_msg bundler_hdr; |
1041 | 1044 | ||
1042 | if (bundler) { | 1045 | if (bundler) { |
@@ -1312,7 +1315,7 @@ again: | |||
1312 | 1315 | ||
1313 | /* Prepare header of first fragment: */ | 1316 | /* Prepare header of first fragment: */ |
1314 | 1317 | ||
1315 | buf_chain = buf = buf_acquire(max_pkt); | 1318 | buf_chain = buf = tipc_buf_acquire(max_pkt); |
1316 | if (!buf) | 1319 | if (!buf) |
1317 | return -ENOMEM; | 1320 | return -ENOMEM; |
1318 | buf->next = NULL; | 1321 | buf->next = NULL; |
@@ -1369,7 +1372,7 @@ error: | |||
1369 | msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); | 1372 | msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); |
1370 | msg_set_fragm_no(&fragm_hdr, ++fragm_no); | 1373 | msg_set_fragm_no(&fragm_hdr, ++fragm_no); |
1371 | prev = buf; | 1374 | prev = buf; |
1372 | buf = buf_acquire(fragm_sz + INT_H_SIZE); | 1375 | buf = tipc_buf_acquire(fragm_sz + INT_H_SIZE); |
1373 | if (!buf) | 1376 | if (!buf) |
1374 | goto error; | 1377 | goto error; |
1375 | 1378 | ||
@@ -2145,7 +2148,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, | |||
2145 | if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { | 2148 | if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { |
2146 | if (!l_ptr->proto_msg_queue) { | 2149 | if (!l_ptr->proto_msg_queue) { |
2147 | l_ptr->proto_msg_queue = | 2150 | l_ptr->proto_msg_queue = |
2148 | buf_acquire(sizeof(l_ptr->proto_msg)); | 2151 | tipc_buf_acquire(sizeof(l_ptr->proto_msg)); |
2149 | } | 2152 | } |
2150 | buf = l_ptr->proto_msg_queue; | 2153 | buf = l_ptr->proto_msg_queue; |
2151 | if (!buf) | 2154 | if (!buf) |
@@ -2159,7 +2162,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, | |||
2159 | 2162 | ||
2160 | msg_dbg(msg, ">>"); | 2163 | msg_dbg(msg, ">>"); |
2161 | 2164 | ||
2162 | buf = buf_acquire(msg_size); | 2165 | buf = tipc_buf_acquire(msg_size); |
2163 | if (!buf) | 2166 | if (!buf) |
2164 | return; | 2167 | return; |
2165 | 2168 | ||
@@ -2318,10 +2321,10 @@ exit: | |||
2318 | * tipc_link_tunnel(): Send one message via a link belonging to | 2321 | * tipc_link_tunnel(): Send one message via a link belonging to |
2319 | * another bearer. Owner node is locked. | 2322 | * another bearer. Owner node is locked. |
2320 | */ | 2323 | */ |
2321 | void tipc_link_tunnel(struct link *l_ptr, | 2324 | static void tipc_link_tunnel(struct link *l_ptr, |
2322 | struct tipc_msg *tunnel_hdr, | 2325 | struct tipc_msg *tunnel_hdr, |
2323 | struct tipc_msg *msg, | 2326 | struct tipc_msg *msg, |
2324 | u32 selector) | 2327 | u32 selector) |
2325 | { | 2328 | { |
2326 | struct link *tunnel; | 2329 | struct link *tunnel; |
2327 | struct sk_buff *buf; | 2330 | struct sk_buff *buf; |
@@ -2334,7 +2337,7 @@ void tipc_link_tunnel(struct link *l_ptr, | |||
2334 | return; | 2337 | return; |
2335 | } | 2338 | } |
2336 | msg_set_size(tunnel_hdr, length + INT_H_SIZE); | 2339 | msg_set_size(tunnel_hdr, length + INT_H_SIZE); |
2337 | buf = buf_acquire(length + INT_H_SIZE); | 2340 | buf = tipc_buf_acquire(length + INT_H_SIZE); |
2338 | if (!buf) { | 2341 | if (!buf) { |
2339 | warn("Link changeover error, " | 2342 | warn("Link changeover error, " |
2340 | "unable to send tunnel msg\n"); | 2343 | "unable to send tunnel msg\n"); |
@@ -2380,7 +2383,7 @@ void tipc_link_changeover(struct link *l_ptr) | |||
2380 | if (!l_ptr->first_out) { | 2383 | if (!l_ptr->first_out) { |
2381 | struct sk_buff *buf; | 2384 | struct sk_buff *buf; |
2382 | 2385 | ||
2383 | buf = buf_acquire(INT_H_SIZE); | 2386 | buf = tipc_buf_acquire(INT_H_SIZE); |
2384 | if (buf) { | 2387 | if (buf) { |
2385 | skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE); | 2388 | skb_copy_to_linear_data(buf, &tunnel_hdr, INT_H_SIZE); |
2386 | msg_set_size(&tunnel_hdr, INT_H_SIZE); | 2389 | msg_set_size(&tunnel_hdr, INT_H_SIZE); |
@@ -2441,7 +2444,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel) | |||
2441 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */ | 2444 | msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */ |
2442 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); | 2445 | msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); |
2443 | msg_set_size(&tunnel_hdr, length + INT_H_SIZE); | 2446 | msg_set_size(&tunnel_hdr, length + INT_H_SIZE); |
2444 | outbuf = buf_acquire(length + INT_H_SIZE); | 2447 | outbuf = tipc_buf_acquire(length + INT_H_SIZE); |
2445 | if (outbuf == NULL) { | 2448 | if (outbuf == NULL) { |
2446 | warn("Link changeover error, " | 2449 | warn("Link changeover error, " |
2447 | "unable to send duplicate msg\n"); | 2450 | "unable to send duplicate msg\n"); |
@@ -2477,7 +2480,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) | |||
2477 | u32 size = msg_size(msg); | 2480 | u32 size = msg_size(msg); |
2478 | struct sk_buff *eb; | 2481 | struct sk_buff *eb; |
2479 | 2482 | ||
2480 | eb = buf_acquire(size); | 2483 | eb = tipc_buf_acquire(size); |
2481 | if (eb) | 2484 | if (eb) |
2482 | skb_copy_to_linear_data(eb, msg, size); | 2485 | skb_copy_to_linear_data(eb, msg, size); |
2483 | return eb; | 2486 | return eb; |
@@ -2605,11 +2608,11 @@ void tipc_link_recv_bundle(struct sk_buff *buf) | |||
2605 | 2608 | ||
2606 | 2609 | ||
2607 | /* | 2610 | /* |
2608 | * tipc_link_send_long_buf: Entry for buffers needing fragmentation. | 2611 | * link_send_long_buf: Entry for buffers needing fragmentation. |
2609 | * The buffer is complete, inclusive total message length. | 2612 | * The buffer is complete, inclusive total message length. |
2610 | * Returns user data length. | 2613 | * Returns user data length. |
2611 | */ | 2614 | */ |
2612 | int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) | 2615 | static int link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) |
2613 | { | 2616 | { |
2614 | struct tipc_msg *inmsg = buf_msg(buf); | 2617 | struct tipc_msg *inmsg = buf_msg(buf); |
2615 | struct tipc_msg fragm_hdr; | 2618 | struct tipc_msg fragm_hdr; |
@@ -2648,7 +2651,7 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) | |||
2648 | fragm_sz = rest; | 2651 | fragm_sz = rest; |
2649 | msg_set_type(&fragm_hdr, LAST_FRAGMENT); | 2652 | msg_set_type(&fragm_hdr, LAST_FRAGMENT); |
2650 | } | 2653 | } |
2651 | fragm = buf_acquire(fragm_sz + INT_H_SIZE); | 2654 | fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE); |
2652 | if (fragm == NULL) { | 2655 | if (fragm == NULL) { |
2653 | warn("Link unable to fragment message\n"); | 2656 | warn("Link unable to fragment message\n"); |
2654 | dsz = -ENOMEM; | 2657 | dsz = -ENOMEM; |
@@ -2753,7 +2756,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, | |||
2753 | buf_discard(fbuf); | 2756 | buf_discard(fbuf); |
2754 | return 0; | 2757 | return 0; |
2755 | } | 2758 | } |
2756 | pbuf = buf_acquire(msg_size(imsg)); | 2759 | pbuf = tipc_buf_acquire(msg_size(imsg)); |
2757 | if (pbuf != NULL) { | 2760 | if (pbuf != NULL) { |
2758 | pbuf->next = *pending; | 2761 | pbuf->next = *pending; |
2759 | *pending = pbuf; | 2762 | *pending = pbuf; |
diff --git a/net/tipc/link.h b/net/tipc/link.h index 4e944ef4a540..f98bc613de67 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
@@ -225,7 +225,6 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *dest); | |||
225 | void tipc_link_reset_fragments(struct link *l_ptr); | 225 | void tipc_link_reset_fragments(struct link *l_ptr); |
226 | int tipc_link_is_up(struct link *l_ptr); | 226 | int tipc_link_is_up(struct link *l_ptr); |
227 | int tipc_link_is_active(struct link *l_ptr); | 227 | int tipc_link_is_active(struct link *l_ptr); |
228 | void tipc_link_start(struct link *l_ptr); | ||
229 | u32 tipc_link_push_packet(struct link *l_ptr); | 228 | u32 tipc_link_push_packet(struct link *l_ptr); |
230 | void tipc_link_stop(struct link *l_ptr); | 229 | void tipc_link_stop(struct link *l_ptr); |
231 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, u16 cmd); | 230 | struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, u16 cmd); |
@@ -239,9 +238,6 @@ int tipc_link_send_sections_fast(struct port* sender, | |||
239 | struct iovec const *msg_sect, | 238 | struct iovec const *msg_sect, |
240 | const u32 num_sect, | 239 | const u32 num_sect, |
241 | u32 destnode); | 240 | u32 destnode); |
242 | int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf); | ||
243 | void tipc_link_tunnel(struct link *l_ptr, struct tipc_msg *tnl_hdr, | ||
244 | struct tipc_msg *msg, u32 selector); | ||
245 | void tipc_link_recv_bundle(struct sk_buff *buf); | 241 | void tipc_link_recv_bundle(struct sk_buff *buf); |
246 | int tipc_link_recv_fragment(struct sk_buff **pending, | 242 | int tipc_link_recv_fragment(struct sk_buff **pending, |
247 | struct sk_buff **fb, | 243 | struct sk_buff **fb, |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 381063817b41..ecb532fb0351 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -112,7 +112,7 @@ int tipc_msg_build(struct tipc_msg *hdr, | |||
112 | return dsz; | 112 | return dsz; |
113 | } | 113 | } |
114 | 114 | ||
115 | *buf = buf_acquire(sz); | 115 | *buf = tipc_buf_acquire(sz); |
116 | if (!(*buf)) | 116 | if (!(*buf)) |
117 | return -ENOMEM; | 117 | return -ENOMEM; |
118 | skb_copy_to_linear_data(*buf, hdr, hsz); | 118 | skb_copy_to_linear_data(*buf, hdr, hsz); |
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index 6ac3c543250b..7b907171f879 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
@@ -98,7 +98,7 @@ static void publ_to_item(struct distr_item *i, struct publication *p) | |||
98 | 98 | ||
99 | static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) | 99 | static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) |
100 | { | 100 | { |
101 | struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size); | 101 | struct sk_buff *buf = tipc_buf_acquire(LONG_H_SIZE + size); |
102 | struct tipc_msg *msg; | 102 | struct tipc_msg *msg; |
103 | 103 | ||
104 | if (buf != NULL) { | 104 | if (buf != NULL) { |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 823e9abb7ef5..b4d87eb2dc5d 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -50,7 +50,8 @@ void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str); | |||
50 | static void node_lost_contact(struct tipc_node *n_ptr); | 50 | static void node_lost_contact(struct tipc_node *n_ptr); |
51 | static void node_established_contact(struct tipc_node *n_ptr); | 51 | static void node_established_contact(struct tipc_node *n_ptr); |
52 | 52 | ||
53 | struct tipc_node *tipc_nodes = NULL; /* sorted list of nodes within cluster */ | 53 | /* sorted list of nodes within cluster */ |
54 | static struct tipc_node *tipc_nodes = NULL; | ||
54 | 55 | ||
55 | static DEFINE_SPINLOCK(node_create_lock); | 56 | static DEFINE_SPINLOCK(node_create_lock); |
56 | 57 | ||
@@ -587,22 +588,6 @@ void tipc_node_remove_router(struct tipc_node *n_ptr, u32 router) | |||
587 | node_lost_contact(n_ptr); | 588 | node_lost_contact(n_ptr); |
588 | } | 589 | } |
589 | 590 | ||
590 | u32 tipc_available_nodes(const u32 domain) | ||
591 | { | ||
592 | struct tipc_node *n_ptr; | ||
593 | u32 cnt = 0; | ||
594 | |||
595 | read_lock_bh(&tipc_net_lock); | ||
596 | for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { | ||
597 | if (!tipc_in_scope(domain, n_ptr->addr)) | ||
598 | continue; | ||
599 | if (tipc_node_is_up(n_ptr)) | ||
600 | cnt++; | ||
601 | } | ||
602 | read_unlock_bh(&tipc_net_lock); | ||
603 | return cnt; | ||
604 | } | ||
605 | |||
606 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | 591 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) |
607 | { | 592 | { |
608 | u32 domain; | 593 | u32 domain; |
diff --git a/net/tipc/node.h b/net/tipc/node.h index 45f3db3a595d..fff331b2d26c 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
@@ -96,7 +96,6 @@ struct tipc_node { | |||
96 | } bclink; | 96 | } bclink; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | extern struct tipc_node *tipc_nodes; | ||
100 | extern u32 tipc_own_tag; | 99 | extern u32 tipc_own_tag; |
101 | 100 | ||
102 | struct tipc_node *tipc_node_create(u32 addr); | 101 | struct tipc_node *tipc_node_create(u32 addr); |
diff --git a/net/tipc/port.c b/net/tipc/port.c index 5c4285b2d555..82092eaa1536 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c | |||
@@ -293,34 +293,6 @@ int tipc_deleteport(u32 ref) | |||
293 | return 0; | 293 | return 0; |
294 | } | 294 | } |
295 | 295 | ||
296 | /** | ||
297 | * tipc_get_port() - return port associated with 'ref' | ||
298 | * | ||
299 | * Note: Port is not locked. | ||
300 | */ | ||
301 | |||
302 | struct tipc_port *tipc_get_port(const u32 ref) | ||
303 | { | ||
304 | return (struct tipc_port *)tipc_ref_deref(ref); | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * tipc_get_handle - return user handle associated to port 'ref' | ||
309 | */ | ||
310 | |||
311 | void *tipc_get_handle(const u32 ref) | ||
312 | { | ||
313 | struct port *p_ptr; | ||
314 | void * handle; | ||
315 | |||
316 | p_ptr = tipc_port_lock(ref); | ||
317 | if (!p_ptr) | ||
318 | return NULL; | ||
319 | handle = p_ptr->publ.usr_handle; | ||
320 | tipc_port_unlock(p_ptr); | ||
321 | return handle; | ||
322 | } | ||
323 | |||
324 | static int port_unreliable(struct port *p_ptr) | 296 | static int port_unreliable(struct port *p_ptr) |
325 | { | 297 | { |
326 | return msg_src_droppable(&p_ptr->publ.phdr); | 298 | return msg_src_droppable(&p_ptr->publ.phdr); |
@@ -392,7 +364,7 @@ static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, | |||
392 | struct sk_buff *buf; | 364 | struct sk_buff *buf; |
393 | struct tipc_msg *msg; | 365 | struct tipc_msg *msg; |
394 | 366 | ||
395 | buf = buf_acquire(LONG_H_SIZE); | 367 | buf = tipc_buf_acquire(LONG_H_SIZE); |
396 | if (buf) { | 368 | if (buf) { |
397 | msg = buf_msg(buf); | 369 | msg = buf_msg(buf); |
398 | tipc_msg_init(msg, usr, type, LONG_H_SIZE, destnode); | 370 | tipc_msg_init(msg, usr, type, LONG_H_SIZE, destnode); |
@@ -433,7 +405,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) | |||
433 | hdr_sz = MCAST_H_SIZE; | 405 | hdr_sz = MCAST_H_SIZE; |
434 | else | 406 | else |
435 | hdr_sz = LONG_H_SIZE; | 407 | hdr_sz = LONG_H_SIZE; |
436 | rbuf = buf_acquire(data_sz + hdr_sz); | 408 | rbuf = tipc_buf_acquire(data_sz + hdr_sz); |
437 | if (rbuf == NULL) { | 409 | if (rbuf == NULL) { |
438 | buf_discard(buf); | 410 | buf_discard(buf); |
439 | return data_sz; | 411 | return data_sz; |
@@ -1242,50 +1214,13 @@ int tipc_shutdown(u32 ref) | |||
1242 | return tipc_disconnect(ref); | 1214 | return tipc_disconnect(ref); |
1243 | } | 1215 | } |
1244 | 1216 | ||
1245 | int tipc_isconnected(u32 ref, int *isconnected) | ||
1246 | { | ||
1247 | struct port *p_ptr; | ||
1248 | |||
1249 | p_ptr = tipc_port_lock(ref); | ||
1250 | if (!p_ptr) | ||
1251 | return -EINVAL; | ||
1252 | *isconnected = p_ptr->publ.connected; | ||
1253 | tipc_port_unlock(p_ptr); | ||
1254 | return 0; | ||
1255 | } | ||
1256 | |||
1257 | int tipc_peer(u32 ref, struct tipc_portid *peer) | ||
1258 | { | ||
1259 | struct port *p_ptr; | ||
1260 | int res; | ||
1261 | |||
1262 | p_ptr = tipc_port_lock(ref); | ||
1263 | if (!p_ptr) | ||
1264 | return -EINVAL; | ||
1265 | if (p_ptr->publ.connected) { | ||
1266 | peer->ref = port_peerport(p_ptr); | ||
1267 | peer->node = port_peernode(p_ptr); | ||
1268 | res = 0; | ||
1269 | } else | ||
1270 | res = -ENOTCONN; | ||
1271 | tipc_port_unlock(p_ptr); | ||
1272 | return res; | ||
1273 | } | ||
1274 | |||
1275 | int tipc_ref_valid(u32 ref) | ||
1276 | { | ||
1277 | /* Works irrespective of type */ | ||
1278 | return !!tipc_ref_deref(ref); | ||
1279 | } | ||
1280 | |||
1281 | |||
1282 | /* | 1217 | /* |
1283 | * tipc_port_recv_sections(): Concatenate and deliver sectioned | 1218 | * tipc_port_recv_sections(): Concatenate and deliver sectioned |
1284 | * message for this node. | 1219 | * message for this node. |
1285 | */ | 1220 | */ |
1286 | 1221 | ||
1287 | int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, | 1222 | static int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, |
1288 | struct iovec const *msg_sect) | 1223 | struct iovec const *msg_sect) |
1289 | { | 1224 | { |
1290 | struct sk_buff *buf; | 1225 | struct sk_buff *buf; |
1291 | int res; | 1226 | int res; |
@@ -1336,65 +1271,16 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) | |||
1336 | } | 1271 | } |
1337 | 1272 | ||
1338 | /** | 1273 | /** |
1339 | * tipc_send_buf - send message buffer on connection | ||
1340 | */ | ||
1341 | |||
1342 | int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz) | ||
1343 | { | ||
1344 | struct port *p_ptr; | ||
1345 | struct tipc_msg *msg; | ||
1346 | u32 destnode; | ||
1347 | u32 hsz; | ||
1348 | u32 sz; | ||
1349 | u32 res; | ||
1350 | |||
1351 | p_ptr = tipc_port_deref(ref); | ||
1352 | if (!p_ptr || !p_ptr->publ.connected) | ||
1353 | return -EINVAL; | ||
1354 | |||
1355 | msg = &p_ptr->publ.phdr; | ||
1356 | hsz = msg_hdr_sz(msg); | ||
1357 | sz = hsz + dsz; | ||
1358 | msg_set_size(msg, sz); | ||
1359 | if (skb_cow(buf, hsz)) | ||
1360 | return -ENOMEM; | ||
1361 | |||
1362 | skb_push(buf, hsz); | ||
1363 | skb_copy_to_linear_data(buf, msg, hsz); | ||
1364 | destnode = msg_destnode(msg); | ||
1365 | p_ptr->publ.congested = 1; | ||
1366 | if (!tipc_port_congested(p_ptr)) { | ||
1367 | if (likely(destnode != tipc_own_addr)) | ||
1368 | res = tipc_send_buf_fast(buf, destnode); | ||
1369 | else { | ||
1370 | tipc_port_recv_msg(buf); | ||
1371 | res = sz; | ||
1372 | } | ||
1373 | if (likely(res != -ELINKCONG)) { | ||
1374 | port_incr_out_seqno(p_ptr); | ||
1375 | p_ptr->sent++; | ||
1376 | p_ptr->publ.congested = 0; | ||
1377 | return res; | ||
1378 | } | ||
1379 | } | ||
1380 | if (port_unreliable(p_ptr)) { | ||
1381 | p_ptr->publ.congested = 0; | ||
1382 | return dsz; | ||
1383 | } | ||
1384 | return -ELINKCONG; | ||
1385 | } | ||
1386 | |||
1387 | /** | ||
1388 | * tipc_forward2name - forward message sections to port name | 1274 | * tipc_forward2name - forward message sections to port name |
1389 | */ | 1275 | */ |
1390 | 1276 | ||
1391 | int tipc_forward2name(u32 ref, | 1277 | static int tipc_forward2name(u32 ref, |
1392 | struct tipc_name const *name, | 1278 | struct tipc_name const *name, |
1393 | u32 domain, | 1279 | u32 domain, |
1394 | u32 num_sect, | 1280 | u32 num_sect, |
1395 | struct iovec const *msg_sect, | 1281 | struct iovec const *msg_sect, |
1396 | struct tipc_portid const *orig, | 1282 | struct tipc_portid const *orig, |
1397 | unsigned int importance) | 1283 | unsigned int importance) |
1398 | { | 1284 | { |
1399 | struct port *p_ptr; | 1285 | struct port *p_ptr; |
1400 | struct tipc_msg *msg; | 1286 | struct tipc_msg *msg; |
@@ -1457,89 +1343,15 @@ int tipc_send2name(u32 ref, | |||
1457 | } | 1343 | } |
1458 | 1344 | ||
1459 | /** | 1345 | /** |
1460 | * tipc_forward_buf2name - forward message buffer to port name | ||
1461 | */ | ||
1462 | |||
1463 | int tipc_forward_buf2name(u32 ref, | ||
1464 | struct tipc_name const *name, | ||
1465 | u32 domain, | ||
1466 | struct sk_buff *buf, | ||
1467 | unsigned int dsz, | ||
1468 | struct tipc_portid const *orig, | ||
1469 | unsigned int importance) | ||
1470 | { | ||
1471 | struct port *p_ptr; | ||
1472 | struct tipc_msg *msg; | ||
1473 | u32 destnode = domain; | ||
1474 | u32 destport; | ||
1475 | int res; | ||
1476 | |||
1477 | p_ptr = (struct port *)tipc_ref_deref(ref); | ||
1478 | if (!p_ptr || p_ptr->publ.connected) | ||
1479 | return -EINVAL; | ||
1480 | |||
1481 | msg = &p_ptr->publ.phdr; | ||
1482 | if (importance <= TIPC_CRITICAL_IMPORTANCE) | ||
1483 | msg_set_importance(msg, importance); | ||
1484 | msg_set_type(msg, TIPC_NAMED_MSG); | ||
1485 | msg_set_orignode(msg, orig->node); | ||
1486 | msg_set_origport(msg, orig->ref); | ||
1487 | msg_set_nametype(msg, name->type); | ||
1488 | msg_set_nameinst(msg, name->instance); | ||
1489 | msg_set_lookup_scope(msg, tipc_addr_scope(domain)); | ||
1490 | msg_set_hdr_sz(msg, LONG_H_SIZE); | ||
1491 | msg_set_size(msg, LONG_H_SIZE + dsz); | ||
1492 | destport = tipc_nametbl_translate(name->type, name->instance, &destnode); | ||
1493 | msg_set_destnode(msg, destnode); | ||
1494 | msg_set_destport(msg, destport); | ||
1495 | msg_dbg(msg, "forw2name ==> "); | ||
1496 | if (skb_cow(buf, LONG_H_SIZE)) | ||
1497 | return -ENOMEM; | ||
1498 | skb_push(buf, LONG_H_SIZE); | ||
1499 | skb_copy_to_linear_data(buf, msg, LONG_H_SIZE); | ||
1500 | msg_dbg(buf_msg(buf),"PREP:"); | ||
1501 | if (likely(destport)) { | ||
1502 | p_ptr->sent++; | ||
1503 | if (destnode == tipc_own_addr) | ||
1504 | return tipc_port_recv_msg(buf); | ||
1505 | res = tipc_send_buf_fast(buf, destnode); | ||
1506 | if (likely(res != -ELINKCONG)) | ||
1507 | return res; | ||
1508 | if (port_unreliable(p_ptr)) | ||
1509 | return dsz; | ||
1510 | return -ELINKCONG; | ||
1511 | } | ||
1512 | return tipc_reject_msg(buf, TIPC_ERR_NO_NAME); | ||
1513 | } | ||
1514 | |||
1515 | /** | ||
1516 | * tipc_send_buf2name - send message buffer to port name | ||
1517 | */ | ||
1518 | |||
1519 | int tipc_send_buf2name(u32 ref, | ||
1520 | struct tipc_name const *dest, | ||
1521 | u32 domain, | ||
1522 | struct sk_buff *buf, | ||
1523 | unsigned int dsz) | ||
1524 | { | ||
1525 | struct tipc_portid orig; | ||
1526 | |||
1527 | orig.ref = ref; | ||
1528 | orig.node = tipc_own_addr; | ||
1529 | return tipc_forward_buf2name(ref, dest, domain, buf, dsz, &orig, | ||
1530 | TIPC_PORT_IMPORTANCE); | ||
1531 | } | ||
1532 | |||
1533 | /** | ||
1534 | * tipc_forward2port - forward message sections to port identity | 1346 | * tipc_forward2port - forward message sections to port identity |
1535 | */ | 1347 | */ |
1536 | 1348 | ||
1537 | int tipc_forward2port(u32 ref, | 1349 | static int tipc_forward2port(u32 ref, |
1538 | struct tipc_portid const *dest, | 1350 | struct tipc_portid const *dest, |
1539 | unsigned int num_sect, | 1351 | unsigned int num_sect, |
1540 | struct iovec const *msg_sect, | 1352 | struct iovec const *msg_sect, |
1541 | struct tipc_portid const *orig, | 1353 | struct tipc_portid const *orig, |
1542 | unsigned int importance) | 1354 | unsigned int importance) |
1543 | { | 1355 | { |
1544 | struct port *p_ptr; | 1356 | struct port *p_ptr; |
1545 | struct tipc_msg *msg; | 1357 | struct tipc_msg *msg; |
@@ -1591,12 +1403,12 @@ int tipc_send2port(u32 ref, | |||
1591 | /** | 1403 | /** |
1592 | * tipc_forward_buf2port - forward message buffer to port identity | 1404 | * tipc_forward_buf2port - forward message buffer to port identity |
1593 | */ | 1405 | */ |
1594 | int tipc_forward_buf2port(u32 ref, | 1406 | static int tipc_forward_buf2port(u32 ref, |
1595 | struct tipc_portid const *dest, | 1407 | struct tipc_portid const *dest, |
1596 | struct sk_buff *buf, | 1408 | struct sk_buff *buf, |
1597 | unsigned int dsz, | 1409 | unsigned int dsz, |
1598 | struct tipc_portid const *orig, | 1410 | struct tipc_portid const *orig, |
1599 | unsigned int importance) | 1411 | unsigned int importance) |
1600 | { | 1412 | { |
1601 | struct port *p_ptr; | 1413 | struct port *p_ptr; |
1602 | struct tipc_msg *msg; | 1414 | struct tipc_msg *msg; |
diff --git a/net/tipc/port.h b/net/tipc/port.h index e74bd9563739..73bbf442b346 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
@@ -109,8 +109,6 @@ struct port { | |||
109 | extern spinlock_t tipc_port_list_lock; | 109 | extern spinlock_t tipc_port_list_lock; |
110 | struct port_list; | 110 | struct port_list; |
111 | 111 | ||
112 | int tipc_port_recv_sections(struct port *p_ptr, u32 num_sect, | ||
113 | struct iovec const *msg_sect); | ||
114 | int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, | 112 | int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, |
115 | struct iovec const *msg_sect, u32 num_sect, | 113 | struct iovec const *msg_sect, u32 num_sect, |
116 | int err); | 114 | int err); |
diff --git a/net/tipc/ref.c b/net/tipc/ref.c index 8dea66500cf5..ab8ad32d8c20 100644 --- a/net/tipc/ref.c +++ b/net/tipc/ref.c | |||
@@ -282,23 +282,6 @@ void *tipc_ref_lock(u32 ref) | |||
282 | return NULL; | 282 | return NULL; |
283 | } | 283 | } |
284 | 284 | ||
285 | /** | ||
286 | * tipc_ref_unlock - unlock referenced object | ||
287 | */ | ||
288 | |||
289 | void tipc_ref_unlock(u32 ref) | ||
290 | { | ||
291 | if (likely(tipc_ref_table.entries)) { | ||
292 | struct reference *entry; | ||
293 | |||
294 | entry = &tipc_ref_table.entries[ref & | ||
295 | tipc_ref_table.index_mask]; | ||
296 | if (likely((entry->ref == ref) && (entry->object))) | ||
297 | spin_unlock_bh(&entry->lock); | ||
298 | else | ||
299 | err("Attempt to unlock non-existent reference\n"); | ||
300 | } | ||
301 | } | ||
302 | 285 | ||
303 | /** | 286 | /** |
304 | * tipc_ref_deref - return pointer referenced object (without locking it) | 287 | * tipc_ref_deref - return pointer referenced object (without locking it) |
diff --git a/net/tipc/ref.h b/net/tipc/ref.h index 7e3798ea93b9..5bc8e7ab84de 100644 --- a/net/tipc/ref.h +++ b/net/tipc/ref.h | |||
@@ -44,7 +44,6 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock); | |||
44 | void tipc_ref_discard(u32 ref); | 44 | void tipc_ref_discard(u32 ref); |
45 | 45 | ||
46 | void *tipc_ref_lock(u32 ref); | 46 | void *tipc_ref_lock(u32 ref); |
47 | void tipc_ref_unlock(u32 ref); | ||
48 | void *tipc_ref_deref(u32 ref); | 47 | void *tipc_ref_deref(u32 ref); |
49 | 48 | ||
50 | #endif | 49 | #endif |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 1a5b9a6bd128..18813acc6bef 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -598,12 +598,3 @@ void tipc_subscr_stop(void) | |||
598 | topsrv.user_ref = 0; | 598 | topsrv.user_ref = 0; |
599 | } | 599 | } |
600 | } | 600 | } |
601 | |||
602 | |||
603 | int tipc_ispublished(struct tipc_name const *name) | ||
604 | { | ||
605 | u32 domain = 0; | ||
606 | |||
607 | return tipc_nametbl_translate(name->type, name->instance, &domain) != 0; | ||
608 | } | ||
609 | |||
diff --git a/net/tipc/zone.c b/net/tipc/zone.c index 2c01ba2d86bf..83f8b5e91fc8 100644 --- a/net/tipc/zone.c +++ b/net/tipc/zone.c | |||
@@ -160,14 +160,3 @@ u32 tipc_zone_select_router(struct _zone *z_ptr, u32 addr, u32 ref) | |||
160 | } | 160 | } |
161 | return 0; | 161 | return 0; |
162 | } | 162 | } |
163 | |||
164 | |||
165 | u32 tipc_zone_next_node(u32 addr) | ||
166 | { | ||
167 | struct cluster *c_ptr = tipc_cltr_find(addr); | ||
168 | |||
169 | if (c_ptr) | ||
170 | return tipc_cltr_next_node(c_ptr, addr); | ||
171 | return 0; | ||
172 | } | ||
173 | |||
diff --git a/net/tipc/zone.h b/net/tipc/zone.h index 7bdc3406ba9b..bd1c20ce9d06 100644 --- a/net/tipc/zone.h +++ b/net/tipc/zone.h | |||
@@ -61,7 +61,6 @@ void tipc_zone_send_external_routes(struct _zone *z_ptr, u32 dest); | |||
61 | struct _zone *tipc_zone_create(u32 addr); | 61 | struct _zone *tipc_zone_create(u32 addr); |
62 | void tipc_zone_delete(struct _zone *z_ptr); | 62 | void tipc_zone_delete(struct _zone *z_ptr); |
63 | void tipc_zone_attach_cluster(struct _zone *z_ptr, struct cluster *c_ptr); | 63 | void tipc_zone_attach_cluster(struct _zone *z_ptr, struct cluster *c_ptr); |
64 | u32 tipc_zone_next_node(u32 addr); | ||
65 | 64 | ||
66 | static inline struct _zone *tipc_zone_find(u32 addr) | 65 | static inline struct _zone *tipc_zone_find(u32 addr) |
67 | { | 66 | { |