History

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

* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: [TG3]: Update driver version and reldate. [TG3]: Add 5755 nvram support [TG3]: Add 5755 support [IPV6]: ip6_xmit: remove unnecessary NULL ptr check [NET_SCHED]: cls_u32: remove unnecessary NULL-ptr check [IPV4]: Add fib rule netlink notifications [BNX2]: Update version and reldate [BNX2]: Separate tx producer and consumer fields [BNX2]: Move .h files to bnx2.c [BNX2]: Combine small mem allocations [BNX2]: Fix link change handling [PKTGEN]: Add MPLS extension.

Linus Torvalds committed 20 years ago

Commit 554f5932 parents debf798 95381c811 files · +371 −111Browse files

Unified · Split

11 files
  1. Documentation/networking/pktgen.txt +19 −1
  2. drivers/net/bnx2.c +75 −33
  3. drivers/net/bnx2.h +14 −48
  4. drivers/net/tg3.c +76 −8
  5. drivers/net/tg3.h +8 −1
  6. include/linux/pci_ids.h +2 −0
  7. include/linux/rtnetlink.h +3 −1
  8. net/core/pktgen.c +147 −11
  9. net/ipv4/fib_rules.c +24 −3
  10. net/ipv6/ip6_output.c +1 −1
  11. net/sched/cls_u32.c +2 −4
Documentation/networking/pktgen.txt+19−1
@@ -109,6 +109,22 @@ Examples: · 108 unmodified lines
109109 cycle through the port range.
110110 pgset "udp_dst_max 9" set UDP destination port max.
111111
112+ pgset "mpls 0001000a,0002000a,0000000a" set MPLS labels (in this example
113+ outer label=16,middle label=32,
114+ inner label=0 (IPv4 NULL)) Note that
115+ there must be no spaces between the
116+ arguments. Leading zeros are required.
117+ Do not set the bottom of stack bit,
118+ thats done automatically. If you do
119+ set the bottom of stack bit, that
120+ indicates that you want to randomly
121+ generate that address and the flag
122+ MPLS_RND will be turned on. You
123+ can have any mix of random and fixed
124+ labels in the label stack.
125+
126+ pgset "mpls 0" turn off mpls (or any invalid argument works too!)
127+
112128 pgset stop aborts injection. Also, ^C aborts generator.
113129
114130
@@ -167,6 +183,8 @@ pkt_size · 52 unmodified lines
167183 min_pkt_size
168184 max_pkt_size
169185
186+mpls
187+
170188 udp_src_min
171189 udp_src_max
172190
@@ -211,4 +229,4 @@ Grant Grundler for testing on IA-64 and parisc, Harald Welte, Lennert Buytenhek · 38 unmodified lines
211229 Stephen Hemminger, Andi Kleen, Dave Miller and many others.
212230
213231
214−Good luck with the linux net-development.
232+Good luck with the linux net-development.
drivers/net/bnx2.c+75−33
@@ -9,13 +9,54 @@ · 8 unmodified lines
99 * Written by: Michael Chan (mchan@broadcom.com)
1010 */
1111
12+#include <linux/config.h>
13+
14+#include <linux/module.h>
15+#include <linux/moduleparam.h>
16+
17+#include <linux/kernel.h>
18+#include <linux/timer.h>
19+#include <linux/errno.h>
20+#include <linux/ioport.h>
21+#include <linux/slab.h>
22+#include <linux/vmalloc.h>
23+#include <linux/interrupt.h>
24+#include <linux/pci.h>
25+#include <linux/init.h>
26+#include <linux/netdevice.h>
27+#include <linux/etherdevice.h>
28+#include <linux/skbuff.h>
29+#include <linux/dma-mapping.h>
30+#include <asm/bitops.h>
31+#include <asm/io.h>
32+#include <asm/irq.h>
33+#include <linux/delay.h>
34+#include <asm/byteorder.h>
35+#include <linux/time.h>
36+#include <linux/ethtool.h>
37+#include <linux/mii.h>
38+#ifdef NETIF_F_HW_VLAN_TX
39+#include <linux/if_vlan.h>
40+#define BCM_VLAN 1
41+#endif
42+#ifdef NETIF_F_TSO
43+#include <net/ip.h>
44+#include <net/tcp.h>
45+#include <net/checksum.h>
46+#define BCM_TSO 1
47+#endif
48+#include <linux/workqueue.h>
49+#include <linux/crc32.h>
50+#include <linux/prefetch.h>
51+#include <linux/cache.h>
52+
1253 #include "bnx2.h"
1354 #include "bnx2_fw.h"
1455
1556 #define DRV_MODULE_NAME "bnx2"
1657 #define PFX DRV_MODULE_NAME ": "
17−#define DRV_MODULE_VERSION "1.4.38"
18−#define DRV_MODULE_RELDATE "February 10, 2006"
58+#define DRV_MODULE_VERSION "1.4.39"
59+#define DRV_MODULE_RELDATE "March 22, 2006"
1960
2061 #define RUN_AT(x) (jiffies + (x))
2162
@@ -313,8 +354,6 @@ bnx2_disable_int(struct bnx2 *bp) · 291 unmodified lines
313354 static void
314355 bnx2_enable_int(struct bnx2 *bp)
315356 {
316− u32 val;
317−
318357 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
319358 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
320359 BNX2_PCICFG_INT_ACK_CMD_MASK_INT | bp->last_status_idx);
@@ -322,8 +361,7 @@ bnx2_enable_int(struct bnx2 *bp) · 1 unmodified line
322361 REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
323362 BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx);
324363
325− val = REG_RD(bp, BNX2_HC_COMMAND);
326− REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW);
364+ REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW);
327365 }
328366
329367 static void
@@ -362,15 +400,11 @@ bnx2_free_mem(struct bnx2 *bp) · 32 unmodified lines
362400 {
363401 int i;
364402
365− if (bp->stats_blk) {
366− pci_free_consistent(bp->pdev, sizeof(struct statistics_block),
367− bp->stats_blk, bp->stats_blk_mapping);
368− bp->stats_blk = NULL;
369− }
370403 if (bp->status_blk) {
371− pci_free_consistent(bp->pdev, sizeof(struct status_block),
404+ pci_free_consistent(bp->pdev, bp->status_stats_size,
372405 bp->status_blk, bp->status_blk_mapping);
373406 bp->status_blk = NULL;
407+ bp->stats_blk = NULL;
374408 }
375409 if (bp->tx_desc_ring) {
376410 pci_free_consistent(bp->pdev,
@@ -395,14 +429,13 @@ bnx2_free_mem(struct bnx2 *bp) · 18 unmodified lines
395429 static int
396430 bnx2_alloc_mem(struct bnx2 *bp)
397431 {
398− int i;
432+ int i, status_blk_size;
399433
400− bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
401− GFP_KERNEL);
434+ bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
435+ GFP_KERNEL);
402436 if (bp->tx_buf_ring == NULL)
403437 return -ENOMEM;
404438
405− memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT);
406439 bp->tx_desc_ring = pci_alloc_consistent(bp->pdev,
407440 sizeof(struct tx_bd) *
408441 TX_DESC_CNT,
@@ -428,21 +461,22 @@ bnx2_alloc_mem(struct bnx2 *bp) · 19 unmodified lines
428461
429462 }
430463
431− bp->status_blk = pci_alloc_consistent(bp->pdev,
432− sizeof(struct status_block),
464+ /* Combine status and statistics blocks into one allocation. */
465+ status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block));
466+ bp->status_stats_size = status_blk_size +
467+ sizeof(struct statistics_block);
468+
469+ bp->status_blk = pci_alloc_consistent(bp->pdev, bp->status_stats_size,
433470 &bp->status_blk_mapping);
434471 if (bp->status_blk == NULL)
435472 goto alloc_mem_err;
436473
437− memset(bp->status_blk, 0, sizeof(struct status_block));
474+ memset(bp->status_blk, 0, bp->status_stats_size);
438475
439− bp->stats_blk = pci_alloc_consistent(bp->pdev,
440− sizeof(struct statistics_block),
441− &bp->stats_blk_mapping);
442− if (bp->stats_blk == NULL)
443− goto alloc_mem_err;
476+ bp->stats_blk = (void *) ((unsigned long) bp->status_blk +
477+ status_blk_size);
444478
445− memset(bp->stats_blk, 0, sizeof(struct statistics_block));
479+ bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size;
446480
447481 return 0;
448482
@@ -1926,6 +1960,13 @@ bnx2_poll(struct net_device *dev, int *budget) · 1477 unmodified lines
19261960 spin_lock(&bp->phy_lock);
19271961 bnx2_phy_int(bp);
19281962 spin_unlock(&bp->phy_lock);
1963+
1964+ /* This is needed to take care of transient status
1965+ * during link changes.
1966+ */
1967+ REG_WR(bp, BNX2_HC_COMMAND,
1968+ bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
1969+ REG_RD(bp, BNX2_HC_COMMAND);
19291970 }
19301971
19311972 if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)
@@ -3307,6 +3348,8 @@ bnx2_init_chip(struct bnx2 *bp) · 1375 unmodified lines
33073348
33083349 udelay(20);
33093350
3351+ bp->hc_cmd = REG_RD(bp, BNX2_HC_COMMAND);
3352+
33103353 return rc;
33113354 }
33123355
@@ -3746,7 +3789,6 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) · 433 unmodified lines
37463789 struct sk_buff *skb, *rx_skb;
37473790 unsigned char *packet;
37483791 u16 rx_start_idx, rx_idx;
3749− u32 val;
37503792 dma_addr_t map;
37513793 struct tx_bd *txbd;
37523794 struct sw_bd *rx_buf;
@@ -3777,8 +3819,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) · 24 unmodified lines
37773819 map = pci_map_single(bp->pdev, skb->data, pkt_size,
37783820 PCI_DMA_TODEVICE);
37793821
3780− val = REG_RD(bp, BNX2_HC_COMMAND);
3781− REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
3822+ REG_WR(bp, BNX2_HC_COMMAND,
3823+ bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
3824+
37823825 REG_RD(bp, BNX2_HC_COMMAND);
37833826
37843827 udelay(5);
@@ -3802,8 +3845,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode) · 17 unmodified lines
38023845
38033846 udelay(100);
38043847
3805− val = REG_RD(bp, BNX2_HC_COMMAND);
3806− REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
3848+ REG_WR(bp, BNX2_HC_COMMAND,
3849+ bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
3850+
38073851 REG_RD(bp, BNX2_HC_COMMAND);
38083852
38093853 udelay(5);
@@ -3939,7 +3983,6 @@ static int · 129 unmodified lines
39393983 bnx2_test_intr(struct bnx2 *bp)
39403984 {
39413985 int i;
3942− u32 val;
39433986 u16 status_idx;
39443987
39453988 if (!netif_running(bp->dev))
@@ -3948,8 +3991,7 @@ bnx2_test_intr(struct bnx2 *bp) · 2 unmodified lines
39483991 status_idx = REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff;
39493992
39503993 /* This register is not touched during run-time. */
3951− val = REG_RD(bp, BNX2_HC_COMMAND);
3952− REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW);
3994+ REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW);
39533995 REG_RD(bp, BNX2_HC_COMMAND);
39543996
39553997 for (i = 0; i < 10; i++) {
drivers/net/bnx2.h+14−48
@@ -13,46 +13,6 @@ · 12 unmodified lines
1313 #ifndef BNX2_H
1414 #define BNX2_H
1515
16−#include <linux/config.h>
17−
18−#include <linux/module.h>
19−#include <linux/moduleparam.h>
20−
21−#include <linux/kernel.h>
22−#include <linux/timer.h>
23−#include <linux/errno.h>
24−#include <linux/ioport.h>
25−#include <linux/slab.h>
26−#include <linux/vmalloc.h>
27−#include <linux/interrupt.h>
28−#include <linux/pci.h>
29−#include <linux/init.h>
30−#include <linux/netdevice.h>
31−#include <linux/etherdevice.h>
32−#include <linux/skbuff.h>
33−#include <linux/dma-mapping.h>
34−#include <asm/bitops.h>
35−#include <asm/io.h>
36−#include <asm/irq.h>
37−#include <linux/delay.h>
38−#include <asm/byteorder.h>
39−#include <linux/time.h>
40−#include <linux/ethtool.h>
41−#include <linux/mii.h>
42−#ifdef NETIF_F_HW_VLAN_TX
43−#include <linux/if_vlan.h>
44−#define BCM_VLAN 1
45−#endif
46−#ifdef NETIF_F_TSO
47−#include <net/ip.h>
48−#include <net/tcp.h>
49−#include <net/checksum.h>
50−#define BCM_TSO 1
51−#endif
52−#include <linux/workqueue.h>
53−#include <linux/crc32.h>
54−#include <linux/prefetch.h>
55−
5616 /* Hardware data structures and register definitions automatically
5717 * generated from RTL code. Do not modify.
5818 */
@@ -3917,15 +3877,17 @@ struct bnx2 { · 3858 unmodified lines
39173877 #define USING_MSI_FLAG 0x20
39183878 #define ASF_ENABLE_FLAG 0x40
39193879
3920− struct tx_bd *tx_desc_ring;
3921− struct sw_bd *tx_buf_ring;
3922− u32 tx_prod_bseq;
3923− u16 tx_prod;
3924− u16 tx_cons;
3925− int tx_ring_size;
3880+ /* Put tx producer and consumer fields in separate cache lines. */
39263881
3927− u16 hw_tx_cons;
3928− u16 hw_rx_cons;
3882+ u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES)));
3883+ u16 tx_prod;
3884+
3885+ struct tx_bd *tx_desc_ring;
3886+ struct sw_bd *tx_buf_ring;
3887+ int tx_ring_size;
3888+
3889+ u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES)));
3890+ u16 hw_tx_cons;
39293891
39303892 #ifdef BCM_VLAN
39313893 struct vlan_group *vlgrp;
@@ -3939,6 +3901,7 @@ struct bnx2 { · 7 unmodified lines
39393901 u32 rx_prod_bseq;
39403902 u16 rx_prod;
39413903 u16 rx_cons;
3904+ u16 hw_rx_cons;
39423905
39433906 u32 rx_csum;
39443907
@@ -4038,6 +4001,7 @@ struct bnx2 { · 93 unmodified lines
40384001 struct statistics_block *stats_blk;
40394002 dma_addr_t stats_blk_mapping;
40404003
4004+ u32 hc_cmd;
40414005 u32 rx_mode;
40424006
40434007 u16 req_line_speed;
@@ -4082,6 +4046,8 @@ struct bnx2 { · 38 unmodified lines
40824046
40834047 struct flash_spec *flash_info;
40844048 u32 flash_size;
4049+
4050+ int status_stats_size;
40854051 };
40864052
40874053 static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset);
drivers/net/tg3.c+76−8
@@ -69,8 +69,8 @@ · 68 unmodified lines
6969
7070 #define DRV_MODULE_NAME "tg3"
7171 #define PFX DRV_MODULE_NAME ": "
72−#define DRV_MODULE_VERSION "3.53"
73−#define DRV_MODULE_RELDATE "Mar 22, 2006"
72+#define DRV_MODULE_VERSION "3.54"
73+#define DRV_MODULE_RELDATE "Mar 23, 2006"
7474
7575 #define TG3_DEF_MAC_MODE 0
7676 #define TG3_DEF_RX_MODE 0
@@ -225,6 +225,10 @@ static struct pci_device_id tg3_pci_tbl[] = { · 148 unmodified lines
225225 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
226226 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754M,
227227 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
228+ { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755,
229+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
230+ { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755M,
231+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
228232 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787,
229233 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
230234 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M,
@@ -4557,6 +4561,7 @@ static int tg3_chip_reset(struct tg3 *tp) · 4326 unmodified lines
45574561 }
45584562
45594563 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
4564+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
45604565 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
45614566 tw32(GRC_FASTBOOT_PC, 0);
45624567
@@ -6152,6 +6157,9 @@ static int tg3_reset_hw(struct tg3 *tp) · 1589 unmodified lines
61526157 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
61536158 GRC_LCLCTRL_GPIO_OUTPUT3;
61546159
6160+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
6161+ gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL;
6162+
61556163 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
61566164
61576165 /* GPIO1 must be driven high for eeprom write protect */
@@ -6191,7 +6199,8 @@ static int tg3_reset_hw(struct tg3 *tp) · 33 unmodified lines
61916199 }
61926200
61936201 /* Enable host coalescing bug fix */
6194− if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
6202+ if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) ||
6203+ (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787))
61956204 val |= (1 << 29);
61966205
61976206 tw32_f(WDMAC_MODE, val);
@@ -6249,6 +6258,9 @@ static int tg3_reset_hw(struct tg3 *tp) · 51 unmodified lines
62496258 udelay(100);
62506259
62516260 tp->rx_mode = RX_MODE_ENABLE;
6261+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
6262+ tp->rx_mode |= RX_MODE_IPV6_CSUM_ENABLE;
6263+
62526264 tw32_f(MAC_RX_MODE, tp->rx_mode);
62536265 udelay(10);
62546266
@@ -7907,7 +7919,8 @@ static int tg3_set_tx_csum(struct net_device *dev, u32 data) · 1652 unmodified lines
79077919 return 0;
79087920 }
79097921
7910− if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
7922+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
7923+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
79117924 ethtool_op_set_tx_hw_csum(dev, data);
79127925 else
79137926 ethtool_op_set_tx_csum(dev, data);
@@ -8332,7 +8345,8 @@ static int tg3_test_memory(struct tg3 *tp) · 418 unmodified lines
83328345 int i;
83338346
83348347 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
8335− if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
8348+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
8349+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
83368350 mem_tbl = mem_tbl_5755;
83378351 else
83388352 mem_tbl = mem_tbl_5705;
@@ -8924,6 +8938,47 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp) · 585 unmodified lines
89248938 }
89258939 }
89268940
8941+static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
8942+{
8943+ u32 nvcfg1;
8944+
8945+ nvcfg1 = tr32(NVRAM_CFG1);
8946+
8947+ /* NVRAM protection for TPM */
8948+ if (nvcfg1 & (1 << 27))
8949+ tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
8950+
8951+ switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) {
8952+ case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ:
8953+ case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ:
8954+ tp->nvram_jedecnum = JEDEC_ATMEL;
8955+ tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
8956+ tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;
8957+
8958+ nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
8959+ tw32(NVRAM_CFG1, nvcfg1);
8960+ break;
8961+ case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
8962+ case FLASH_5755VENDOR_ATMEL_FLASH_1:
8963+ case FLASH_5755VENDOR_ATMEL_FLASH_2:
8964+ case FLASH_5755VENDOR_ATMEL_FLASH_3:
8965+ case FLASH_5755VENDOR_ATMEL_FLASH_4:
8966+ tp->nvram_jedecnum = JEDEC_ATMEL;
8967+ tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
8968+ tp->tg3_flags2 |= TG3_FLG2_FLASH;
8969+ tp->nvram_pagesize = 264;
8970+ break;
8971+ case FLASH_5752VENDOR_ST_M45PE10:
8972+ case FLASH_5752VENDOR_ST_M45PE20:
8973+ case FLASH_5752VENDOR_ST_M45PE40:
8974+ tp->nvram_jedecnum = JEDEC_ST;
8975+ tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
8976+ tp->tg3_flags2 |= TG3_FLG2_FLASH;
8977+ tp->nvram_pagesize = 256;
8978+ break;
8979+ }
8980+}
8981+
89278982 static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp)
89288983 {
89298984 u32 nvcfg1;
@@ -8997,6 +9052,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp) · 67 unmodified lines
89979052
89989053 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
89999054 tg3_get_5752_nvram_info(tp);
9055+ else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
9056+ tg3_get_5755_nvram_info(tp);
90009057 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
90019058 tg3_get_5787_nvram_info(tp);
90029059 else
@@ -9310,6 +9367,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, · 307 unmodified lines
93109367 nvram_cmd |= NVRAM_CMD_LAST;
93119368
93129369 if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) &&
9370+ (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) &&
93139371 (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) &&
93149372 (tp->nvram_jedecnum == JEDEC_ST) &&
93159373 (nvram_cmd & NVRAM_CMD_FIRST)) {
@@ -10044,6 +10102,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) · 728 unmodified lines
1004410102
1004510103 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
1004610104 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
10105+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
1004710106 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 ||
1004810107 (tp->tg3_flags2 & TG3_FLG2_5780_CLASS))
1004910108 tp->tg3_flags2 |= TG3_FLG2_5750_PLUS;
@@ -10053,7 +10112,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) · 3 unmodified lines
1005310112 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
1005410113
1005510114 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
10056− if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
10115+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
10116+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
1005710117 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2;
1005810118 tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI;
1005910119 } else
@@ -10063,6 +10123,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) · 3 unmodified lines
1006310123 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
1006410124 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 &&
1006510125 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 &&
10126+ GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755 &&
1006610127 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)
1006710128 tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE;
1006810129
@@ -10219,6 +10280,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) · 150 unmodified lines
1021910280 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
1022010281 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
1022110282
10283+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
10284+ tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL;
10285+
1022210286 /* Force the chip into D0. */
1022310287 err = tg3_set_power_state(tp, PCI_D0);
1022410288 if (err) {
@@ -10274,6 +10338,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) · 49 unmodified lines
1027410338 tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG;
1027510339
1027610340 if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) &&
10341+ (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) &&
1027710342 (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787))
1027810343 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;
1027910344
@@ -10413,7 +10478,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) · 133 unmodified lines
1041310478 /* All chips before 5787 can get confused if TX buffers
1041410479 * straddle the 4GB address boundary in some cases.
1041510480 */
10416− if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
10481+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
10482+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
1041710483 tp->dev->hard_start_xmit = tg3_start_xmit;
1041810484 else
1041910485 tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug;
@@ -11002,6 +11068,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp) · 582 unmodified lines
1100211068 case PHY_ID_BCM5752: return "5752";
1100311069 case PHY_ID_BCM5714: return "5714";
1100411070 case PHY_ID_BCM5780: return "5780";
11071+ case PHY_ID_BCM5755: return "5755";
1100511072 case PHY_ID_BCM5787: return "5787";
1100611073 case PHY_ID_BCM8002: return "8002/serdes";
1100711074 case 0: return "serdes";
@@ -11350,7 +11417,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev, · 342 unmodified lines
1135011417 * checksumming.
1135111418 */
1135211419 if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) {
11353− if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
11420+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
11421+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
1135411422 dev->features |= NETIF_F_HW_CSUM;
1135511423 else
1135611424 dev->features |= NETIF_F_IP_CSUM;
drivers/net/tg3.h+8−1
@@ -138,6 +138,7 @@ · 137 unmodified lines
138138 #define ASIC_REV_5752 0x06
139139 #define ASIC_REV_5780 0x08
140140 #define ASIC_REV_5714 0x09
141+#define ASIC_REV_5755 0x0a
141142 #define ASIC_REV_5787 0x0b
142143 #define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
143144 #define CHIPREV_5700_AX 0x70
@@ -456,6 +457,7 @@ · 312 unmodified lines
456457 #define RX_MODE_PROMISC 0x00000100
457458 #define RX_MODE_NO_CRC_CHECK 0x00000200
458459 #define RX_MODE_KEEP_VLAN_TAG 0x00000400
460+#define RX_MODE_IPV6_CSUM_ENABLE 0x01000000
459461 #define MAC_RX_STATUS 0x0000046c
460462 #define RX_STATUS_REMOTE_TX_XOFFED 0x00000001
461463 #define RX_STATUS_XOFF_RCVD 0x00000002
@@ -1340,6 +1342,7 @@ · 878 unmodified lines
13401342 #define GRC_LCLCTRL_CLEARINT 0x00000002
13411343 #define GRC_LCLCTRL_SETINT 0x00000004
13421344 #define GRC_LCLCTRL_INT_ON_ATTN 0x00000008
1345+#define GRC_LCLCTRL_GPIO_UART_SEL 0x00000010 /* 5755 only */
13431346 #define GRC_LCLCTRL_USE_SIG_DETECT 0x00000010 /* 5714/5780 only */
13441347 #define GRC_LCLCTRL_USE_EXT_SIG_DETECT 0x00000020 /* 5714/5780 only */
13451348 #define GRC_LCLCTRL_GPIO_INPUT3 0x00000020
@@ -1441,6 +1444,9 @@ · 95 unmodified lines
14411444 #define FLASH_5755VENDOR_ATMEL_FLASH_1 0x03400001
14421445 #define FLASH_5755VENDOR_ATMEL_FLASH_2 0x03400002
14431446 #define FLASH_5755VENDOR_ATMEL_FLASH_3 0x03400000
1447+#define FLASH_5755VENDOR_ATMEL_FLASH_4 0x00000003
1448+#define FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ 0x03c00003
1449+#define FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ 0x03c00002
14441450 #define FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ 0x03000003
14451451 #define FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ 0x03000002
14461452 #define FLASH_5787VENDOR_MICRO_EEPROM_64KHZ 0x03000000
@@ -2259,6 +2265,7 @@ struct tg3 { · 812 unmodified lines
22592265 #define PHY_ID_BCM5752 0x60008100
22602266 #define PHY_ID_BCM5714 0x60008340
22612267 #define PHY_ID_BCM5780 0x60008350
2268+#define PHY_ID_BCM5755 0xbc050cc0
22622269 #define PHY_ID_BCM5787 0xbc050ce0
22632270 #define PHY_ID_BCM8002 0x60010140
22642271 #define PHY_ID_INVALID 0xffffffff
@@ -2286,7 +2293,7 @@ struct tg3 { · 21 unmodified lines
22862293 (X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \
22872294 (X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \
22882295 (X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \
2289− (X) == PHY_ID_BCM8002)
2296+ (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM8002)
22902297
22912298 struct tg3_hw_stats *hw_stats;
22922299 dma_addr_t stats_mapping;
include/linux/pci_ids.h+2−0
@@ -1864,11 +1864,13 @@ · 1863 unmodified lines
18641864 #define PCI_DEVICE_ID_TIGON3_5780S 0x166b
18651865 #define PCI_DEVICE_ID_TIGON3_5705F 0x166e
18661866 #define PCI_DEVICE_ID_TIGON3_5754M 0x1672
1867+#define PCI_DEVICE_ID_TIGON3_5755M 0x1673
18671868 #define PCI_DEVICE_ID_TIGON3_5750 0x1676
18681869 #define PCI_DEVICE_ID_TIGON3_5751 0x1677
18691870 #define PCI_DEVICE_ID_TIGON3_5715 0x1678
18701871 #define PCI_DEVICE_ID_TIGON3_5715S 0x1679
18711872 #define PCI_DEVICE_ID_TIGON3_5754 0x167a
1873+#define PCI_DEVICE_ID_TIGON3_5755 0x167b
18721874 #define PCI_DEVICE_ID_TIGON3_5750M 0x167c
18731875 #define PCI_DEVICE_ID_TIGON3_5751M 0x167d
18741876 #define PCI_DEVICE_ID_TIGON3_5751F 0x167e
include/linux/rtnetlink.h+3−1
@@ -839,6 +839,7 @@ enum · 838 unmodified lines
839839 #define RTMGRP_IPV4_IFADDR 0x10
840840 #define RTMGRP_IPV4_MROUTE 0x20
841841 #define RTMGRP_IPV4_ROUTE 0x40
842+#define RTMGRP_IPV4_RULE 0x80
842843
843844 #define RTMGRP_IPV6_IFADDR 0x100
844845 #define RTMGRP_IPV6_MROUTE 0x200
@@ -869,7 +870,8 @@ enum rtnetlink_groups { · 24 unmodified lines
869870 #define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
870871 RTNLGRP_IPV4_ROUTE,
871872 #define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
872− RTNLGRP_NOP1,
873+ RTNLGRP_IPV4_RULE,
874+#define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
873875 RTNLGRP_IPV6_IFADDR,
874876 #define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
875877 RTNLGRP_IPV6_MROUTE,
net/core/pktgen.c+147−11
@@ -106,6 +106,9 @@ · 105 unmodified lines
106106 *
107107 * interruptible_sleep_on_timeout() replaced Nishanth Aravamudan <nacc@us.ibm.com>
108108 * 050103
109+ *
110+ * MPLS support by Steven Whitehouse <steve@chygwyn.com>
111+ *
109112 */
110113 #include <linux/sys.h>
111114 #include <linux/types.h>
@@ -154,7 +157,7 @@ · 42 unmodified lines
154157 #include <asm/div64.h> /* do_div */
155158 #include <asm/timex.h>
156159
157−#define VERSION "pktgen v2.66: Packet Generator for packet performance testing.\n"
160+#define VERSION "pktgen v2.67: Packet Generator for packet performance testing.\n"
158161
159162 /* #define PG_DEBUG(a) a */
160163 #define PG_DEBUG(a)
@@ -162,6 +165,8 @@ · 1 unmodified line
162165 /* The buckets are exponential in 'width' */
163166 #define LAT_BUCKETS_MAX 32
164167 #define IP_NAME_SZ 32
168+#define MAX_MPLS_LABELS 16 /* This is the max label stack depth */
169+#define MPLS_STACK_BOTTOM __constant_htonl(0x00000100)
165170
166171 /* Device flag bits */
167172 #define F_IPSRC_RND (1<<0) /* IP-Src Random */
@@ -172,6 +177,7 @@ · 4 unmodified lines
172177 #define F_MACDST_RND (1<<5) /* MAC-Dst Random */
173178 #define F_TXSIZE_RND (1<<6) /* Transmit size is random */
174179 #define F_IPV6 (1<<7) /* Interface in IPV6 Mode */
180+#define F_MPLS_RND (1<<8) /* Random MPLS labels */
175181
176182 /* Thread control flag bits */
177183 #define T_TERMINATE (1<<0)
@@ -278,6 +284,10 @@ struct pktgen_dev { · 100 unmodified lines
278284 __u16 udp_dst_min; /* inclusive, dest UDP port */
279285 __u16 udp_dst_max; /* exclusive, dest UDP port */
280286
287+ /* MPLS */
288+ unsigned nr_labels; /* Depth of stack, 0 = no MPLS */
289+ __be32 labels[MAX_MPLS_LABELS];
290+
281291 __u32 src_mac_count; /* How many MACs to iterate through */
282292 __u32 dst_mac_count; /* How many MACs to iterate through */
283293
@@ -623,9 +633,19 @@ static int pktgen_if_show(struct seq_file *seq, void *v) · 339 unmodified lines
623633 pkt_dev->udp_dst_min, pkt_dev->udp_dst_max);
624634
625635 seq_printf(seq,
626− " src_mac_count: %d dst_mac_count: %d \n Flags: ",
636+ " src_mac_count: %d dst_mac_count: %d\n",
627637 pkt_dev->src_mac_count, pkt_dev->dst_mac_count);
628638
639+ if (pkt_dev->nr_labels) {
640+ unsigned i;
641+ seq_printf(seq, " mpls: ");
642+ for(i = 0; i < pkt_dev->nr_labels; i++)
643+ seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]),
644+ i == pkt_dev->nr_labels-1 ? "\n" : ", ");
645+ }
646+
647+ seq_printf(seq, " Flags: ");
648+
629649 if (pkt_dev->flags & F_IPV6)
630650 seq_printf(seq, "IPV6 ");
631651
@@ -644,6 +664,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v) · 12 unmodified lines
644664 if (pkt_dev->flags & F_UDPDST_RND)
645665 seq_printf(seq, "UDPDST_RND ");
646666
667+ if (pkt_dev->flags & F_MPLS_RND)
668+ seq_printf(seq, "MPLS_RND ");
669+
647670 if (pkt_dev->flags & F_MACSRC_RND)
648671 seq_printf(seq, "MACSRC_RND ");
649672
@@ -691,6 +714,29 @@ static int pktgen_if_show(struct seq_file *seq, void *v) · 41 unmodified lines
691714 return 0;
692715 }
693716
717+
718+static int hex32_arg(const char __user *user_buffer, __u32 *num)
719+{
720+ int i = 0;
721+ *num = 0;
722+
723+ for(; i < 8; i++) {
724+ char c;
725+ *num <<= 4;
726+ if (get_user(c, &user_buffer[i]))
727+ return -EFAULT;
728+ if ((c >= '0') && (c <= '9'))
729+ *num |= c - '0';
730+ else if ((c >= 'a') && (c <= 'f'))
731+ *num |= c - 'a' + 10;
732+ else if ((c >= 'A') && (c <= 'F'))
733+ *num |= c - 'A' + 10;
734+ else
735+ break;
736+ }
737+ return i;
738+}
739+
694740 static int count_trail_chars(const char __user * user_buffer,
695741 unsigned int maxlen)
696742 {
@@ -759,6 +805,35 @@ done_str: · 62 unmodified lines
759805 return i;
760806 }
761807
808+static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev)
809+{
810+ unsigned n = 0;
811+ char c;
812+ ssize_t i = 0;
813+ int len;
814+
815+ pkt_dev->nr_labels = 0;
816+ do {
817+ __u32 tmp;
818+ len = hex32_arg(&buffer[i], &tmp);
819+ if (len <= 0)
820+ return len;
821+ pkt_dev->labels[n] = htonl(tmp);
822+ if (pkt_dev->labels[n] & MPLS_STACK_BOTTOM)
823+ pkt_dev->flags |= F_MPLS_RND;
824+ i += len;
825+ if (get_user(c, &buffer[i]))
826+ return -EFAULT;
827+ i++;
828+ n++;
829+ if (n >= MAX_MPLS_LABELS)
830+ return -E2BIG;
831+ } while(c == ',');
832+
833+ pkt_dev->nr_labels = n;
834+ return i;
835+}
836+
762837 static ssize_t pktgen_if_write(struct file *file,
763838 const char __user * user_buffer, size_t count,
764839 loff_t * offset)
@@ -1059,6 +1134,12 @@ static ssize_t pktgen_if_write(struct file *file, · 294 unmodified lines
10591134 else if (strcmp(f, "!MACDST_RND") == 0)
10601135 pkt_dev->flags &= ~F_MACDST_RND;
10611136
1137+ else if (strcmp(f, "MPLS_RND") == 0)
1138+ pkt_dev->flags |= F_MPLS_RND;
1139+
1140+ else if (strcmp(f, "!MPLS_RND") == 0)
1141+ pkt_dev->flags &= ~F_MPLS_RND;
1142+
10621143 else {
10631144 sprintf(pg_result,
10641145 "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s",
@@ -1354,6 +1435,19 @@ static ssize_t pktgen_if_write(struct file *file, · 289 unmodified lines
13541435 return count;
13551436 }
13561437
1438+ if (!strcmp(name, "mpls")) {
1439+ unsigned n, offset;
1440+ len = get_labels(&user_buffer[i], pkt_dev);
1441+ if (len < 0) { return len; }
1442+ i += len;
1443+ offset = sprintf(pg_result, "OK: mpls=");
1444+ for(n = 0; n < pkt_dev->nr_labels; n++)
1445+ offset += sprintf(pg_result + offset,
1446+ "%08x%s", ntohl(pkt_dev->labels[n]),
1447+ n == pkt_dev->nr_labels-1 ? "" : ",");
1448+ return count;
1449+ }
1450+
13571451 sprintf(pkt_dev->result, "No such parameter \"%s\"", name);
13581452 return -EINVAL;
13591453 }
@@ -1846,6 +1940,15 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) · 486 unmodified lines
18461940 pkt_dev->hh[1] = tmp;
18471941 }
18481942
1943+ if (pkt_dev->flags & F_MPLS_RND) {
1944+ unsigned i;
1945+ for(i = 0; i < pkt_dev->nr_labels; i++)
1946+ if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
1947+ pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
1948+ (pktgen_random() &
1949+ htonl(0x000fffff));
1950+ }
1951+
18491952 if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) {
18501953 if (pkt_dev->flags & F_UDPSRC_RND)
18511954 pkt_dev->cur_udp_src =
@@ -1968,6 +2071,16 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) · 116 unmodified lines
19682071 pkt_dev->flows[flow].count++;
19692072 }
19702073
2074+static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev)
2075+{
2076+ unsigned i;
2077+ for(i = 0; i < pkt_dev->nr_labels; i++) {
2078+ *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM;
2079+ }
2080+ mpls--;
2081+ *mpls |= MPLS_STACK_BOTTOM;
2082+}
2083+
19712084 static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
19722085 struct pktgen_dev *pkt_dev)
19732086 {
@@ -1977,6 +2090,11 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, · 3 unmodified lines
19772090 int datalen, iplen;
19782091 struct iphdr *iph;
19792092 struct pktgen_hdr *pgh = NULL;
2093+ __be16 protocol = __constant_htons(ETH_P_IP);
2094+ __be32 *mpls;
2095+
2096+ if (pkt_dev->nr_labels)
2097+ protocol = __constant_htons(ETH_P_MPLS_UC);
19802098
19812099 /* Update any of the values, used when we're incrementing various
19822100 * fields.
@@ -1984,7 +2102,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, · 1 unmodified line
19842102 mod_cur_headers(pkt_dev);
19852103
19862104 datalen = (odev->hard_header_len + 16) & ~0xf;
1987− skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen, GFP_ATOMIC);
2105+ skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen +
2106+ pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC);
19882107 if (!skb) {
19892108 sprintf(pkt_dev->result, "No memory");
19902109 return NULL;
@@ -1994,13 +2113,18 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, · 3 unmodified lines
19942113
19952114 /* Reserve for ethernet and IP header */
19962115 eth = (__u8 *) skb_push(skb, 14);
2116+ mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32));
2117+ if (pkt_dev->nr_labels)
2118+ mpls_push(mpls, pkt_dev);
19972119 iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr));
19982120 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
19992121
20002122 memcpy(eth, pkt_dev->hh, 12);
2001− *(u16 *) & eth[12] = __constant_htons(ETH_P_IP);
2123+ *(u16 *) & eth[12] = protocol;
20022124
2003− datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8; /* Eth + IPh + UDPh */
2125+ /* Eth + IPh + UDPh + mpls */
2126+ datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 -
2127+ pkt_dev->nr_labels*sizeof(u32);
20042128 if (datalen < sizeof(struct pktgen_hdr))
20052129 datalen = sizeof(struct pktgen_hdr);
20062130
@@ -2021,8 +2145,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev, · 14 unmodified lines
20212145 iph->tot_len = htons(iplen);
20222146 iph->check = 0;
20232147 iph->check = ip_fast_csum((void *)iph, iph->ihl);
2024− skb->protocol = __constant_htons(ETH_P_IP);
2025− skb->mac.raw = ((u8 *) iph) - 14;
2148+ skb->protocol = protocol;
2149+ skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32);
20262150 skb->dev = odev;
20272151 skb->pkt_type = PACKET_HOST;
20282152
@@ -2274,13 +2398,19 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, · 245 unmodified lines
22742398 int datalen;
22752399 struct ipv6hdr *iph;
22762400 struct pktgen_hdr *pgh = NULL;
2401+ __be16 protocol = __constant_htons(ETH_P_IPV6);
2402+ __be32 *mpls;
2403+
2404+ if (pkt_dev->nr_labels)
2405+ protocol = __constant_htons(ETH_P_MPLS_UC);
22772406
22782407 /* Update any of the values, used when we're incrementing various
22792408 * fields.
22802409 */
22812410 mod_cur_headers(pkt_dev);
22822411
2283− skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16, GFP_ATOMIC);
2412+ skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16 +
2413+ pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC);
22842414 if (!skb) {
22852415 sprintf(pkt_dev->result, "No memory");
22862416 return NULL;
@@ -2290,13 +2420,19 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, · 3 unmodified lines
22902420
22912421 /* Reserve for ethernet and IP header */
22922422 eth = (__u8 *) skb_push(skb, 14);
2423+ mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32));
2424+ if (pkt_dev->nr_labels)
2425+ mpls_push(mpls, pkt_dev);
22932426 iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr));
22942427 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
22952428
22962429 memcpy(eth, pkt_dev->hh, 12);
22972430 *(u16 *) & eth[12] = __constant_htons(ETH_P_IPV6);
22982431
2299− datalen = pkt_dev->cur_pkt_size - 14 - sizeof(struct ipv6hdr) - sizeof(struct udphdr); /* Eth + IPh + UDPh */
2432+ /* Eth + IPh + UDPh + mpls */
2433+ datalen = pkt_dev->cur_pkt_size - 14 -
2434+ sizeof(struct ipv6hdr) - sizeof(struct udphdr) -
2435+ pkt_dev->nr_labels*sizeof(u32);
23002436
23012437 if (datalen < sizeof(struct pktgen_hdr)) {
23022438 datalen = sizeof(struct pktgen_hdr);
@@ -2320,8 +2456,8 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev, · 17 unmodified lines
23202456 ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr);
23212457 ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr);
23222458
2323− skb->mac.raw = ((u8 *) iph) - 14;
2324− skb->protocol = __constant_htons(ETH_P_IPV6);
2459+ skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32);
2460+ skb->protocol = protocol;
23252461 skb->dev = odev;
23262462 skb->pkt_type = PACKET_HOST;
23272463
net/ipv4/fib_rules.c+24−3
@@ -104,6 +104,8 @@ static struct hlist_head fib_rules; · 103 unmodified lines
104104
105105 /* writer func called from netlink -- rtnl_sem hold*/
106106
107+static void rtmsg_rule(int, struct fib_rule *);
108+
107109 int inet_rtm_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
108110 {
109111 struct rtattr **rta = arg;
@@ -131,6 +133,7 @@ int inet_rtm_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) · 21 unmodified lines
131133
132134 hlist_del_rcu(&r->hlist);
133135 r->r_dead = 1;
136+ rtmsg_rule(RTM_DELRULE, r);
134137 fib_rule_put(r);
135138 err = 0;
136139 break;
@@ -253,6 +256,7 @@ int inet_rtm_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) · 116 unmodified lines
253256 else
254257 hlist_add_before_rcu(&new_r->hlist, &r->hlist);
255258
259+ rtmsg_rule(RTM_NEWRULE, new_r);
256260 return 0;
257261 }
258262
@@ -382,14 +386,14 @@ static struct notifier_block fib_rules_notifier = { · 123 unmodified lines
382386
383387 static __inline__ int inet_fill_rule(struct sk_buff *skb,
384388 struct fib_rule *r,
385− struct netlink_callback *cb,
389+ u32 pid, u32 seq, int event,
386390 unsigned int flags)
387391 {
388392 struct rtmsg *rtm;
389393 struct nlmsghdr *nlh;
390394 unsigned char *b = skb->tail;
391395
392− nlh = NLMSG_NEW_ANSWER(skb, cb, RTM_NEWRULE, sizeof(*rtm), flags);
396+ nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags);
393397 rtm = NLMSG_DATA(nlh);
394398 rtm->rtm_family = AF_INET;
395399 rtm->rtm_dst_len = r->r_dst_len;
@@ -430,6 +434,21 @@ rtattr_failure: · 34 unmodified lines
430434
431435 /* callers should hold rtnl semaphore */
432436
437+static void rtmsg_rule(int event, struct fib_rule *r)
438+{
439+ int size = NLMSG_SPACE(sizeof(struct rtmsg) + 128);
440+ struct sk_buff *skb = alloc_skb(size, GFP_KERNEL);
441+
442+ if (!skb)
443+ netlink_set_err(rtnl, 0, RTNLGRP_IPV4_RULE, ENOBUFS);
444+ else if (inet_fill_rule(skb, r, 0, 0, event, 0) < 0) {
445+ kfree_skb(skb);
446+ netlink_set_err(rtnl, 0, RTNLGRP_IPV4_RULE, EINVAL);
447+ } else {
448+ netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV4_RULE, GFP_KERNEL);
449+ }
450+}
451+
433452 int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb)
434453 {
435454 int idx = 0;
@@ -442,7 +461,9 @@ int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb) · 6 unmodified lines
442461
443462 if (idx < s_idx)
444463 continue;
445− if (inet_fill_rule(skb, r, cb, NLM_F_MULTI) < 0)
464+ if (inet_fill_rule(skb, r, NETLINK_CB(cb->skb).pid,
465+ cb->nlh->nlmsg_seq,
466+ RTM_NEWRULE, NLM_F_MULTI) < 0)
446467 break;
447468 idx++;
448469 }
net/ipv6/ip6_output.c+1−1
@@ -161,7 +161,7 @@ int ip6_output(struct sk_buff *skb) · 160 unmodified lines
161161 int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
162162 struct ipv6_txoptions *opt, int ipfragok)
163163 {
164− struct ipv6_pinfo *np = sk ? inet6_sk(sk) : NULL;
164+ struct ipv6_pinfo *np = inet6_sk(sk);
165165 struct in6_addr *first_hop = &fl->fl6_dst;
166166 struct dst_entry *dst = skb->dst;
167167 struct ipv6hdr *hdr;
net/sched/cls_u32.c+2−4
@@ -347,8 +347,7 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n) · 346 unmodified lines
347347 if (n->ht_down)
348348 n->ht_down->refcnt--;
349349 #ifdef CONFIG_CLS_U32_PERF
350− if (n)
351− kfree(n->pf);
350+ kfree(n->pf);
352351 #endif
353352 kfree(n);
354353 return 0;
@@ -680,8 +679,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, · 325 unmodified lines
680679 return 0;
681680 }
682681 #ifdef CONFIG_CLS_U32_PERF
683− if (n)
684− kfree(n->pf);
682+ kfree(n->pf);
685683 #endif
686684 kfree(n);
687685 return err;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t