aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bcma/bcma.h55
-rw-r--r--include/linux/bcma/bcma_driver_chipcommon.h6
-rw-r--r--include/linux/bcma/bcma_regs.h1
-rw-r--r--include/linux/cn_proc.h4
-rw-r--r--include/linux/filter.h15
-rw-r--r--include/linux/icmpv6.h18
-rw-r--r--include/linux/ieee80211.h125
-rw-r--r--include/linux/if_arp.h12
-rw-r--r--include/linux/if_team.h25
-rw-r--r--include/linux/if_vlan.h56
-rw-r--r--include/linux/ktime.h18
-rw-r--r--include/linux/micrel_phy.h1
-rw-r--r--include/linux/mlx4/cmd.h6
-rw-r--r--include/linux/mlx4/cq.h16
-rw-r--r--include/linux/mlx4/device.h13
-rw-r--r--include/linux/mv643xx_eth.h1
-rw-r--r--include/linux/netdev_features.h27
-rw-r--r--include/linux/netdevice.h79
-rw-r--r--include/linux/netfilter.h5
-rw-r--r--include/linux/netfilter/ipset/ip_set.h126
-rw-r--r--include/linux/netfilter/ipset/ip_set_ahash.h1241
-rw-r--r--include/linux/netfilter/ipset/ip_set_bitmap.h6
-rw-r--r--include/linux/netfilter/ipset/ip_set_timeout.h102
-rw-r--r--include/linux/netfilter/ipset/pfxlen.h9
-rw-r--r--include/linux/netfilter/nfnetlink.h11
-rw-r--r--include/linux/netlink.h11
-rw-r--r--include/linux/netpoll.h2
-rw-r--r--include/linux/of_net.h10
-rw-r--r--include/linux/openvswitch.h431
-rw-r--r--include/linux/pci.h5
-rw-r--r--include/linux/phy.h10
-rw-r--r--include/linux/platform_data/brcmfmac-sdio.h124
-rw-r--r--include/linux/platform_data/cpsw.h2
-rw-r--r--include/linux/rtnetlink.h9
-rw-r--r--include/linux/sctp.h6
-rw-r--r--include/linux/sh_eth.h1
-rw-r--r--include/linux/skbuff.h95
-rw-r--r--include/linux/sock_diag.h3
-rw-r--r--include/linux/socket.h1
-rw-r--r--include/linux/spi/at86rf230.h14
-rw-r--r--include/linux/ssb/ssb.h60
-rw-r--r--include/linux/ssb/ssb_regs.h10
-rw-r--r--include/linux/tcp.h21
-rw-r--r--include/linux/usb/usbnet.h2
-rw-r--r--include/linux/virtio.h6
-rw-r--r--include/linux/vm_sockets.h23
46 files changed, 933 insertions, 1891 deletions
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index e0ce311011c0..f14a98a79c9d 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -134,6 +134,7 @@ struct bcma_host_ops {
134#define BCMA_CORE_I2S 0x834 134#define BCMA_CORE_I2S 0x834
135#define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */ 135#define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
136#define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */ 136#define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
137#define BCMA_CORE_ARM_CR4 0x83e
137#define BCMA_CORE_DEFAULT 0xFFF 138#define BCMA_CORE_DEFAULT 0xFFF
138 139
139#define BCMA_MAX_NR_CORES 16 140#define BCMA_MAX_NR_CORES 16
@@ -173,6 +174,60 @@ struct bcma_host_ops {
173#define BCMA_CHIP_ID_BCM53572 53572 174#define BCMA_CHIP_ID_BCM53572 53572
174#define BCMA_PKG_ID_BCM47188 9 175#define BCMA_PKG_ID_BCM47188 9
175 176
177/* Board types (on PCI usually equals to the subsystem dev id) */
178/* BCM4313 */
179#define BCMA_BOARD_TYPE_BCM94313BU 0X050F
180#define BCMA_BOARD_TYPE_BCM94313HM 0X0510
181#define BCMA_BOARD_TYPE_BCM94313EPA 0X0511
182#define BCMA_BOARD_TYPE_BCM94313HMG 0X051C
183/* BCM4716 */
184#define BCMA_BOARD_TYPE_BCM94716NR2 0X04CD
185/* BCM43224 */
186#define BCMA_BOARD_TYPE_BCM943224X21 0X056E
187#define BCMA_BOARD_TYPE_BCM943224X21_FCC 0X00D1
188#define BCMA_BOARD_TYPE_BCM943224X21B 0X00E9
189#define BCMA_BOARD_TYPE_BCM943224M93 0X008B
190#define BCMA_BOARD_TYPE_BCM943224M93A 0X0090
191#define BCMA_BOARD_TYPE_BCM943224X16 0X0093
192#define BCMA_BOARD_TYPE_BCM94322X9 0X008D
193#define BCMA_BOARD_TYPE_BCM94322M35E 0X008E
194/* BCM43228 */
195#define BCMA_BOARD_TYPE_BCM943228BU8 0X0540
196#define BCMA_BOARD_TYPE_BCM943228BU9 0X0541
197#define BCMA_BOARD_TYPE_BCM943228BU 0X0542
198#define BCMA_BOARD_TYPE_BCM943227HM4L 0X0543
199#define BCMA_BOARD_TYPE_BCM943227HMB 0X0544
200#define BCMA_BOARD_TYPE_BCM943228HM4L 0X0545
201#define BCMA_BOARD_TYPE_BCM943228SD 0X0573
202/* BCM4331 */
203#define BCMA_BOARD_TYPE_BCM94331X19 0X00D6
204#define BCMA_BOARD_TYPE_BCM94331X28 0X00E4
205#define BCMA_BOARD_TYPE_BCM94331X28B 0X010E
206#define BCMA_BOARD_TYPE_BCM94331PCIEBT3AX 0X00E4
207#define BCMA_BOARD_TYPE_BCM94331X12_2G 0X00EC
208#define BCMA_BOARD_TYPE_BCM94331X12_5G 0X00ED
209#define BCMA_BOARD_TYPE_BCM94331X29B 0X00EF
210#define BCMA_BOARD_TYPE_BCM94331CSAX 0X00EF
211#define BCMA_BOARD_TYPE_BCM94331X19C 0X00F5
212#define BCMA_BOARD_TYPE_BCM94331X33 0X00F4
213#define BCMA_BOARD_TYPE_BCM94331BU 0X0523
214#define BCMA_BOARD_TYPE_BCM94331S9BU 0X0524
215#define BCMA_BOARD_TYPE_BCM94331MC 0X0525
216#define BCMA_BOARD_TYPE_BCM94331MCI 0X0526
217#define BCMA_BOARD_TYPE_BCM94331PCIEBT4 0X0527
218#define BCMA_BOARD_TYPE_BCM94331HM 0X0574
219#define BCMA_BOARD_TYPE_BCM94331PCIEDUAL 0X059B
220#define BCMA_BOARD_TYPE_BCM94331MCH5 0X05A9
221#define BCMA_BOARD_TYPE_BCM94331CS 0X05C6
222#define BCMA_BOARD_TYPE_BCM94331CD 0X05DA
223/* BCM53572 */
224#define BCMA_BOARD_TYPE_BCM953572BU 0X058D
225#define BCMA_BOARD_TYPE_BCM953572NR2 0X058E
226#define BCMA_BOARD_TYPE_BCM947188NR2 0X058F
227#define BCMA_BOARD_TYPE_BCM953572SDRNR2 0X0590
228/* BCM43142 */
229#define BCMA_BOARD_TYPE_BCM943142HM 0X05E0
230
176struct bcma_device { 231struct bcma_device {
177 struct bcma_bus *bus; 232 struct bcma_bus *bus;
178 struct bcma_device_id id; 233 struct bcma_device_id id;
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index 8390c474f69a..b8b09eac60a4 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -104,6 +104,7 @@
104#define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */ 104#define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
105#define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */ 105#define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
106#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */ 106#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
107#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
107#define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */ 108#define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
108#define BCMA_CC_JCMD_START 0x80000000 109#define BCMA_CC_JCMD_START 0x80000000
109#define BCMA_CC_JCMD_BUSY 0x80000000 110#define BCMA_CC_JCMD_BUSY 0x80000000
@@ -315,6 +316,9 @@
315#define BCMA_CC_PMU_CTL 0x0600 /* PMU control */ 316#define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
316#define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */ 317#define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
317#define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16 318#define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
319#define BCMA_CC_PMU_CTL_RES 0x00006000 /* reset control mask */
320#define BCMA_CC_PMU_CTL_RES_SHIFT 13
321#define BCMA_CC_PMU_CTL_RES_RELOAD 0x2 /* reload POR values */
318#define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400 322#define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
319#define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */ 323#define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
320#define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */ 324#define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
@@ -607,6 +611,8 @@ void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
607 611
608extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks); 612extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
609 613
614extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
615
610void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value); 616void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
611 617
612u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask); 618u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask);
diff --git a/include/linux/bcma/bcma_regs.h b/include/linux/bcma/bcma_regs.h
index 7e8104bb7a7e..917dcd7965e7 100644
--- a/include/linux/bcma/bcma_regs.h
+++ b/include/linux/bcma/bcma_regs.h
@@ -37,6 +37,7 @@
37#define BCMA_IOST_BIST_DONE 0x8000 37#define BCMA_IOST_BIST_DONE 0x8000
38#define BCMA_RESET_CTL 0x0800 38#define BCMA_RESET_CTL 0x0800
39#define BCMA_RESET_CTL_RESET 0x0001 39#define BCMA_RESET_CTL_RESET 0x0001
40#define BCMA_RESET_ST 0x0804
40 41
41/* BCMA PCI config space registers. */ 42/* BCMA PCI config space registers. */
42#define BCMA_PCI_PMCSR 0x44 43#define BCMA_PCI_PMCSR 0x44
diff --git a/include/linux/cn_proc.h b/include/linux/cn_proc.h
index 2c1bc1ea04ee..1d5b02a96c46 100644
--- a/include/linux/cn_proc.h
+++ b/include/linux/cn_proc.h
@@ -26,6 +26,7 @@ void proc_id_connector(struct task_struct *task, int which_id);
26void proc_sid_connector(struct task_struct *task); 26void proc_sid_connector(struct task_struct *task);
27void proc_ptrace_connector(struct task_struct *task, int which_id); 27void proc_ptrace_connector(struct task_struct *task, int which_id);
28void proc_comm_connector(struct task_struct *task); 28void proc_comm_connector(struct task_struct *task);
29void proc_coredump_connector(struct task_struct *task);
29void proc_exit_connector(struct task_struct *task); 30void proc_exit_connector(struct task_struct *task);
30#else 31#else
31static inline void proc_fork_connector(struct task_struct *task) 32static inline void proc_fork_connector(struct task_struct *task)
@@ -48,6 +49,9 @@ static inline void proc_ptrace_connector(struct task_struct *task,
48 int ptrace_id) 49 int ptrace_id)
49{} 50{}
50 51
52static inline void proc_coredump_connector(struct task_struct *task)
53{}
54
51static inline void proc_exit_connector(struct task_struct *task) 55static inline void proc_exit_connector(struct task_struct *task)
52{} 56{}
53#endif /* CONFIG_PROC_EVENTS */ 57#endif /* CONFIG_PROC_EVENTS */
diff --git a/include/linux/filter.h b/include/linux/filter.h
index c45eabc135e1..c050dcc322a4 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -48,8 +48,22 @@ extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen);
48extern int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, unsigned len); 48extern int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, unsigned len);
49 49
50#ifdef CONFIG_BPF_JIT 50#ifdef CONFIG_BPF_JIT
51#include <stdarg.h>
52#include <linux/linkage.h>
53#include <linux/printk.h>
54
51extern void bpf_jit_compile(struct sk_filter *fp); 55extern void bpf_jit_compile(struct sk_filter *fp);
52extern void bpf_jit_free(struct sk_filter *fp); 56extern void bpf_jit_free(struct sk_filter *fp);
57
58static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
59 u32 pass, void *image)
60{
61 pr_err("flen=%u proglen=%u pass=%u image=%p\n",
62 flen, proglen, pass, image);
63 if (image)
64 print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_ADDRESS,
65 16, 1, image, proglen, false);
66}
53#define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns) 67#define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns)
54#else 68#else
55static inline void bpf_jit_compile(struct sk_filter *fp) 69static inline void bpf_jit_compile(struct sk_filter *fp)
@@ -126,6 +140,7 @@ enum {
126 BPF_S_ANC_SECCOMP_LD_W, 140 BPF_S_ANC_SECCOMP_LD_W,
127 BPF_S_ANC_VLAN_TAG, 141 BPF_S_ANC_VLAN_TAG,
128 BPF_S_ANC_VLAN_TAG_PRESENT, 142 BPF_S_ANC_VLAN_TAG_PRESENT,
143 BPF_S_ANC_PAY_OFFSET,
129}; 144};
130 145
131#endif /* __LINUX_FILTER_H__ */ 146#endif /* __LINUX_FILTER_H__ */
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index b4f6c29caced..630f45335c73 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -11,9 +11,21 @@ static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb)
11 11
12#include <linux/netdevice.h> 12#include <linux/netdevice.h>
13 13
14extern void icmpv6_send(struct sk_buff *skb, 14#if IS_ENABLED(CONFIG_IPV6)
15 u8 type, u8 code, 15extern void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info);
16 __u32 info); 16
17typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info);
18extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn);
19extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn);
20
21#else
22
23static inline void icmpv6_send(struct sk_buff *skb,
24 u8 type, u8 code, __u32 info)
25{
26
27}
28#endif
17 29
18extern int icmpv6_init(void); 30extern int icmpv6_init(void);
19extern int icmpv6_err_convert(u8 type, u8 code, 31extern int icmpv6_err_convert(u8 type, u8 code,
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 7e24fe0cfbcd..06b0ed0154a4 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -113,6 +113,34 @@
113#define IEEE80211_CTL_EXT_SSW_FBACK 0x9000 113#define IEEE80211_CTL_EXT_SSW_FBACK 0x9000
114#define IEEE80211_CTL_EXT_SSW_ACK 0xa000 114#define IEEE80211_CTL_EXT_SSW_ACK 0xa000
115 115
116
117#define IEEE80211_SN_MASK ((IEEE80211_SCTL_SEQ) >> 4)
118#define IEEE80211_MAX_SN IEEE80211_SN_MASK
119#define IEEE80211_SN_MODULO (IEEE80211_MAX_SN + 1)
120
121static inline int ieee80211_sn_less(u16 sn1, u16 sn2)
122{
123 return ((sn1 - sn2) & IEEE80211_SN_MASK) > (IEEE80211_SN_MODULO >> 1);
124}
125
126static inline u16 ieee80211_sn_add(u16 sn1, u16 sn2)
127{
128 return (sn1 + sn2) & IEEE80211_SN_MASK;
129}
130
131static inline u16 ieee80211_sn_inc(u16 sn)
132{
133 return ieee80211_sn_add(sn, 1);
134}
135
136static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
137{
138 return (sn1 - sn2) & IEEE80211_SN_MASK;
139}
140
141#define IEEE80211_SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
142#define IEEE80211_SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
143
116/* miscellaneous IEEE 802.11 constants */ 144/* miscellaneous IEEE 802.11 constants */
117#define IEEE80211_MAX_FRAG_THRESHOLD 2352 145#define IEEE80211_MAX_FRAG_THRESHOLD 2352
118#define IEEE80211_MAX_RTS_THRESHOLD 2353 146#define IEEE80211_MAX_RTS_THRESHOLD 2353
@@ -185,7 +213,7 @@ struct ieee80211_hdr {
185 u8 addr3[6]; 213 u8 addr3[6];
186 __le16 seq_ctrl; 214 __le16 seq_ctrl;
187 u8 addr4[6]; 215 u8 addr4[6];
188} __packed; 216} __packed __aligned(2);
189 217
190struct ieee80211_hdr_3addr { 218struct ieee80211_hdr_3addr {
191 __le16 frame_control; 219 __le16 frame_control;
@@ -194,7 +222,7 @@ struct ieee80211_hdr_3addr {
194 u8 addr2[6]; 222 u8 addr2[6];
195 u8 addr3[6]; 223 u8 addr3[6];
196 __le16 seq_ctrl; 224 __le16 seq_ctrl;
197} __packed; 225} __packed __aligned(2);
198 226
199struct ieee80211_qos_hdr { 227struct ieee80211_qos_hdr {
200 __le16 frame_control; 228 __le16 frame_control;
@@ -204,7 +232,7 @@ struct ieee80211_qos_hdr {
204 u8 addr3[6]; 232 u8 addr3[6];
205 __le16 seq_ctrl; 233 __le16 seq_ctrl;
206 __le16 qos_ctrl; 234 __le16 qos_ctrl;
207} __packed; 235} __packed __aligned(2);
208 236
209/** 237/**
210 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set 238 * ieee80211_has_tods - check if IEEE80211_FCTL_TODS is set
@@ -581,7 +609,7 @@ struct ieee80211s_hdr {
581 __le32 seqnum; 609 __le32 seqnum;
582 u8 eaddr1[6]; 610 u8 eaddr1[6];
583 u8 eaddr2[6]; 611 u8 eaddr2[6];
584} __packed; 612} __packed __aligned(2);
585 613
586/* Mesh flags */ 614/* Mesh flags */
587#define MESH_FLAGS_AE_A4 0x1 615#define MESH_FLAGS_AE_A4 0x1
@@ -645,6 +673,36 @@ struct ieee80211_channel_sw_ie {
645} __packed; 673} __packed;
646 674
647/** 675/**
676 * struct ieee80211_ext_chansw_ie
677 *
678 * This structure represents the "Extended Channel Switch Announcement element"
679 */
680struct ieee80211_ext_chansw_ie {
681 u8 mode;
682 u8 new_operating_class;
683 u8 new_ch_num;
684 u8 count;
685} __packed;
686
687/**
688 * struct ieee80211_sec_chan_offs_ie - secondary channel offset IE
689 * @sec_chan_offs: secondary channel offset, uses IEEE80211_HT_PARAM_CHA_SEC_*
690 * values here
691 * This structure represents the "Secondary Channel Offset element"
692 */
693struct ieee80211_sec_chan_offs_ie {
694 u8 sec_chan_offs;
695} __packed;
696
697/**
698 * struct ieee80211_wide_bw_chansw_ie - wide bandwidth channel switch IE
699 */
700struct ieee80211_wide_bw_chansw_ie {
701 u8 new_channel_width;
702 u8 new_center_freq_seg0, new_center_freq_seg1;
703} __packed;
704
705/**
648 * struct ieee80211_tim 706 * struct ieee80211_tim
649 * 707 *
650 * This structure refers to "Traffic Indication Map information element" 708 * This structure refers to "Traffic Indication Map information element"
@@ -812,12 +870,15 @@ struct ieee80211_mgmt {
812 } __packed wme_action; 870 } __packed wme_action;
813 struct{ 871 struct{
814 u8 action_code; 872 u8 action_code;
815 u8 element_id; 873 u8 variable[0];
816 u8 length;
817 struct ieee80211_channel_sw_ie sw_elem;
818 } __packed chan_switch; 874 } __packed chan_switch;
819 struct{ 875 struct{
820 u8 action_code; 876 u8 action_code;
877 struct ieee80211_ext_chansw_ie data;
878 u8 variable[0];
879 } __packed ext_chan_switch;
880 struct{
881 u8 action_code;
821 u8 dialog_token; 882 u8 dialog_token;
822 u8 element_id; 883 u8 element_id;
823 u8 length; 884 u8 length;
@@ -875,7 +936,7 @@ struct ieee80211_mgmt {
875 } u; 936 } u;
876 } __packed action; 937 } __packed action;
877 } u; 938 } u;
878} __packed; 939} __packed __aligned(2);
879 940
880/* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */ 941/* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */
881#define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 942#define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127
@@ -906,20 +967,20 @@ struct ieee80211_rts {
906 __le16 duration; 967 __le16 duration;
907 u8 ra[6]; 968 u8 ra[6];
908 u8 ta[6]; 969 u8 ta[6];
909} __packed; 970} __packed __aligned(2);
910 971
911struct ieee80211_cts { 972struct ieee80211_cts {
912 __le16 frame_control; 973 __le16 frame_control;
913 __le16 duration; 974 __le16 duration;
914 u8 ra[6]; 975 u8 ra[6];
915} __packed; 976} __packed __aligned(2);
916 977
917struct ieee80211_pspoll { 978struct ieee80211_pspoll {
918 __le16 frame_control; 979 __le16 frame_control;
919 __le16 aid; 980 __le16 aid;
920 u8 bssid[6]; 981 u8 bssid[6];
921 u8 ta[6]; 982 u8 ta[6];
922} __packed; 983} __packed __aligned(2);
923 984
924/* TDLS */ 985/* TDLS */
925 986
@@ -999,6 +1060,26 @@ enum ieee80211_p2p_attr_id {
999 IEEE80211_P2P_ATTR_MAX 1060 IEEE80211_P2P_ATTR_MAX
1000}; 1061};
1001 1062
1063/* Notice of Absence attribute - described in P2P spec 4.1.14 */
1064/* Typical max value used here */
1065#define IEEE80211_P2P_NOA_DESC_MAX 4
1066
1067struct ieee80211_p2p_noa_desc {
1068 u8 count;
1069 __le32 duration;
1070 __le32 interval;
1071 __le32 start_time;
1072} __packed;
1073
1074struct ieee80211_p2p_noa_attr {
1075 u8 index;
1076 u8 oppps_ctwindow;
1077 struct ieee80211_p2p_noa_desc desc[IEEE80211_P2P_NOA_DESC_MAX];
1078} __packed;
1079
1080#define IEEE80211_P2P_OPPPS_ENABLE_BIT BIT(7)
1081#define IEEE80211_P2P_OPPPS_CTWINDOW_MASK 0x7F
1082
1002/** 1083/**
1003 * struct ieee80211_bar - HT Block Ack Request 1084 * struct ieee80211_bar - HT Block Ack Request
1004 * 1085 *
@@ -1290,11 +1371,6 @@ struct ieee80211_vht_operation {
1290} __packed; 1371} __packed;
1291 1372
1292 1373
1293#define IEEE80211_VHT_MCS_ZERO_TO_SEVEN_SUPPORT 0
1294#define IEEE80211_VHT_MCS_ZERO_TO_EIGHT_SUPPORT 1
1295#define IEEE80211_VHT_MCS_ZERO_TO_NINE_SUPPORT 2
1296#define IEEE80211_VHT_MCS_NOT_SUPPORTED 3
1297
1298/* 802.11ac VHT Capabilities */ 1374/* 802.11ac VHT Capabilities */
1299#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000 1375#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895 0x00000000
1300#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001 1376#define IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 0x00000001
@@ -1310,10 +1386,11 @@ struct ieee80211_vht_operation {
1310#define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200 1386#define IEEE80211_VHT_CAP_RXSTBC_2 0x00000200
1311#define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300 1387#define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
1312#define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400 1388#define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
1389#define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
1313#define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800 1390#define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
1314#define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000 1391#define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
1315#define IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX 0x00006000 1392#define IEEE80211_VHT_CAP_BEAMFORMER_ANTENNAS_MAX 0x00006000
1316#define IEEE80211_VHT_CAP_SOUNDING_DIMENTION_MAX 0x00030000 1393#define IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_MAX 0x00030000
1317#define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000 1394#define IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE 0x00080000
1318#define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000 1395#define IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE 0x00100000
1319#define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000 1396#define IEEE80211_VHT_CAP_VHT_TXOP_PS 0x00200000
@@ -1594,6 +1671,7 @@ enum ieee80211_eid {
1594 1671
1595 WLAN_EID_HT_CAPABILITY = 45, 1672 WLAN_EID_HT_CAPABILITY = 45,
1596 WLAN_EID_HT_OPERATION = 61, 1673 WLAN_EID_HT_OPERATION = 61,
1674 WLAN_EID_SECONDARY_CHANNEL_OFFSET = 62,
1597 1675
1598 WLAN_EID_RSN = 48, 1676 WLAN_EID_RSN = 48,
1599 WLAN_EID_MMIE = 76, 1677 WLAN_EID_MMIE = 76,
@@ -1628,6 +1706,8 @@ enum ieee80211_eid {
1628 WLAN_EID_VHT_CAPABILITY = 191, 1706 WLAN_EID_VHT_CAPABILITY = 191,
1629 WLAN_EID_VHT_OPERATION = 192, 1707 WLAN_EID_VHT_OPERATION = 192,
1630 WLAN_EID_OPMODE_NOTIF = 199, 1708 WLAN_EID_OPMODE_NOTIF = 199,
1709 WLAN_EID_WIDE_BW_CHANNEL_SWITCH = 194,
1710 WLAN_EID_CHANNEL_SWITCH_WRAPPER = 196,
1631 1711
1632 /* 802.11ad */ 1712 /* 802.11ad */
1633 WLAN_EID_NON_TX_BSSID_CAP = 83, 1713 WLAN_EID_NON_TX_BSSID_CAP = 83,
@@ -1751,6 +1831,7 @@ enum ieee80211_key_len {
1751 1831
1752/* Public action codes */ 1832/* Public action codes */
1753enum ieee80211_pub_actioncode { 1833enum ieee80211_pub_actioncode {
1834 WLAN_PUB_ACTION_EXT_CHANSW_ANN = 4,
1754 WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14, 1835 WLAN_PUB_ACTION_TDLS_DISCOVER_RES = 14,
1755}; 1836};
1756 1837
@@ -1911,6 +1992,16 @@ enum ieee80211_timeout_interval_type {
1911 WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */, 1992 WLAN_TIMEOUT_ASSOC_COMEBACK = 3 /* 802.11w */,
1912}; 1993};
1913 1994
1995/**
1996 * struct ieee80211_timeout_interval_ie - Timeout Interval element
1997 * @type: type, see &enum ieee80211_timeout_interval_type
1998 * @value: timeout interval value
1999 */
2000struct ieee80211_timeout_interval_ie {
2001 u8 type;
2002 __le32 value;
2003} __packed;
2004
1914/* BACK action code */ 2005/* BACK action code */
1915enum ieee80211_back_actioncode { 2006enum ieee80211_back_actioncode {
1916 WLAN_ACTION_ADDBA_REQ = 0, 2007 WLAN_ACTION_ADDBA_REQ = 0,
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index 89b4614a4722..f563907ed776 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -33,7 +33,15 @@ static inline struct arphdr *arp_hdr(const struct sk_buff *skb)
33 33
34static inline int arp_hdr_len(struct net_device *dev) 34static inline int arp_hdr_len(struct net_device *dev)
35{ 35{
36 /* ARP header, plus 2 device addresses, plus 2 IP addresses. */ 36 switch (dev->type) {
37 return sizeof(struct arphdr) + (dev->addr_len + sizeof(u32)) * 2; 37#if IS_ENABLED(CONFIG_FIREWIRE_NET)
38 case ARPHRD_IEEE1394:
39 /* ARP header, device address and 2 IP addresses */
40 return sizeof(struct arphdr) + dev->addr_len + sizeof(u32) * 2;
41#endif
42 default:
43 /* ARP header, plus 2 device addresses, plus 2 IP addresses. */
44 return sizeof(struct arphdr) + (dev->addr_len + sizeof(u32)) * 2;
45 }
38} 46}
39#endif /* _LINUX_IF_ARP_H */ 47#endif /* _LINUX_IF_ARP_H */
diff --git a/include/linux/if_team.h b/include/linux/if_team.h
index cfd21e3d5506..4474557904f6 100644
--- a/include/linux/if_team.h
+++ b/include/linux/if_team.h
@@ -112,6 +112,10 @@ struct team_mode_ops {
112 void (*port_disabled)(struct team *team, struct team_port *port); 112 void (*port_disabled)(struct team *team, struct team_port *port);
113}; 113};
114 114
115extern int team_modeop_port_enter(struct team *team, struct team_port *port);
116extern void team_modeop_port_change_dev_addr(struct team *team,
117 struct team_port *port);
118
115enum team_option_type { 119enum team_option_type {
116 TEAM_OPTION_TYPE_U32, 120 TEAM_OPTION_TYPE_U32,
117 TEAM_OPTION_TYPE_STRING, 121 TEAM_OPTION_TYPE_STRING,
@@ -236,7 +240,26 @@ static inline struct team_port *team_get_port_by_index_rcu(struct team *team,
236 return NULL; 240 return NULL;
237} 241}
238 242
239extern int team_port_set_team_dev_addr(struct team_port *port); 243static inline struct team_port *
244team_get_first_port_txable_rcu(struct team *team, struct team_port *port)
245{
246 struct team_port *cur;
247
248 if (likely(team_port_txable(port)))
249 return port;
250 cur = port;
251 list_for_each_entry_continue_rcu(cur, &team->port_list, list)
252 if (team_port_txable(port))
253 return cur;
254 list_for_each_entry_rcu(cur, &team->port_list, list) {
255 if (cur == port)
256 break;
257 if (team_port_txable(port))
258 return cur;
259 }
260 return NULL;
261}
262
240extern int team_options_register(struct team *team, 263extern int team_options_register(struct team *team,
241 const struct team_option *option, 264 const struct team_option *option,
242 size_t option_count); 265 size_t option_count);
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 218a3b686d90..52bd03b38962 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -86,15 +86,15 @@ static inline int is_vlan_dev(struct net_device *dev)
86#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 86#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
87 87
88extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev, 88extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
89 u16 vlan_id); 89 __be16 vlan_proto, u16 vlan_id);
90extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); 90extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
91extern u16 vlan_dev_vlan_id(const struct net_device *dev); 91extern u16 vlan_dev_vlan_id(const struct net_device *dev);
92 92
93extern bool vlan_do_receive(struct sk_buff **skb); 93extern bool vlan_do_receive(struct sk_buff **skb);
94extern struct sk_buff *vlan_untag(struct sk_buff *skb); 94extern struct sk_buff *vlan_untag(struct sk_buff *skb);
95 95
96extern int vlan_vid_add(struct net_device *dev, unsigned short vid); 96extern int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid);
97extern void vlan_vid_del(struct net_device *dev, unsigned short vid); 97extern void vlan_vid_del(struct net_device *dev, __be16 proto, u16 vid);
98 98
99extern int vlan_vids_add_by_dev(struct net_device *dev, 99extern int vlan_vids_add_by_dev(struct net_device *dev,
100 const struct net_device *by_dev); 100 const struct net_device *by_dev);
@@ -104,7 +104,8 @@ extern void vlan_vids_del_by_dev(struct net_device *dev,
104extern bool vlan_uses_dev(const struct net_device *dev); 104extern bool vlan_uses_dev(const struct net_device *dev);
105#else 105#else
106static inline struct net_device * 106static inline struct net_device *
107__vlan_find_dev_deep(struct net_device *real_dev, u16 vlan_id) 107__vlan_find_dev_deep(struct net_device *real_dev,
108 __be16 vlan_proto, u16 vlan_id)
108{ 109{
109 return NULL; 110 return NULL;
110} 111}
@@ -131,12 +132,12 @@ static inline struct sk_buff *vlan_untag(struct sk_buff *skb)
131 return skb; 132 return skb;
132} 133}
133 134
134static inline int vlan_vid_add(struct net_device *dev, unsigned short vid) 135static inline int vlan_vid_add(struct net_device *dev, __be16 proto, u16 vid)
135{ 136{
136 return 0; 137 return 0;
137} 138}
138 139
139static inline void vlan_vid_del(struct net_device *dev, unsigned short vid) 140static inline void vlan_vid_del(struct net_device *dev, __be16 proto, u16 vid)
140{ 141{
141} 142}
142 143
@@ -157,9 +158,20 @@ static inline bool vlan_uses_dev(const struct net_device *dev)
157} 158}
158#endif 159#endif
159 160
161static inline bool vlan_hw_offload_capable(netdev_features_t features,
162 __be16 proto)
163{
164 if (proto == htons(ETH_P_8021Q) && features & NETIF_F_HW_VLAN_CTAG_TX)
165 return true;
166 if (proto == htons(ETH_P_8021AD) && features & NETIF_F_HW_VLAN_STAG_TX)
167 return true;
168 return false;
169}
170
160/** 171/**
161 * vlan_insert_tag - regular VLAN tag inserting 172 * vlan_insert_tag - regular VLAN tag inserting
162 * @skb: skbuff to tag 173 * @skb: skbuff to tag
174 * @vlan_proto: VLAN encapsulation protocol
163 * @vlan_tci: VLAN TCI to insert 175 * @vlan_tci: VLAN TCI to insert
164 * 176 *
165 * Inserts the VLAN tag into @skb as part of the payload 177 * Inserts the VLAN tag into @skb as part of the payload
@@ -170,7 +182,8 @@ static inline bool vlan_uses_dev(const struct net_device *dev)
170 * 182 *
171 * Does not change skb->protocol so this function can be used during receive. 183 * Does not change skb->protocol so this function can be used during receive.
172 */ 184 */
173static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci) 185static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb,
186 __be16 vlan_proto, u16 vlan_tci)
174{ 187{
175 struct vlan_ethhdr *veth; 188 struct vlan_ethhdr *veth;
176 189
@@ -185,7 +198,7 @@ static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci)
185 skb->mac_header -= VLAN_HLEN; 198 skb->mac_header -= VLAN_HLEN;
186 199
187 /* first, the ethernet type */ 200 /* first, the ethernet type */
188 veth->h_vlan_proto = htons(ETH_P_8021Q); 201 veth->h_vlan_proto = vlan_proto;
189 202
190 /* now, the TCI */ 203 /* now, the TCI */
191 veth->h_vlan_TCI = htons(vlan_tci); 204 veth->h_vlan_TCI = htons(vlan_tci);
@@ -204,24 +217,28 @@ static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci)
204 * Following the skb_unshare() example, in case of error, the calling function 217 * Following the skb_unshare() example, in case of error, the calling function
205 * doesn't have to worry about freeing the original skb. 218 * doesn't have to worry about freeing the original skb.
206 */ 219 */
207static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 220static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb,
221 __be16 vlan_proto, u16 vlan_tci)
208{ 222{
209 skb = vlan_insert_tag(skb, vlan_tci); 223 skb = vlan_insert_tag(skb, vlan_proto, vlan_tci);
210 if (skb) 224 if (skb)
211 skb->protocol = htons(ETH_P_8021Q); 225 skb->protocol = vlan_proto;
212 return skb; 226 return skb;
213} 227}
214 228
215/** 229/**
216 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting 230 * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
217 * @skb: skbuff to tag 231 * @skb: skbuff to tag
232 * @vlan_proto: VLAN encapsulation protocol
218 * @vlan_tci: VLAN TCI to insert 233 * @vlan_tci: VLAN TCI to insert
219 * 234 *
220 * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest 235 * Puts the VLAN TCI in @skb->vlan_tci and lets the device do the rest
221 */ 236 */
222static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, 237static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
238 __be16 vlan_proto,
223 u16 vlan_tci) 239 u16 vlan_tci)
224{ 240{
241 skb->vlan_proto = vlan_proto;
225 skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci; 242 skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci;
226 return skb; 243 return skb;
227} 244}
@@ -236,12 +253,13 @@ static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
236 * Assumes skb->dev is the target that will xmit this frame. 253 * Assumes skb->dev is the target that will xmit this frame.
237 * Returns a VLAN tagged skb. 254 * Returns a VLAN tagged skb.
238 */ 255 */
239static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 256static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb,
257 __be16 vlan_proto, u16 vlan_tci)
240{ 258{
241 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 259 if (vlan_hw_offload_capable(skb->dev->features, vlan_proto)) {
242 return __vlan_hwaccel_put_tag(skb, vlan_tci); 260 return __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
243 } else { 261 } else {
244 return __vlan_put_tag(skb, vlan_tci); 262 return __vlan_put_tag(skb, vlan_proto, vlan_tci);
245 } 263 }
246} 264}
247 265
@@ -256,9 +274,9 @@ static inline int __vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
256{ 274{
257 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; 275 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
258 276
259 if (veth->h_vlan_proto != htons(ETH_P_8021Q)) { 277 if (veth->h_vlan_proto != htons(ETH_P_8021Q) &&
278 veth->h_vlan_proto != htons(ETH_P_8021AD))
260 return -EINVAL; 279 return -EINVAL;
261 }
262 280
263 *vlan_tci = ntohs(veth->h_vlan_TCI); 281 *vlan_tci = ntohs(veth->h_vlan_TCI);
264 return 0; 282 return 0;
@@ -294,7 +312,7 @@ static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
294 */ 312 */
295static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci) 313static inline int vlan_get_tag(const struct sk_buff *skb, u16 *vlan_tci)
296{ 314{
297 if (skb->dev->features & NETIF_F_HW_VLAN_TX) { 315 if (skb->dev->features & NETIF_F_HW_VLAN_CTAG_TX) {
298 return __vlan_hwaccel_get_tag(skb, vlan_tci); 316 return __vlan_hwaccel_get_tag(skb, vlan_tci);
299 } else { 317 } else {
300 return __vlan_get_tag(skb, vlan_tci); 318 return __vlan_get_tag(skb, vlan_tci);
@@ -339,7 +357,7 @@ static inline void vlan_set_encap_proto(struct sk_buff *skb,
339 */ 357 */
340 358
341 proto = vhdr->h_vlan_encapsulated_proto; 359 proto = vhdr->h_vlan_encapsulated_proto;
342 if (ntohs(proto) >= 1536) { 360 if (ntohs(proto) >= ETH_P_802_3_MIN) {
343 skb->protocol = proto; 361 skb->protocol = proto;
344 return; 362 return;
345 } 363 }
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index e83512f63df5..bbca12804d12 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -330,6 +330,24 @@ static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec)
330 330
331extern ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs); 331extern ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs);
332 332
333/**
334 * ktime_to_timespec_cond - convert a ktime_t variable to timespec
335 * format only if the variable contains data
336 * @kt: the ktime_t variable to convert
337 * @ts: the timespec variable to store the result in
338 *
339 * Returns true if there was a successful conversion, false if kt was 0.
340 */
341static inline bool ktime_to_timespec_cond(const ktime_t kt, struct timespec *ts)
342{
343 if (kt.tv64) {
344 *ts = ktime_to_timespec(kt);
345 return true;
346 } else {
347 return false;
348 }
349}
350
333/* 351/*
334 * The resolution of the clocks. The resolution value is returned in 352 * The resolution of the clocks. The resolution value is returned in
335 * the clock_getres() system call to give application programmers an 353 * the clock_getres() system call to give application programmers an
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index 9dbb41a4e250..8752dbbc6135 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -19,6 +19,7 @@
19#define PHY_ID_KSZ9021 0x00221610 19#define PHY_ID_KSZ9021 0x00221610
20#define PHY_ID_KS8737 0x00221720 20#define PHY_ID_KS8737 0x00221720
21#define PHY_ID_KSZ8021 0x00221555 21#define PHY_ID_KSZ8021 0x00221555
22#define PHY_ID_KSZ8031 0x00221556
22#define PHY_ID_KSZ8041 0x00221510 23#define PHY_ID_KSZ8041 0x00221510
23#define PHY_ID_KSZ8051 0x00221550 24#define PHY_ID_KSZ8051 0x00221550
24/* same id: ks8001 Rev. A/B, and ks8721 Rev 3. */ 25/* same id: ks8001 Rev. A/B, and ks8721 Rev 3. */
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h
index 260695186256..adf6e0648f20 100644
--- a/include/linux/mlx4/cmd.h
+++ b/include/linux/mlx4/cmd.h
@@ -34,6 +34,7 @@
34#define MLX4_CMD_H 34#define MLX4_CMD_H
35 35
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/if_link.h>
37 38
38enum { 39enum {
39 /* initialization and general commands */ 40 /* initialization and general commands */
@@ -232,6 +233,11 @@ struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev);
232void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox); 233void mlx4_free_cmd_mailbox(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox);
233 234
234u32 mlx4_comm_get_version(void); 235u32 mlx4_comm_get_version(void);
236int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac);
237int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos);
238int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting);
239int mlx4_get_vf_config(struct mlx4_dev *dev, int port, int vf, struct ifla_vf_info *ivf);
240
235 241
236#define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8) 242#define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8)
237 243
diff --git a/include/linux/mlx4/cq.h b/include/linux/mlx4/cq.h
index 6f65b2c8bb89..98fa492cf406 100644
--- a/include/linux/mlx4/cq.h
+++ b/include/linux/mlx4/cq.h
@@ -64,6 +64,22 @@ struct mlx4_err_cqe {
64 u8 owner_sr_opcode; 64 u8 owner_sr_opcode;
65}; 65};
66 66
67struct mlx4_ts_cqe {
68 __be32 vlan_my_qpn;
69 __be32 immed_rss_invalid;
70 __be32 g_mlpath_rqpn;
71 __be32 timestamp_hi;
72 __be16 status;
73 u8 ipv6_ext_mask;
74 u8 badfcs_enc;
75 __be32 byte_cnt;
76 __be16 wqe_index;
77 __be16 checksum;
78 u8 reserved;
79 __be16 timestamp_lo;
80 u8 owner_sr_opcode;
81} __packed;
82
67enum { 83enum {
68 MLX4_CQE_VLAN_PRESENT_MASK = 1 << 29, 84 MLX4_CQE_VLAN_PRESENT_MASK = 1 << 29,
69 MLX4_CQE_QPN_MASK = 0xffffff, 85 MLX4_CQE_QPN_MASK = 0xffffff,
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 811f91cf5e8c..53acaf64189f 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -40,6 +40,8 @@
40 40
41#include <linux/atomic.h> 41#include <linux/atomic.h>
42 42
43#include <linux/clocksource.h>
44
43#define MAX_MSIX_P_PORT 17 45#define MAX_MSIX_P_PORT 17
44#define MAX_MSIX 64 46#define MAX_MSIX 64
45#define MSIX_LEGACY_SZ 4 47#define MSIX_LEGACY_SZ 4
@@ -140,6 +142,7 @@ enum {
140 MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41, 142 MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41,
141 MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42, 143 MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42,
142 MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48, 144 MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48,
145 MLX4_DEV_CAP_FLAG_SET_ETH_SCHED = 1LL << 53,
143 MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55, 146 MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55,
144 MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59, 147 MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV = 1LL << 59,
145 MLX4_DEV_CAP_FLAG_64B_EQE = 1LL << 61, 148 MLX4_DEV_CAP_FLAG_64B_EQE = 1LL << 61,
@@ -151,7 +154,10 @@ enum {
151 MLX4_DEV_CAP_FLAG2_RSS_TOP = 1LL << 1, 154 MLX4_DEV_CAP_FLAG2_RSS_TOP = 1LL << 1,
152 MLX4_DEV_CAP_FLAG2_RSS_XOR = 1LL << 2, 155 MLX4_DEV_CAP_FLAG2_RSS_XOR = 1LL << 2,
153 MLX4_DEV_CAP_FLAG2_FS_EN = 1LL << 3, 156 MLX4_DEV_CAP_FLAG2_FS_EN = 1LL << 3,
154 MLX4_DEV_CAP_FLAGS2_REASSIGN_MAC_EN = 1LL << 4 157 MLX4_DEV_CAP_FLAGS2_REASSIGN_MAC_EN = 1LL << 4,
158 MLX4_DEV_CAP_FLAG2_TS = 1LL << 5,
159 MLX4_DEV_CAP_FLAG2_VLAN_CONTROL = 1LL << 6,
160 MLX4_DEV_CAP_FLAG2_FSM = 1LL << 7
155}; 161};
156 162
157enum { 163enum {
@@ -443,6 +449,7 @@ struct mlx4_caps {
443 u8 eqe_factor; 449 u8 eqe_factor;
444 u32 userspace_caps; /* userspace must be aware of these */ 450 u32 userspace_caps; /* userspace must be aware of these */
445 u32 function_caps; /* VFs must be aware of these */ 451 u32 function_caps; /* VFs must be aware of these */
452 u16 hca_core_clock;
446}; 453};
447 454
448struct mlx4_buf_list { 455struct mlx4_buf_list {
@@ -837,7 +844,7 @@ void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres,
837 844
838int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, 845int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt,
839 struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq, 846 struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq,
840 unsigned vector, int collapsed); 847 unsigned vector, int collapsed, int timestamp_en);
841void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); 848void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq);
842 849
843int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, int *base); 850int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, int *base);
@@ -1028,4 +1035,6 @@ int set_and_calc_slave_port_state(struct mlx4_dev *dev, int slave, u8 port, int
1028void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid); 1035void mlx4_put_slave_node_guid(struct mlx4_dev *dev, int slave, __be64 guid);
1029__be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave); 1036__be64 mlx4_get_slave_node_guid(struct mlx4_dev *dev, int slave);
1030 1037
1038cycle_t mlx4_read_clock(struct mlx4_dev *dev);
1039
1031#endif /* MLX4_DEVICE_H */ 1040#endif /* MLX4_DEVICE_H */
diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h
index 49258e0ed1c6..141d395bbb5f 100644
--- a/include/linux/mv643xx_eth.h
+++ b/include/linux/mv643xx_eth.h
@@ -19,7 +19,6 @@
19 19
20struct mv643xx_eth_shared_platform_data { 20struct mv643xx_eth_shared_platform_data {
21 struct mbus_dram_target_info *dram; 21 struct mbus_dram_target_info *dram;
22 struct platform_device *shared_smi;
23 /* 22 /*
24 * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default 23 * Max packet size for Tx IP/Layer 4 checksum, when set to 0, default
25 * limit of 9KiB will be used. 24 * limit of 9KiB will be used.
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 3dd39340430e..cbaa027ef5a7 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -22,9 +22,12 @@ enum {
22 NETIF_F_IPV6_CSUM_BIT, /* Can checksum TCP/UDP over IPV6 */ 22 NETIF_F_IPV6_CSUM_BIT, /* Can checksum TCP/UDP over IPV6 */
23 NETIF_F_HIGHDMA_BIT, /* Can DMA to high memory. */ 23 NETIF_F_HIGHDMA_BIT, /* Can DMA to high memory. */
24 NETIF_F_FRAGLIST_BIT, /* Scatter/gather IO. */ 24 NETIF_F_FRAGLIST_BIT, /* Scatter/gather IO. */
25 NETIF_F_HW_VLAN_TX_BIT, /* Transmit VLAN hw acceleration */ 25 NETIF_F_HW_VLAN_CTAG_TX_BIT, /* Transmit VLAN CTAG HW acceleration */
26 NETIF_F_HW_VLAN_RX_BIT, /* Receive VLAN hw acceleration */ 26 NETIF_F_HW_VLAN_CTAG_RX_BIT, /* Receive VLAN CTAG HW acceleration */
27 NETIF_F_HW_VLAN_FILTER_BIT, /* Receive filtering on VLAN */ 27 NETIF_F_HW_VLAN_CTAG_FILTER_BIT,/* Receive filtering on VLAN CTAGs */
28 NETIF_F_HW_VLAN_STAG_TX_BIT, /* Transmit VLAN STAG HW acceleration */
29 NETIF_F_HW_VLAN_STAG_RX_BIT, /* Receive VLAN STAG HW acceleration */
30 NETIF_F_HW_VLAN_STAG_FILTER_BIT,/* Receive filtering on VLAN STAGs */
28 NETIF_F_VLAN_CHALLENGED_BIT, /* Device cannot handle VLAN packets */ 31 NETIF_F_VLAN_CHALLENGED_BIT, /* Device cannot handle VLAN packets */
29 NETIF_F_GSO_BIT, /* Enable software GSO. */ 32 NETIF_F_GSO_BIT, /* Enable software GSO. */
30 NETIF_F_LLTX_BIT, /* LockLess TX - deprecated. Please */ 33 NETIF_F_LLTX_BIT, /* LockLess TX - deprecated. Please */
@@ -42,9 +45,9 @@ enum {
42 NETIF_F_TSO6_BIT, /* ... TCPv6 segmentation */ 45 NETIF_F_TSO6_BIT, /* ... TCPv6 segmentation */
43 NETIF_F_FSO_BIT, /* ... FCoE segmentation */ 46 NETIF_F_FSO_BIT, /* ... FCoE segmentation */
44 NETIF_F_GSO_GRE_BIT, /* ... GRE with TSO */ 47 NETIF_F_GSO_GRE_BIT, /* ... GRE with TSO */
45 /**/NETIF_F_GSO_LAST, /* [can't be last bit, see GSO_MASK] */ 48 NETIF_F_GSO_UDP_TUNNEL_BIT, /* ... UDP TUNNEL with TSO */
46 NETIF_F_GSO_RESERVED2 /* ... free (fill GSO_MASK to 8 bits) */ 49 /**/NETIF_F_GSO_LAST = /* last bit, see GSO_MASK */
47 = NETIF_F_GSO_LAST, 50 NETIF_F_GSO_UDP_TUNNEL_BIT,
48 51
49 NETIF_F_FCOE_CRC_BIT, /* FCoE CRC32 */ 52 NETIF_F_FCOE_CRC_BIT, /* FCoE CRC32 */
50 NETIF_F_SCTP_CSUM_BIT, /* SCTP checksum offload */ 53 NETIF_F_SCTP_CSUM_BIT, /* SCTP checksum offload */
@@ -80,9 +83,12 @@ enum {
80#define NETIF_F_GSO_ROBUST __NETIF_F(GSO_ROBUST) 83#define NETIF_F_GSO_ROBUST __NETIF_F(GSO_ROBUST)
81#define NETIF_F_HIGHDMA __NETIF_F(HIGHDMA) 84#define NETIF_F_HIGHDMA __NETIF_F(HIGHDMA)
82#define NETIF_F_HW_CSUM __NETIF_F(HW_CSUM) 85#define NETIF_F_HW_CSUM __NETIF_F(HW_CSUM)
83#define NETIF_F_HW_VLAN_FILTER __NETIF_F(HW_VLAN_FILTER) 86#define NETIF_F_HW_VLAN_CTAG_FILTER __NETIF_F(HW_VLAN_CTAG_FILTER)
84#define NETIF_F_HW_VLAN_RX __NETIF_F(HW_VLAN_RX) 87#define NETIF_F_HW_VLAN_CTAG_RX __NETIF_F(HW_VLAN_CTAG_RX)
85#define NETIF_F_HW_VLAN_TX __NETIF_F(HW_VLAN_TX) 88#define NETIF_F_HW_VLAN_CTAG_TX __NETIF_F(HW_VLAN_CTAG_TX)
89#define NETIF_F_HW_VLAN_STAG_FILTER __NETIF_F(HW_VLAN_STAG_FILTER)
90#define NETIF_F_HW_VLAN_STAG_RX __NETIF_F(HW_VLAN_STAG_RX)
91#define NETIF_F_HW_VLAN_STAG_TX __NETIF_F(HW_VLAN_STAG_TX)
86#define NETIF_F_IP_CSUM __NETIF_F(IP_CSUM) 92#define NETIF_F_IP_CSUM __NETIF_F(IP_CSUM)
87#define NETIF_F_IPV6_CSUM __NETIF_F(IPV6_CSUM) 93#define NETIF_F_IPV6_CSUM __NETIF_F(IPV6_CSUM)
88#define NETIF_F_LLTX __NETIF_F(LLTX) 94#define NETIF_F_LLTX __NETIF_F(LLTX)
@@ -102,7 +108,8 @@ enum {
102#define NETIF_F_VLAN_CHALLENGED __NETIF_F(VLAN_CHALLENGED) 108#define NETIF_F_VLAN_CHALLENGED __NETIF_F(VLAN_CHALLENGED)
103#define NETIF_F_RXFCS __NETIF_F(RXFCS) 109#define NETIF_F_RXFCS __NETIF_F(RXFCS)
104#define NETIF_F_RXALL __NETIF_F(RXALL) 110#define NETIF_F_RXALL __NETIF_F(RXALL)
105#define NETIF_F_GRE_GSO __NETIF_F(GSO_GRE) 111#define NETIF_F_GSO_GRE __NETIF_F(GSO_GRE)
112#define NETIF_F_GSO_UDP_TUNNEL __NETIF_F(GSO_UDP_TUNNEL)
106 113
107/* Features valid for ethtool to change */ 114/* Features valid for ethtool to change */
108/* = all defined minus driver/device-class-related */ 115/* = all defined minus driver/device-class-related */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6151e903eef0..f8898a435dc5 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -144,8 +144,6 @@ static inline bool dev_xmit_complete(int rc)
144# else 144# else
145# define LL_MAX_HEADER 96 145# define LL_MAX_HEADER 96
146# endif 146# endif
147#elif IS_ENABLED(CONFIG_TR)
148# define LL_MAX_HEADER 48
149#else 147#else
150# define LL_MAX_HEADER 32 148# define LL_MAX_HEADER 32
151#endif 149#endif
@@ -211,6 +209,7 @@ struct netdev_hw_addr {
211#define NETDEV_HW_ADDR_T_UNICAST 4 209#define NETDEV_HW_ADDR_T_UNICAST 4
212#define NETDEV_HW_ADDR_T_MULTICAST 5 210#define NETDEV_HW_ADDR_T_MULTICAST 5
213 bool global_use; 211 bool global_use;
212 int sync_cnt;
214 int refcount; 213 int refcount;
215 int synced; 214 int synced;
216 struct rcu_head rcu_head; 215 struct rcu_head rcu_head;
@@ -785,13 +784,13 @@ struct netdev_fcoe_hbainfo {
785 * 3. Update dev->stats asynchronously and atomically, and define 784 * 3. Update dev->stats asynchronously and atomically, and define
786 * neither operation. 785 * neither operation.
787 * 786 *
788 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid); 787 * int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16t vid);
789 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) 788 * If device support VLAN filtering this function is called when a
790 * this function is called when a VLAN id is registered. 789 * VLAN id is registered.
791 * 790 *
792 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); 791 * int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
793 * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) 792 * If device support VLAN filtering this function is called when a
794 * this function is called when a VLAN id is unregistered. 793 * VLAN id is unregistered.
795 * 794 *
796 * void (*ndo_poll_controller)(struct net_device *dev); 795 * void (*ndo_poll_controller)(struct net_device *dev);
797 * 796 *
@@ -935,9 +934,9 @@ struct net_device_ops {
935 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); 934 struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
936 935
937 int (*ndo_vlan_rx_add_vid)(struct net_device *dev, 936 int (*ndo_vlan_rx_add_vid)(struct net_device *dev,
938 unsigned short vid); 937 __be16 proto, u16 vid);
939 int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, 938 int (*ndo_vlan_rx_kill_vid)(struct net_device *dev,
940 unsigned short vid); 939 __be16 proto, u16 vid);
941#ifdef CONFIG_NET_POLL_CONTROLLER 940#ifdef CONFIG_NET_POLL_CONTROLLER
942 void (*ndo_poll_controller)(struct net_device *dev); 941 void (*ndo_poll_controller)(struct net_device *dev);
943 int (*ndo_netpoll_setup)(struct net_device *dev, 942 int (*ndo_netpoll_setup)(struct net_device *dev,
@@ -1073,6 +1072,8 @@ struct net_device {
1073 struct list_head dev_list; 1072 struct list_head dev_list;
1074 struct list_head napi_list; 1073 struct list_head napi_list;
1075 struct list_head unreg_list; 1074 struct list_head unreg_list;
1075 struct list_head upper_dev_list; /* List of upper devices */
1076
1076 1077
1077 /* currently active device features */ 1078 /* currently active device features */
1078 netdev_features_t features; 1079 netdev_features_t features;
@@ -1145,6 +1146,13 @@ struct net_device {
1145 spinlock_t addr_list_lock; 1146 spinlock_t addr_list_lock;
1146 struct netdev_hw_addr_list uc; /* Unicast mac addresses */ 1147 struct netdev_hw_addr_list uc; /* Unicast mac addresses */
1147 struct netdev_hw_addr_list mc; /* Multicast mac addresses */ 1148 struct netdev_hw_addr_list mc; /* Multicast mac addresses */
1149 struct netdev_hw_addr_list dev_addrs; /* list of device
1150 * hw addresses
1151 */
1152#ifdef CONFIG_SYSFS
1153 struct kset *queues_kset;
1154#endif
1155
1148 bool uc_promisc; 1156 bool uc_promisc;
1149 unsigned int promiscuity; 1157 unsigned int promiscuity;
1150 unsigned int allmulti; 1158 unsigned int allmulti;
@@ -1177,21 +1185,11 @@ struct net_device {
1177 * avoid dirtying this cache line. 1185 * avoid dirtying this cache line.
1178 */ 1186 */
1179 1187
1180 struct list_head upper_dev_list; /* List of upper devices */
1181
1182 /* Interface address info used in eth_type_trans() */ 1188 /* Interface address info used in eth_type_trans() */
1183 unsigned char *dev_addr; /* hw address, (before bcast 1189 unsigned char *dev_addr; /* hw address, (before bcast
1184 because most packets are 1190 because most packets are
1185 unicast) */ 1191 unicast) */
1186 1192
1187 struct netdev_hw_addr_list dev_addrs; /* list of device
1188 hw addresses */
1189
1190 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
1191
1192#ifdef CONFIG_SYSFS
1193 struct kset *queues_kset;
1194#endif
1195 1193
1196#ifdef CONFIG_RPS 1194#ifdef CONFIG_RPS
1197 struct netdev_rx_queue *_rx; 1195 struct netdev_rx_queue *_rx;
@@ -1202,18 +1200,14 @@ struct net_device {
1202 /* Number of RX queues currently active in device */ 1200 /* Number of RX queues currently active in device */
1203 unsigned int real_num_rx_queues; 1201 unsigned int real_num_rx_queues;
1204 1202
1205#ifdef CONFIG_RFS_ACCEL
1206 /* CPU reverse-mapping for RX completion interrupts, indexed
1207 * by RX queue number. Assigned by driver. This must only be
1208 * set if the ndo_rx_flow_steer operation is defined. */
1209 struct cpu_rmap *rx_cpu_rmap;
1210#endif
1211#endif 1203#endif
1212 1204
1213 rx_handler_func_t __rcu *rx_handler; 1205 rx_handler_func_t __rcu *rx_handler;
1214 void __rcu *rx_handler_data; 1206 void __rcu *rx_handler_data;
1215 1207
1216 struct netdev_queue __rcu *ingress_queue; 1208 struct netdev_queue __rcu *ingress_queue;
1209 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
1210
1217 1211
1218/* 1212/*
1219 * Cache lines mostly used on transmit path 1213 * Cache lines mostly used on transmit path
@@ -1235,6 +1229,12 @@ struct net_device {
1235#ifdef CONFIG_XPS 1229#ifdef CONFIG_XPS
1236 struct xps_dev_maps __rcu *xps_maps; 1230 struct xps_dev_maps __rcu *xps_maps;
1237#endif 1231#endif
1232#ifdef CONFIG_RFS_ACCEL
1233 /* CPU reverse-mapping for RX completion interrupts, indexed
1234 * by RX queue number. Assigned by driver. This must only be
1235 * set if the ndo_rx_flow_steer operation is defined. */
1236 struct cpu_rmap *rx_cpu_rmap;
1237#endif
1238 1238
1239 /* These may be needed for future network-power-down code. */ 1239 /* These may be needed for future network-power-down code. */
1240 1240
@@ -1475,6 +1475,11 @@ static inline void *netdev_priv(const struct net_device *dev)
1475 */ 1475 */
1476#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype)) 1476#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype))
1477 1477
1478/* Default NAPI poll() weight
1479 * Device drivers are strongly advised to not use bigger value
1480 */
1481#define NAPI_POLL_WEIGHT 64
1482
1478/** 1483/**
1479 * netif_napi_add - initialize a napi context 1484 * netif_napi_add - initialize a napi context
1480 * @dev: network device 1485 * @dev: network device
@@ -1612,6 +1617,9 @@ extern seqcount_t devnet_rename_seq; /* Device rename seq */
1612 list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list) 1617 list_for_each_entry_continue(d, &(net)->dev_base_head, dev_list)
1613#define for_each_netdev_continue_rcu(net, d) \ 1618#define for_each_netdev_continue_rcu(net, d) \
1614 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list) 1619 list_for_each_entry_continue_rcu(d, &(net)->dev_base_head, dev_list)
1620#define for_each_netdev_in_bond_rcu(bond, slave) \
1621 for_each_netdev_rcu(&init_net, slave) \
1622 if (netdev_master_upper_dev_get_rcu(slave) == bond)
1615#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) 1623#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
1616 1624
1617static inline struct net_device *next_net_device(struct net_device *dev) 1625static inline struct net_device *next_net_device(struct net_device *dev)
@@ -1684,7 +1692,6 @@ extern int netdev_refcnt_read(const struct net_device *dev);
1684extern void free_netdev(struct net_device *dev); 1692extern void free_netdev(struct net_device *dev);
1685extern void synchronize_net(void); 1693extern void synchronize_net(void);
1686extern int init_dummy_netdev(struct net_device *dev); 1694extern int init_dummy_netdev(struct net_device *dev);
1687extern void netdev_resync_ops(struct net_device *dev);
1688 1695
1689extern struct net_device *dev_get_by_index(struct net *net, int ifindex); 1696extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
1690extern struct net_device *__dev_get_by_index(struct net *net, int ifindex); 1697extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
@@ -2621,6 +2628,7 @@ extern int dev_uc_add(struct net_device *dev, const unsigned char *addr);
2621extern int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr); 2628extern int dev_uc_add_excl(struct net_device *dev, const unsigned char *addr);
2622extern int dev_uc_del(struct net_device *dev, const unsigned char *addr); 2629extern int dev_uc_del(struct net_device *dev, const unsigned char *addr);
2623extern int dev_uc_sync(struct net_device *to, struct net_device *from); 2630extern int dev_uc_sync(struct net_device *to, struct net_device *from);
2631extern int dev_uc_sync_multiple(struct net_device *to, struct net_device *from);
2624extern void dev_uc_unsync(struct net_device *to, struct net_device *from); 2632extern void dev_uc_unsync(struct net_device *to, struct net_device *from);
2625extern void dev_uc_flush(struct net_device *dev); 2633extern void dev_uc_flush(struct net_device *dev);
2626extern void dev_uc_init(struct net_device *dev); 2634extern void dev_uc_init(struct net_device *dev);
@@ -2632,6 +2640,7 @@ extern int dev_mc_add_excl(struct net_device *dev, const unsigned char *addr);
2632extern int dev_mc_del(struct net_device *dev, const unsigned char *addr); 2640extern int dev_mc_del(struct net_device *dev, const unsigned char *addr);
2633extern int dev_mc_del_global(struct net_device *dev, const unsigned char *addr); 2641extern int dev_mc_del_global(struct net_device *dev, const unsigned char *addr);
2634extern int dev_mc_sync(struct net_device *to, struct net_device *from); 2642extern int dev_mc_sync(struct net_device *to, struct net_device *from);
2643extern int dev_mc_sync_multiple(struct net_device *to, struct net_device *from);
2635extern void dev_mc_unsync(struct net_device *to, struct net_device *from); 2644extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
2636extern void dev_mc_flush(struct net_device *dev); 2645extern void dev_mc_flush(struct net_device *dev);
2637extern void dev_mc_init(struct net_device *dev); 2646extern void dev_mc_init(struct net_device *dev);
@@ -2678,6 +2687,19 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, netdev_features_t features)
2678{ 2687{
2679 return __skb_gso_segment(skb, features, true); 2688 return __skb_gso_segment(skb, features, true);
2680} 2689}
2690__be16 skb_network_protocol(struct sk_buff *skb);
2691
2692static inline bool can_checksum_protocol(netdev_features_t features,
2693 __be16 protocol)
2694{
2695 return ((features & NETIF_F_GEN_CSUM) ||
2696 ((features & NETIF_F_V4_CSUM) &&
2697 protocol == htons(ETH_P_IP)) ||
2698 ((features & NETIF_F_V6_CSUM) &&
2699 protocol == htons(ETH_P_IPV6)) ||
2700 ((features & NETIF_F_FCOE_CRC) &&
2701 protocol == htons(ETH_P_FCOE)));
2702}
2681 2703
2682#ifdef CONFIG_BUG 2704#ifdef CONFIG_BUG
2683extern void netdev_rx_csum_fault(struct net_device *dev); 2705extern void netdev_rx_csum_fault(struct net_device *dev);
@@ -2756,6 +2778,11 @@ static inline void netif_set_gso_max_size(struct net_device *dev,
2756 dev->gso_max_size = size; 2778 dev->gso_max_size = size;
2757} 2779}
2758 2780
2781static inline bool netif_is_bond_master(struct net_device *dev)
2782{
2783 return dev->flags & IFF_MASTER && dev->priv_flags & IFF_BONDING;
2784}
2785
2759static inline bool netif_is_bond_slave(struct net_device *dev) 2786static inline bool netif_is_bond_slave(struct net_device *dev)
2760{ 2787{
2761 return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING; 2788 return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index ee142846f56a..0060fde3160e 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -289,11 +289,6 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
289#endif 289#endif
290} 290}
291 291
292#ifdef CONFIG_PROC_FS
293#include <linux/proc_fs.h>
294extern struct proc_dir_entry *proc_net_netfilter;
295#endif
296
297#else /* !CONFIG_NETFILTER */ 292#else /* !CONFIG_NETFILTER */
298#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb) 293#define NF_HOOK(pf, hook, skb, indev, outdev, okfn) (okfn)(skb)
299#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb) 294#define NF_HOOK_COND(pf, hook, skb, indev, outdev, okfn, cond) (okfn)(skb)
diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
index 7958e84a65af..d80e2753847c 100644
--- a/include/linux/netfilter/ipset/ip_set.h
+++ b/include/linux/netfilter/ipset/ip_set.h
@@ -1,7 +1,7 @@
1/* Copyright (C) 2000-2002 Joakim Axelsson <gozem@linux.nu> 1/* Copyright (C) 2000-2002 Joakim Axelsson <gozem@linux.nu>
2 * Patrick Schaaf <bof@bof.de> 2 * Patrick Schaaf <bof@bof.de>
3 * Martin Josefsson <gandalf@wlug.westbo.se> 3 * Martin Josefsson <gandalf@wlug.westbo.se>
4 * Copyright (C) 2003-2011 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> 4 * Copyright (C) 2003-2013 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -47,10 +47,36 @@ enum ip_set_feature {
47 IPSET_DUMP_LAST = (1 << IPSET_DUMP_LAST_FLAG), 47 IPSET_DUMP_LAST = (1 << IPSET_DUMP_LAST_FLAG),
48}; 48};
49 49
50/* Set extensions */
51enum ip_set_extension {
52 IPSET_EXT_NONE = 0,
53 IPSET_EXT_BIT_TIMEOUT = 1,
54 IPSET_EXT_TIMEOUT = (1 << IPSET_EXT_BIT_TIMEOUT),
55 IPSET_EXT_BIT_COUNTER = 2,
56 IPSET_EXT_COUNTER = (1 << IPSET_EXT_BIT_COUNTER),
57};
58
59/* Extension offsets */
60enum ip_set_offset {
61 IPSET_OFFSET_TIMEOUT = 0,
62 IPSET_OFFSET_COUNTER,
63 IPSET_OFFSET_MAX,
64};
65
66#define SET_WITH_TIMEOUT(s) ((s)->extensions & IPSET_EXT_TIMEOUT)
67#define SET_WITH_COUNTER(s) ((s)->extensions & IPSET_EXT_COUNTER)
68
69struct ip_set_ext {
70 unsigned long timeout;
71 u64 packets;
72 u64 bytes;
73};
74
50struct ip_set; 75struct ip_set;
51 76
52typedef int (*ipset_adtfn)(struct ip_set *set, void *value, 77typedef int (*ipset_adtfn)(struct ip_set *set, void *value,
53 u32 timeout, u32 flags); 78 const struct ip_set_ext *ext,
79 struct ip_set_ext *mext, u32 cmdflags);
54 80
55/* Kernel API function options */ 81/* Kernel API function options */
56struct ip_set_adt_opt { 82struct ip_set_adt_opt {
@@ -58,7 +84,7 @@ struct ip_set_adt_opt {
58 u8 dim; /* Dimension of match/target */ 84 u8 dim; /* Dimension of match/target */
59 u8 flags; /* Direction and negation flags */ 85 u8 flags; /* Direction and negation flags */
60 u32 cmdflags; /* Command-like flags */ 86 u32 cmdflags; /* Command-like flags */
61 u32 timeout; /* Timeout value */ 87 struct ip_set_ext ext; /* Extensions */
62}; 88};
63 89
64/* Set type, variant-specific part */ 90/* Set type, variant-specific part */
@@ -69,7 +95,7 @@ struct ip_set_type_variant {
69 * positive for matching element */ 95 * positive for matching element */
70 int (*kadt)(struct ip_set *set, const struct sk_buff *skb, 96 int (*kadt)(struct ip_set *set, const struct sk_buff *skb,
71 const struct xt_action_param *par, 97 const struct xt_action_param *par,
72 enum ipset_adt adt, const struct ip_set_adt_opt *opt); 98 enum ipset_adt adt, struct ip_set_adt_opt *opt);
73 99
74 /* Userspace: test/add/del entries 100 /* Userspace: test/add/del entries
75 * returns negative error code, 101 * returns negative error code,
@@ -151,10 +177,76 @@ struct ip_set {
151 u8 family; 177 u8 family;
152 /* The type revision */ 178 /* The type revision */
153 u8 revision; 179 u8 revision;
180 /* Extensions */
181 u8 extensions;
154 /* The type specific data */ 182 /* The type specific data */
155 void *data; 183 void *data;
156}; 184};
157 185
186struct ip_set_counter {
187 atomic64_t bytes;
188 atomic64_t packets;
189};
190
191static inline void
192ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
193{
194 atomic64_add((long long)bytes, &(counter)->bytes);
195}
196
197static inline void
198ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
199{
200 atomic64_add((long long)packets, &(counter)->packets);
201}
202
203static inline u64
204ip_set_get_bytes(const struct ip_set_counter *counter)
205{
206 return (u64)atomic64_read(&(counter)->bytes);
207}
208
209static inline u64
210ip_set_get_packets(const struct ip_set_counter *counter)
211{
212 return (u64)atomic64_read(&(counter)->packets);
213}
214
215static inline void
216ip_set_update_counter(struct ip_set_counter *counter,
217 const struct ip_set_ext *ext,
218 struct ip_set_ext *mext, u32 flags)
219{
220 if (ext->packets != ULLONG_MAX &&
221 !(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) {
222 ip_set_add_bytes(ext->bytes, counter);
223 ip_set_add_packets(ext->packets, counter);
224 }
225 if (flags & IPSET_FLAG_MATCH_COUNTERS) {
226 mext->packets = ip_set_get_packets(counter);
227 mext->bytes = ip_set_get_bytes(counter);
228 }
229}
230
231static inline bool
232ip_set_put_counter(struct sk_buff *skb, struct ip_set_counter *counter)
233{
234 return nla_put_net64(skb, IPSET_ATTR_BYTES,
235 cpu_to_be64(ip_set_get_bytes(counter))) ||
236 nla_put_net64(skb, IPSET_ATTR_PACKETS,
237 cpu_to_be64(ip_set_get_packets(counter)));
238}
239
240static inline void
241ip_set_init_counter(struct ip_set_counter *counter,
242 const struct ip_set_ext *ext)
243{
244 if (ext->bytes != ULLONG_MAX)
245 atomic64_set(&(counter)->bytes, (long long)(ext->bytes));
246 if (ext->packets != ULLONG_MAX)
247 atomic64_set(&(counter)->packets, (long long)(ext->packets));
248}
249
158/* register and unregister set references */ 250/* register and unregister set references */
159extern ip_set_id_t ip_set_get_byname(const char *name, struct ip_set **set); 251extern ip_set_id_t ip_set_get_byname(const char *name, struct ip_set **set);
160extern void ip_set_put_byindex(ip_set_id_t index); 252extern void ip_set_put_byindex(ip_set_id_t index);
@@ -167,19 +259,21 @@ extern void ip_set_nfnl_put(ip_set_id_t index);
167 259
168extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb, 260extern int ip_set_add(ip_set_id_t id, const struct sk_buff *skb,
169 const struct xt_action_param *par, 261 const struct xt_action_param *par,
170 const struct ip_set_adt_opt *opt); 262 struct ip_set_adt_opt *opt);
171extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb, 263extern int ip_set_del(ip_set_id_t id, const struct sk_buff *skb,
172 const struct xt_action_param *par, 264 const struct xt_action_param *par,
173 const struct ip_set_adt_opt *opt); 265 struct ip_set_adt_opt *opt);
174extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb, 266extern int ip_set_test(ip_set_id_t id, const struct sk_buff *skb,
175 const struct xt_action_param *par, 267 const struct xt_action_param *par,
176 const struct ip_set_adt_opt *opt); 268 struct ip_set_adt_opt *opt);
177 269
178/* Utility functions */ 270/* Utility functions */
179extern void *ip_set_alloc(size_t size); 271extern void *ip_set_alloc(size_t size);
180extern void ip_set_free(void *members); 272extern void ip_set_free(void *members);
181extern int ip_set_get_ipaddr4(struct nlattr *nla, __be32 *ipaddr); 273extern int ip_set_get_ipaddr4(struct nlattr *nla, __be32 *ipaddr);
182extern int ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr); 274extern int ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr);
275extern int ip_set_get_extensions(struct ip_set *set, struct nlattr *tb[],
276 struct ip_set_ext *ext);
183 277
184static inline int 278static inline int
185ip_set_get_hostipaddr4(struct nlattr *nla, u32 *ipaddr) 279ip_set_get_hostipaddr4(struct nlattr *nla, u32 *ipaddr)
@@ -200,6 +294,14 @@ ip_set_eexist(int ret, u32 flags)
200 return ret == -IPSET_ERR_EXIST && (flags & IPSET_FLAG_EXIST); 294 return ret == -IPSET_ERR_EXIST && (flags & IPSET_FLAG_EXIST);
201} 295}
202 296
297/* Match elements marked with nomatch */
298static inline bool
299ip_set_enomatch(int ret, u32 flags, enum ipset_adt adt)
300{
301 return adt == IPSET_TEST &&
302 ret == -ENOTEMPTY && ((flags >> 16) & IPSET_FLAG_NOMATCH);
303}
304
203/* Check the NLA_F_NET_BYTEORDER flag */ 305/* Check the NLA_F_NET_BYTEORDER flag */
204static inline bool 306static inline bool
205ip_set_attr_netorder(struct nlattr *tb[], int type) 307ip_set_attr_netorder(struct nlattr *tb[], int type)
@@ -284,4 +386,14 @@ bitmap_bytes(u32 a, u32 b)
284 return 4 * ((((b - a + 8) / 8) + 3) / 4); 386 return 4 * ((((b - a + 8) / 8) + 3) / 4);
285} 387}
286 388
389#include <linux/netfilter/ipset/ip_set_timeout.h>
390
391#define IP_SET_INIT_KEXT(skb, opt, map) \
392 { .bytes = (skb)->len, .packets = 1, \
393 .timeout = ip_set_adt_opt_timeout(opt, map) }
394
395#define IP_SET_INIT_UEXT(map) \
396 { .bytes = ULLONG_MAX, .packets = ULLONG_MAX, \
397 .timeout = (map)->timeout }
398
287#endif /*_IP_SET_H */ 399#endif /*_IP_SET_H */
diff --git a/include/linux/netfilter/ipset/ip_set_ahash.h b/include/linux/netfilter/ipset/ip_set_ahash.h
deleted file mode 100644
index 0214c4c146fa..000000000000
--- a/include/linux/netfilter/ipset/ip_set_ahash.h
+++ /dev/null
@@ -1,1241 +0,0 @@
1#ifndef _IP_SET_AHASH_H
2#define _IP_SET_AHASH_H
3
4#include <linux/rcupdate.h>
5#include <linux/jhash.h>
6#include <linux/netfilter/ipset/ip_set_timeout.h>
7
8#define CONCAT(a, b, c) a##b##c
9#define TOKEN(a, b, c) CONCAT(a, b, c)
10
11#define type_pf_next TOKEN(TYPE, PF, _elem)
12
13/* Hashing which uses arrays to resolve clashing. The hash table is resized
14 * (doubled) when searching becomes too long.
15 * Internally jhash is used with the assumption that the size of the
16 * stored data is a multiple of sizeof(u32). If storage supports timeout,
17 * the timeout field must be the last one in the data structure - that field
18 * is ignored when computing the hash key.
19 *
20 * Readers and resizing
21 *
22 * Resizing can be triggered by userspace command only, and those
23 * are serialized by the nfnl mutex. During resizing the set is
24 * read-locked, so the only possible concurrent operations are
25 * the kernel side readers. Those must be protected by proper RCU locking.
26 */
27
28/* Number of elements to store in an initial array block */
29#define AHASH_INIT_SIZE 4
30/* Max number of elements to store in an array block */
31#define AHASH_MAX_SIZE (3*AHASH_INIT_SIZE)
32
33/* Max number of elements can be tuned */
34#ifdef IP_SET_HASH_WITH_MULTI
35#define AHASH_MAX(h) ((h)->ahash_max)
36
37static inline u8
38tune_ahash_max(u8 curr, u32 multi)
39{
40 u32 n;
41
42 if (multi < curr)
43 return curr;
44
45 n = curr + AHASH_INIT_SIZE;
46 /* Currently, at listing one hash bucket must fit into a message.
47 * Therefore we have a hard limit here.
48 */
49 return n > curr && n <= 64 ? n : curr;
50}
51#define TUNE_AHASH_MAX(h, multi) \
52 ((h)->ahash_max = tune_ahash_max((h)->ahash_max, multi))
53#else
54#define AHASH_MAX(h) AHASH_MAX_SIZE
55#define TUNE_AHASH_MAX(h, multi)
56#endif
57
58/* A hash bucket */
59struct hbucket {
60 void *value; /* the array of the values */
61 u8 size; /* size of the array */
62 u8 pos; /* position of the first free entry */
63};
64
65/* The hash table: the table size stored here in order to make resizing easy */
66struct htable {
67 u8 htable_bits; /* size of hash table == 2^htable_bits */
68 struct hbucket bucket[0]; /* hashtable buckets */
69};
70
71#define hbucket(h, i) (&((h)->bucket[i]))
72
73/* Book-keeping of the prefixes added to the set */
74struct ip_set_hash_nets {
75 u8 cidr; /* the different cidr values in the set */
76 u32 nets; /* number of elements per cidr */
77};
78
79/* The generic ip_set hash structure */
80struct ip_set_hash {
81 struct htable *table; /* the hash table */
82 u32 maxelem; /* max elements in the hash */
83 u32 elements; /* current element (vs timeout) */
84 u32 initval; /* random jhash init value */
85 u32 timeout; /* timeout value, if enabled */
86 struct timer_list gc; /* garbage collection when timeout enabled */
87 struct type_pf_next next; /* temporary storage for uadd */
88#ifdef IP_SET_HASH_WITH_MULTI
89 u8 ahash_max; /* max elements in an array block */
90#endif
91#ifdef IP_SET_HASH_WITH_NETMASK
92 u8 netmask; /* netmask value for subnets to store */
93#endif
94#ifdef IP_SET_HASH_WITH_RBTREE
95 struct rb_root rbtree;
96#endif
97#ifdef IP_SET_HASH_WITH_NETS
98 struct ip_set_hash_nets nets[0]; /* book-keeping of prefixes */
99#endif
100};
101
102static size_t
103htable_size(u8 hbits)
104{
105 size_t hsize;
106
107 /* We must fit both into u32 in jhash and size_t */
108 if (hbits > 31)
109 return 0;
110 hsize = jhash_size(hbits);
111 if ((((size_t)-1) - sizeof(struct htable))/sizeof(struct hbucket)
112 < hsize)
113 return 0;
114
115 return hsize * sizeof(struct hbucket) + sizeof(struct htable);
116}
117
118/* Compute htable_bits from the user input parameter hashsize */
119static u8
120htable_bits(u32 hashsize)
121{
122 /* Assume that hashsize == 2^htable_bits */
123 u8 bits = fls(hashsize - 1);
124 if (jhash_size(bits) != hashsize)
125 /* Round up to the first 2^n value */
126 bits = fls(hashsize);
127
128 return bits;
129}
130
131#ifdef IP_SET_HASH_WITH_NETS
132#ifdef IP_SET_HASH_WITH_NETS_PACKED
133/* When cidr is packed with nomatch, cidr - 1 is stored in the entry */
134#define CIDR(cidr) (cidr + 1)
135#else
136#define CIDR(cidr) (cidr)
137#endif
138
139#define SET_HOST_MASK(family) (family == AF_INET ? 32 : 128)
140#ifdef IP_SET_HASH_WITH_MULTI
141#define NETS_LENGTH(family) (SET_HOST_MASK(family) + 1)
142#else
143#define NETS_LENGTH(family) SET_HOST_MASK(family)
144#endif
145
146/* Network cidr size book keeping when the hash stores different
147 * sized networks */
148static void
149add_cidr(struct ip_set_hash *h, u8 cidr, u8 nets_length)
150{
151 int i, j;
152
153 /* Add in increasing prefix order, so larger cidr first */
154 for (i = 0, j = -1; i < nets_length && h->nets[i].nets; i++) {
155 if (j != -1)
156 continue;
157 else if (h->nets[i].cidr < cidr)
158 j = i;
159 else if (h->nets[i].cidr == cidr) {
160 h->nets[i].nets++;
161 return;
162 }
163 }
164 if (j != -1) {
165 for (; i > j; i--) {
166 h->nets[i].cidr = h->nets[i - 1].cidr;
167 h->nets[i].nets = h->nets[i - 1].nets;
168 }
169 }
170 h->nets[i].cidr = cidr;
171 h->nets[i].nets = 1;
172}
173
174static void
175del_cidr(struct ip_set_hash *h, u8 cidr, u8 nets_length)
176{
177 u8 i, j;
178
179 for (i = 0; i < nets_length - 1 && h->nets[i].cidr != cidr; i++)
180 ;
181 h->nets[i].nets--;
182
183 if (h->nets[i].nets != 0)
184 return;
185
186 for (j = i; j < nets_length - 1 && h->nets[j].nets; j++) {
187 h->nets[j].cidr = h->nets[j + 1].cidr;
188 h->nets[j].nets = h->nets[j + 1].nets;
189 }
190}
191#else
192#define NETS_LENGTH(family) 0
193#endif
194
195/* Destroy the hashtable part of the set */
196static void
197ahash_destroy(struct htable *t)
198{
199 struct hbucket *n;
200 u32 i;
201
202 for (i = 0; i < jhash_size(t->htable_bits); i++) {
203 n = hbucket(t, i);
204 if (n->size)
205 /* FIXME: use slab cache */
206 kfree(n->value);
207 }
208
209 ip_set_free(t);
210}
211
212/* Calculate the actual memory size of the set data */
213static size_t
214ahash_memsize(const struct ip_set_hash *h, size_t dsize, u8 nets_length)
215{
216 u32 i;
217 struct htable *t = h->table;
218 size_t memsize = sizeof(*h)
219 + sizeof(*t)
220#ifdef IP_SET_HASH_WITH_NETS
221 + sizeof(struct ip_set_hash_nets) * nets_length
222#endif
223 + jhash_size(t->htable_bits) * sizeof(struct hbucket);
224
225 for (i = 0; i < jhash_size(t->htable_bits); i++)
226 memsize += t->bucket[i].size * dsize;
227
228 return memsize;
229}
230
231/* Flush a hash type of set: destroy all elements */
232static void
233ip_set_hash_flush(struct ip_set *set)
234{
235 struct ip_set_hash *h = set->data;
236 struct htable *t = h->table;
237 struct hbucket *n;
238 u32 i;
239
240 for (i = 0; i < jhash_size(t->htable_bits); i++) {
241 n = hbucket(t, i);
242 if (n->size) {
243 n->size = n->pos = 0;
244 /* FIXME: use slab cache */
245 kfree(n->value);
246 }
247 }
248#ifdef IP_SET_HASH_WITH_NETS
249 memset(h->nets, 0, sizeof(struct ip_set_hash_nets)
250 * NETS_LENGTH(set->family));
251#endif
252 h->elements = 0;
253}
254
255/* Destroy a hash type of set */
256static void
257ip_set_hash_destroy(struct ip_set *set)
258{
259 struct ip_set_hash *h = set->data;
260
261 if (with_timeout(h->timeout))
262 del_timer_sync(&h->gc);
263
264 ahash_destroy(h->table);
265#ifdef IP_SET_HASH_WITH_RBTREE
266 rbtree_destroy(&h->rbtree);
267#endif
268 kfree(h);
269
270 set->data = NULL;
271}
272
273#endif /* _IP_SET_AHASH_H */
274
275#ifndef HKEY_DATALEN
276#define HKEY_DATALEN sizeof(struct type_pf_elem)
277#endif
278
279#define HKEY(data, initval, htable_bits) \
280(jhash2((u32 *)(data), HKEY_DATALEN/sizeof(u32), initval) \
281 & jhash_mask(htable_bits))
282
283/* Type/family dependent function prototypes */
284
285#define type_pf_data_equal TOKEN(TYPE, PF, _data_equal)
286#define type_pf_data_isnull TOKEN(TYPE, PF, _data_isnull)
287#define type_pf_data_copy TOKEN(TYPE, PF, _data_copy)
288#define type_pf_data_zero_out TOKEN(TYPE, PF, _data_zero_out)
289#define type_pf_data_netmask TOKEN(TYPE, PF, _data_netmask)
290#define type_pf_data_list TOKEN(TYPE, PF, _data_list)
291#define type_pf_data_tlist TOKEN(TYPE, PF, _data_tlist)
292#define type_pf_data_next TOKEN(TYPE, PF, _data_next)
293#define type_pf_data_flags TOKEN(TYPE, PF, _data_flags)
294#define type_pf_data_reset_flags TOKEN(TYPE, PF, _data_reset_flags)
295#ifdef IP_SET_HASH_WITH_NETS
296#define type_pf_data_match TOKEN(TYPE, PF, _data_match)
297#else
298#define type_pf_data_match(d) 1
299#endif
300
301#define type_pf_elem TOKEN(TYPE, PF, _elem)
302#define type_pf_telem TOKEN(TYPE, PF, _telem)
303#define type_pf_data_timeout TOKEN(TYPE, PF, _data_timeout)
304#define type_pf_data_expired TOKEN(TYPE, PF, _data_expired)
305#define type_pf_data_timeout_set TOKEN(TYPE, PF, _data_timeout_set)
306
307#define type_pf_elem_add TOKEN(TYPE, PF, _elem_add)
308#define type_pf_add TOKEN(TYPE, PF, _add)
309#define type_pf_del TOKEN(TYPE, PF, _del)
310#define type_pf_test_cidrs TOKEN(TYPE, PF, _test_cidrs)
311#define type_pf_test TOKEN(TYPE, PF, _test)
312
313#define type_pf_elem_tadd TOKEN(TYPE, PF, _elem_tadd)
314#define type_pf_del_telem TOKEN(TYPE, PF, _ahash_del_telem)
315#define type_pf_expire TOKEN(TYPE, PF, _expire)
316#define type_pf_tadd TOKEN(TYPE, PF, _tadd)
317#define type_pf_tdel TOKEN(TYPE, PF, _tdel)
318#define type_pf_ttest_cidrs TOKEN(TYPE, PF, _ahash_ttest_cidrs)
319#define type_pf_ttest TOKEN(TYPE, PF, _ahash_ttest)
320
321#define type_pf_resize TOKEN(TYPE, PF, _resize)
322#define type_pf_tresize TOKEN(TYPE, PF, _tresize)
323#define type_pf_flush ip_set_hash_flush
324#define type_pf_destroy ip_set_hash_destroy
325#define type_pf_head TOKEN(TYPE, PF, _head)
326#define type_pf_list TOKEN(TYPE, PF, _list)
327#define type_pf_tlist TOKEN(TYPE, PF, _tlist)
328#define type_pf_same_set TOKEN(TYPE, PF, _same_set)
329#define type_pf_kadt TOKEN(TYPE, PF, _kadt)
330#define type_pf_uadt TOKEN(TYPE, PF, _uadt)
331#define type_pf_gc TOKEN(TYPE, PF, _gc)
332#define type_pf_gc_init TOKEN(TYPE, PF, _gc_init)
333#define type_pf_variant TOKEN(TYPE, PF, _variant)
334#define type_pf_tvariant TOKEN(TYPE, PF, _tvariant)
335
336/* Flavour without timeout */
337
338/* Get the ith element from the array block n */
339#define ahash_data(n, i) \
340 ((struct type_pf_elem *)((n)->value) + (i))
341
342/* Add an element to the hash table when resizing the set:
343 * we spare the maintenance of the internal counters. */
344static int
345type_pf_elem_add(struct hbucket *n, const struct type_pf_elem *value,
346 u8 ahash_max, u32 cadt_flags)
347{
348 struct type_pf_elem *data;
349
350 if (n->pos >= n->size) {
351 void *tmp;
352
353 if (n->size >= ahash_max)
354 /* Trigger rehashing */
355 return -EAGAIN;
356
357 tmp = kzalloc((n->size + AHASH_INIT_SIZE)
358 * sizeof(struct type_pf_elem),
359 GFP_ATOMIC);
360 if (!tmp)
361 return -ENOMEM;
362 if (n->size) {
363 memcpy(tmp, n->value,
364 sizeof(struct type_pf_elem) * n->size);
365 kfree(n->value);
366 }
367 n->value = tmp;
368 n->size += AHASH_INIT_SIZE;
369 }
370 data = ahash_data(n, n->pos++);
371 type_pf_data_copy(data, value);
372#ifdef IP_SET_HASH_WITH_NETS
373 /* Resizing won't overwrite stored flags */
374 if (cadt_flags)
375 type_pf_data_flags(data, cadt_flags);
376#endif
377 return 0;
378}
379
380/* Resize a hash: create a new hash table with doubling the hashsize
381 * and inserting the elements to it. Repeat until we succeed or
382 * fail due to memory pressures. */
383static int
384type_pf_resize(struct ip_set *set, bool retried)
385{
386 struct ip_set_hash *h = set->data;
387 struct htable *t, *orig = h->table;
388 u8 htable_bits = orig->htable_bits;
389 struct type_pf_elem *data;
390 struct hbucket *n, *m;
391 u32 i, j, flags = 0;
392 int ret;
393
394retry:
395 ret = 0;
396 htable_bits++;
397 pr_debug("attempt to resize set %s from %u to %u, t %p\n",
398 set->name, orig->htable_bits, htable_bits, orig);
399 if (!htable_bits) {
400 /* In case we have plenty of memory :-) */
401 pr_warning("Cannot increase the hashsize of set %s further\n",
402 set->name);
403 return -IPSET_ERR_HASH_FULL;
404 }
405 t = ip_set_alloc(sizeof(*t)
406 + jhash_size(htable_bits) * sizeof(struct hbucket));
407 if (!t)
408 return -ENOMEM;
409 t->htable_bits = htable_bits;
410
411 read_lock_bh(&set->lock);
412 for (i = 0; i < jhash_size(orig->htable_bits); i++) {
413 n = hbucket(orig, i);
414 for (j = 0; j < n->pos; j++) {
415 data = ahash_data(n, j);
416#ifdef IP_SET_HASH_WITH_NETS
417 flags = 0;
418 type_pf_data_reset_flags(data, &flags);
419#endif
420 m = hbucket(t, HKEY(data, h->initval, htable_bits));
421 ret = type_pf_elem_add(m, data, AHASH_MAX(h), flags);
422 if (ret < 0) {
423#ifdef IP_SET_HASH_WITH_NETS
424 type_pf_data_flags(data, flags);
425#endif
426 read_unlock_bh(&set->lock);
427 ahash_destroy(t);
428 if (ret == -EAGAIN)
429 goto retry;
430 return ret;
431 }
432 }
433 }
434
435 rcu_assign_pointer(h->table, t);
436 read_unlock_bh(&set->lock);
437
438 /* Give time to other readers of the set */
439 synchronize_rcu_bh();
440
441 pr_debug("set %s resized from %u (%p) to %u (%p)\n", set->name,
442 orig->htable_bits, orig, t->htable_bits, t);
443 ahash_destroy(orig);
444
445 return 0;
446}
447
448static inline void
449type_pf_data_next(struct ip_set_hash *h, const struct type_pf_elem *d);
450
451/* Add an element to a hash and update the internal counters when succeeded,
452 * otherwise report the proper error code. */
453static int
454type_pf_add(struct ip_set *set, void *value, u32 timeout, u32 flags)
455{
456 struct ip_set_hash *h = set->data;
457 struct htable *t;
458 const struct type_pf_elem *d = value;
459 struct hbucket *n;
460 int i, ret = 0;
461 u32 key, multi = 0;
462 u32 cadt_flags = flags >> 16;
463
464 if (h->elements >= h->maxelem) {
465 if (net_ratelimit())
466 pr_warning("Set %s is full, maxelem %u reached\n",
467 set->name, h->maxelem);
468 return -IPSET_ERR_HASH_FULL;
469 }
470
471 rcu_read_lock_bh();
472 t = rcu_dereference_bh(h->table);
473 key = HKEY(value, h->initval, t->htable_bits);
474 n = hbucket(t, key);
475 for (i = 0; i < n->pos; i++)
476 if (type_pf_data_equal(ahash_data(n, i), d, &multi)) {
477#ifdef IP_SET_HASH_WITH_NETS
478 if (flags & IPSET_FLAG_EXIST)
479 /* Support overwriting just the flags */
480 type_pf_data_flags(ahash_data(n, i),
481 cadt_flags);
482#endif
483 ret = -IPSET_ERR_EXIST;
484 goto out;
485 }
486 TUNE_AHASH_MAX(h, multi);
487 ret = type_pf_elem_add(n, value, AHASH_MAX(h), cadt_flags);
488 if (ret != 0) {
489 if (ret == -EAGAIN)
490 type_pf_data_next(h, d);
491 goto out;
492 }
493
494#ifdef IP_SET_HASH_WITH_NETS
495 add_cidr(h, CIDR(d->cidr), NETS_LENGTH(set->family));
496#endif
497 h->elements++;
498out:
499 rcu_read_unlock_bh();
500 return ret;
501}
502
503/* Delete an element from the hash: swap it with the last element
504 * and free up space if possible.
505 */
506static int
507type_pf_del(struct ip_set *set, void *value, u32 timeout, u32 flags)
508{
509 struct ip_set_hash *h = set->data;
510 struct htable *t = h->table;
511 const struct type_pf_elem *d = value;
512 struct hbucket *n;
513 int i;
514 struct type_pf_elem *data;
515 u32 key, multi = 0;
516
517 key = HKEY(value, h->initval, t->htable_bits);
518 n = hbucket(t, key);
519 for (i = 0; i < n->pos; i++) {
520 data = ahash_data(n, i);
521 if (!type_pf_data_equal(data, d, &multi))
522 continue;
523 if (i != n->pos - 1)
524 /* Not last one */
525 type_pf_data_copy(data, ahash_data(n, n->pos - 1));
526
527 n->pos--;
528 h->elements--;
529#ifdef IP_SET_HASH_WITH_NETS
530 del_cidr(h, CIDR(d->cidr), NETS_LENGTH(set->family));
531#endif
532 if (n->pos + AHASH_INIT_SIZE < n->size) {
533 void *tmp = kzalloc((n->size - AHASH_INIT_SIZE)
534 * sizeof(struct type_pf_elem),
535 GFP_ATOMIC);
536 if (!tmp)
537 return 0;
538 n->size -= AHASH_INIT_SIZE;
539 memcpy(tmp, n->value,
540 n->size * sizeof(struct type_pf_elem));
541 kfree(n->value);
542 n->value = tmp;
543 }
544 return 0;
545 }
546
547 return -IPSET_ERR_EXIST;
548}
549
550#ifdef IP_SET_HASH_WITH_NETS
551
552/* Special test function which takes into account the different network
553 * sizes added to the set */
554static int
555type_pf_test_cidrs(struct ip_set *set, struct type_pf_elem *d, u32 timeout)
556{
557 struct ip_set_hash *h = set->data;
558 struct htable *t = h->table;
559 struct hbucket *n;
560 const struct type_pf_elem *data;
561 int i, j = 0;
562 u32 key, multi = 0;
563 u8 nets_length = NETS_LENGTH(set->family);
564
565 pr_debug("test by nets\n");
566 for (; j < nets_length && h->nets[j].nets && !multi; j++) {
567 type_pf_data_netmask(d, h->nets[j].cidr);
568 key = HKEY(d, h->initval, t->htable_bits);
569 n = hbucket(t, key);
570 for (i = 0; i < n->pos; i++) {
571 data = ahash_data(n, i);
572 if (type_pf_data_equal(data, d, &multi))
573 return type_pf_data_match(data);
574 }
575 }
576 return 0;
577}
578#endif
579
580/* Test whether the element is added to the set */
581static int
582type_pf_test(struct ip_set *set, void *value, u32 timeout, u32 flags)
583{
584 struct ip_set_hash *h = set->data;
585 struct htable *t = h->table;
586 struct type_pf_elem *d = value;
587 struct hbucket *n;
588 const struct type_pf_elem *data;
589 int i;
590 u32 key, multi = 0;
591
592#ifdef IP_SET_HASH_WITH_NETS
593 /* If we test an IP address and not a network address,
594 * try all possible network sizes */
595 if (CIDR(d->cidr) == SET_HOST_MASK(set->family))
596 return type_pf_test_cidrs(set, d, timeout);
597#endif
598
599 key = HKEY(d, h->initval, t->htable_bits);
600 n = hbucket(t, key);
601 for (i = 0; i < n->pos; i++) {
602 data = ahash_data(n, i);
603 if (type_pf_data_equal(data, d, &multi))
604 return type_pf_data_match(data);
605 }
606 return 0;
607}
608
609/* Reply a HEADER request: fill out the header part of the set */
610static int
611type_pf_head(struct ip_set *set, struct sk_buff *skb)
612{
613 const struct ip_set_hash *h = set->data;
614 struct nlattr *nested;
615 size_t memsize;
616
617 read_lock_bh(&set->lock);
618 memsize = ahash_memsize(h, with_timeout(h->timeout)
619 ? sizeof(struct type_pf_telem)
620 : sizeof(struct type_pf_elem),
621 NETS_LENGTH(set->family));
622 read_unlock_bh(&set->lock);
623
624 nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
625 if (!nested)
626 goto nla_put_failure;
627 if (nla_put_net32(skb, IPSET_ATTR_HASHSIZE,
628 htonl(jhash_size(h->table->htable_bits))) ||
629 nla_put_net32(skb, IPSET_ATTR_MAXELEM, htonl(h->maxelem)))
630 goto nla_put_failure;
631#ifdef IP_SET_HASH_WITH_NETMASK
632 if (h->netmask != HOST_MASK &&
633 nla_put_u8(skb, IPSET_ATTR_NETMASK, h->netmask))
634 goto nla_put_failure;
635#endif
636 if (nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) ||
637 nla_put_net32(skb, IPSET_ATTR_MEMSIZE, htonl(memsize)) ||
638 (with_timeout(h->timeout) &&
639 nla_put_net32(skb, IPSET_ATTR_TIMEOUT, htonl(h->timeout))))
640 goto nla_put_failure;
641 ipset_nest_end(skb, nested);
642
643 return 0;
644nla_put_failure:
645 return -EMSGSIZE;
646}
647
648/* Reply a LIST/SAVE request: dump the elements of the specified set */
649static int
650type_pf_list(const struct ip_set *set,
651 struct sk_buff *skb, struct netlink_callback *cb)
652{
653 const struct ip_set_hash *h = set->data;
654 const struct htable *t = h->table;
655 struct nlattr *atd, *nested;
656 const struct hbucket *n;
657 const struct type_pf_elem *data;
658 u32 first = cb->args[2];
659 /* We assume that one hash bucket fills into one page */
660 void *incomplete;
661 int i;
662
663 atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
664 if (!atd)
665 return -EMSGSIZE;
666 pr_debug("list hash set %s\n", set->name);
667 for (; cb->args[2] < jhash_size(t->htable_bits); cb->args[2]++) {
668 incomplete = skb_tail_pointer(skb);
669 n = hbucket(t, cb->args[2]);
670 pr_debug("cb->args[2]: %lu, t %p n %p\n", cb->args[2], t, n);
671 for (i = 0; i < n->pos; i++) {
672 data = ahash_data(n, i);
673 pr_debug("list hash %lu hbucket %p i %u, data %p\n",
674 cb->args[2], n, i, data);
675 nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
676 if (!nested) {
677 if (cb->args[2] == first) {
678 nla_nest_cancel(skb, atd);
679 return -EMSGSIZE;
680 } else
681 goto nla_put_failure;
682 }
683 if (type_pf_data_list(skb, data))
684 goto nla_put_failure;
685 ipset_nest_end(skb, nested);
686 }
687 }
688 ipset_nest_end(skb, atd);
689 /* Set listing finished */
690 cb->args[2] = 0;
691
692 return 0;
693
694nla_put_failure:
695 nlmsg_trim(skb, incomplete);
696 ipset_nest_end(skb, atd);
697 if (unlikely(first == cb->args[2])) {
698 pr_warning("Can't list set %s: one bucket does not fit into "
699 "a message. Please report it!\n", set->name);
700 cb->args[2] = 0;
701 return -EMSGSIZE;
702 }
703 return 0;
704}
705
706static int
707type_pf_kadt(struct ip_set *set, const struct sk_buff *skb,
708 const struct xt_action_param *par,
709 enum ipset_adt adt, const struct ip_set_adt_opt *opt);
710static int
711type_pf_uadt(struct ip_set *set, struct nlattr *tb[],
712 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried);
713
714static const struct ip_set_type_variant type_pf_variant = {
715 .kadt = type_pf_kadt,
716 .uadt = type_pf_uadt,
717 .adt = {
718 [IPSET_ADD] = type_pf_add,
719 [IPSET_DEL] = type_pf_del,
720 [IPSET_TEST] = type_pf_test,
721 },
722 .destroy = type_pf_destroy,
723 .flush = type_pf_flush,
724 .head = type_pf_head,
725 .list = type_pf_list,
726 .resize = type_pf_resize,
727 .same_set = type_pf_same_set,
728};
729
730/* Flavour with timeout support */
731
732#define ahash_tdata(n, i) \
733 (struct type_pf_elem *)((struct type_pf_telem *)((n)->value) + (i))
734
735static inline u32
736type_pf_data_timeout(const struct type_pf_elem *data)
737{
738 const struct type_pf_telem *tdata =
739 (const struct type_pf_telem *) data;
740
741 return tdata->timeout;
742}
743
744static inline bool
745type_pf_data_expired(const struct type_pf_elem *data)
746{
747 const struct type_pf_telem *tdata =
748 (const struct type_pf_telem *) data;
749
750 return ip_set_timeout_expired(tdata->timeout);
751}
752
753static inline void
754type_pf_data_timeout_set(struct type_pf_elem *data, u32 timeout)
755{
756 struct type_pf_telem *tdata = (struct type_pf_telem *) data;
757
758 tdata->timeout = ip_set_timeout_set(timeout);
759}
760
761static int
762type_pf_elem_tadd(struct hbucket *n, const struct type_pf_elem *value,
763 u8 ahash_max, u32 cadt_flags, u32 timeout)
764{
765 struct type_pf_elem *data;
766
767 if (n->pos >= n->size) {
768 void *tmp;
769
770 if (n->size >= ahash_max)
771 /* Trigger rehashing */
772 return -EAGAIN;
773
774 tmp = kzalloc((n->size + AHASH_INIT_SIZE)
775 * sizeof(struct type_pf_telem),
776 GFP_ATOMIC);
777 if (!tmp)
778 return -ENOMEM;
779 if (n->size) {
780 memcpy(tmp, n->value,
781 sizeof(struct type_pf_telem) * n->size);
782 kfree(n->value);
783 }
784 n->value = tmp;
785 n->size += AHASH_INIT_SIZE;
786 }
787 data = ahash_tdata(n, n->pos++);
788 type_pf_data_copy(data, value);
789 type_pf_data_timeout_set(data, timeout);
790#ifdef IP_SET_HASH_WITH_NETS
791 /* Resizing won't overwrite stored flags */
792 if (cadt_flags)
793 type_pf_data_flags(data, cadt_flags);
794#endif
795 return 0;
796}
797
798/* Delete expired elements from the hashtable */
799static void
800type_pf_expire(struct ip_set_hash *h, u8 nets_length)
801{
802 struct htable *t = h->table;
803 struct hbucket *n;
804 struct type_pf_elem *data;
805 u32 i;
806 int j;
807
808 for (i = 0; i < jhash_size(t->htable_bits); i++) {
809 n = hbucket(t, i);
810 for (j = 0; j < n->pos; j++) {
811 data = ahash_tdata(n, j);
812 if (type_pf_data_expired(data)) {
813 pr_debug("expired %u/%u\n", i, j);
814#ifdef IP_SET_HASH_WITH_NETS
815 del_cidr(h, CIDR(data->cidr), nets_length);
816#endif
817 if (j != n->pos - 1)
818 /* Not last one */
819 type_pf_data_copy(data,
820 ahash_tdata(n, n->pos - 1));
821 n->pos--;
822 h->elements--;
823 }
824 }
825 if (n->pos + AHASH_INIT_SIZE < n->size) {
826 void *tmp = kzalloc((n->size - AHASH_INIT_SIZE)
827 * sizeof(struct type_pf_telem),
828 GFP_ATOMIC);
829 if (!tmp)
830 /* Still try to delete expired elements */
831 continue;
832 n->size -= AHASH_INIT_SIZE;
833 memcpy(tmp, n->value,
834 n->size * sizeof(struct type_pf_telem));
835 kfree(n->value);
836 n->value = tmp;
837 }
838 }
839}
840
841static int
842type_pf_tresize(struct ip_set *set, bool retried)
843{
844 struct ip_set_hash *h = set->data;
845 struct htable *t, *orig = h->table;
846 u8 htable_bits = orig->htable_bits;
847 struct type_pf_elem *data;
848 struct hbucket *n, *m;
849 u32 i, j, flags = 0;
850 int ret;
851
852 /* Try to cleanup once */
853 if (!retried) {
854 i = h->elements;
855 write_lock_bh(&set->lock);
856 type_pf_expire(set->data, NETS_LENGTH(set->family));
857 write_unlock_bh(&set->lock);
858 if (h->elements < i)
859 return 0;
860 }
861
862retry:
863 ret = 0;
864 htable_bits++;
865 pr_debug("attempt to resize set %s from %u to %u, t %p\n",
866 set->name, orig->htable_bits, htable_bits, orig);
867 if (!htable_bits) {
868 /* In case we have plenty of memory :-) */
869 pr_warning("Cannot increase the hashsize of set %s further\n",
870 set->name);
871 return -IPSET_ERR_HASH_FULL;
872 }
873 t = ip_set_alloc(sizeof(*t)
874 + jhash_size(htable_bits) * sizeof(struct hbucket));
875 if (!t)
876 return -ENOMEM;
877 t->htable_bits = htable_bits;
878
879 read_lock_bh(&set->lock);
880 for (i = 0; i < jhash_size(orig->htable_bits); i++) {
881 n = hbucket(orig, i);
882 for (j = 0; j < n->pos; j++) {
883 data = ahash_tdata(n, j);
884#ifdef IP_SET_HASH_WITH_NETS
885 flags = 0;
886 type_pf_data_reset_flags(data, &flags);
887#endif
888 m = hbucket(t, HKEY(data, h->initval, htable_bits));
889 ret = type_pf_elem_tadd(m, data, AHASH_MAX(h), flags,
890 ip_set_timeout_get(type_pf_data_timeout(data)));
891 if (ret < 0) {
892#ifdef IP_SET_HASH_WITH_NETS
893 type_pf_data_flags(data, flags);
894#endif
895 read_unlock_bh(&set->lock);
896 ahash_destroy(t);
897 if (ret == -EAGAIN)
898 goto retry;
899 return ret;
900 }
901 }
902 }
903
904 rcu_assign_pointer(h->table, t);
905 read_unlock_bh(&set->lock);
906
907 /* Give time to other readers of the set */
908 synchronize_rcu_bh();
909
910 ahash_destroy(orig);
911
912 return 0;
913}
914
915static int
916type_pf_tadd(struct ip_set *set, void *value, u32 timeout, u32 flags)
917{
918 struct ip_set_hash *h = set->data;
919 struct htable *t = h->table;
920 const struct type_pf_elem *d = value;
921 struct hbucket *n;
922 struct type_pf_elem *data;
923 int ret = 0, i, j = AHASH_MAX(h) + 1;
924 bool flag_exist = flags & IPSET_FLAG_EXIST;
925 u32 key, multi = 0;
926 u32 cadt_flags = flags >> 16;
927
928 if (h->elements >= h->maxelem)
929 /* FIXME: when set is full, we slow down here */
930 type_pf_expire(h, NETS_LENGTH(set->family));
931 if (h->elements >= h->maxelem) {
932 if (net_ratelimit())
933 pr_warning("Set %s is full, maxelem %u reached\n",
934 set->name, h->maxelem);
935 return -IPSET_ERR_HASH_FULL;
936 }
937
938 rcu_read_lock_bh();
939 t = rcu_dereference_bh(h->table);
940 key = HKEY(d, h->initval, t->htable_bits);
941 n = hbucket(t, key);
942 for (i = 0; i < n->pos; i++) {
943 data = ahash_tdata(n, i);
944 if (type_pf_data_equal(data, d, &multi)) {
945 if (type_pf_data_expired(data) || flag_exist)
946 /* Just timeout value may be updated */
947 j = i;
948 else {
949 ret = -IPSET_ERR_EXIST;
950 goto out;
951 }
952 } else if (j == AHASH_MAX(h) + 1 &&
953 type_pf_data_expired(data))
954 j = i;
955 }
956 if (j != AHASH_MAX(h) + 1) {
957 data = ahash_tdata(n, j);
958#ifdef IP_SET_HASH_WITH_NETS
959 del_cidr(h, CIDR(data->cidr), NETS_LENGTH(set->family));
960 add_cidr(h, CIDR(d->cidr), NETS_LENGTH(set->family));
961#endif
962 type_pf_data_copy(data, d);
963 type_pf_data_timeout_set(data, timeout);
964#ifdef IP_SET_HASH_WITH_NETS
965 type_pf_data_flags(data, cadt_flags);
966#endif
967 goto out;
968 }
969 TUNE_AHASH_MAX(h, multi);
970 ret = type_pf_elem_tadd(n, d, AHASH_MAX(h), cadt_flags, timeout);
971 if (ret != 0) {
972 if (ret == -EAGAIN)
973 type_pf_data_next(h, d);
974 goto out;
975 }
976
977#ifdef IP_SET_HASH_WITH_NETS
978 add_cidr(h, CIDR(d->cidr), NETS_LENGTH(set->family));
979#endif
980 h->elements++;
981out:
982 rcu_read_unlock_bh();
983 return ret;
984}
985
986static int
987type_pf_tdel(struct ip_set *set, void *value, u32 timeout, u32 flags)
988{
989 struct ip_set_hash *h = set->data;
990 struct htable *t = h->table;
991 const struct type_pf_elem *d = value;
992 struct hbucket *n;
993 int i;
994 struct type_pf_elem *data;
995 u32 key, multi = 0;
996
997 key = HKEY(value, h->initval, t->htable_bits);
998 n = hbucket(t, key);
999 for (i = 0; i < n->pos; i++) {
1000 data = ahash_tdata(n, i);
1001 if (!type_pf_data_equal(data, d, &multi))
1002 continue;
1003 if (type_pf_data_expired(data))
1004 return -IPSET_ERR_EXIST;
1005 if (i != n->pos - 1)
1006 /* Not last one */
1007 type_pf_data_copy(data, ahash_tdata(n, n->pos - 1));
1008
1009 n->pos--;
1010 h->elements--;
1011#ifdef IP_SET_HASH_WITH_NETS
1012 del_cidr(h, CIDR(d->cidr), NETS_LENGTH(set->family));
1013#endif
1014 if (n->pos + AHASH_INIT_SIZE < n->size) {
1015 void *tmp = kzalloc((n->size - AHASH_INIT_SIZE)
1016 * sizeof(struct type_pf_telem),
1017 GFP_ATOMIC);
1018 if (!tmp)
1019 return 0;
1020 n->size -= AHASH_INIT_SIZE;
1021 memcpy(tmp, n->value,
1022 n->size * sizeof(struct type_pf_telem));
1023 kfree(n->value);
1024 n->value = tmp;
1025 }
1026 return 0;
1027 }
1028
1029 return -IPSET_ERR_EXIST;
1030}
1031
1032#ifdef IP_SET_HASH_WITH_NETS
1033static int
1034type_pf_ttest_cidrs(struct ip_set *set, struct type_pf_elem *d, u32 timeout)
1035{
1036 struct ip_set_hash *h = set->data;
1037 struct htable *t = h->table;
1038 struct type_pf_elem *data;
1039 struct hbucket *n;
1040 int i, j = 0;
1041 u32 key, multi = 0;
1042 u8 nets_length = NETS_LENGTH(set->family);
1043
1044 for (; j < nets_length && h->nets[j].nets && !multi; j++) {
1045 type_pf_data_netmask(d, h->nets[j].cidr);
1046 key = HKEY(d, h->initval, t->htable_bits);
1047 n = hbucket(t, key);
1048 for (i = 0; i < n->pos; i++) {
1049 data = ahash_tdata(n, i);
1050#ifdef IP_SET_HASH_WITH_MULTI
1051 if (type_pf_data_equal(data, d, &multi)) {
1052 if (!type_pf_data_expired(data))
1053 return type_pf_data_match(data);
1054 multi = 0;
1055 }
1056#else
1057 if (type_pf_data_equal(data, d, &multi) &&
1058 !type_pf_data_expired(data))
1059 return type_pf_data_match(data);
1060#endif
1061 }
1062 }
1063 return 0;
1064}
1065#endif
1066
1067static int
1068type_pf_ttest(struct ip_set *set, void *value, u32 timeout, u32 flags)
1069{
1070 struct ip_set_hash *h = set->data;
1071 struct htable *t = h->table;
1072 struct type_pf_elem *data, *d = value;
1073 struct hbucket *n;
1074 int i;
1075 u32 key, multi = 0;
1076
1077#ifdef IP_SET_HASH_WITH_NETS
1078 if (CIDR(d->cidr) == SET_HOST_MASK(set->family))
1079 return type_pf_ttest_cidrs(set, d, timeout);
1080#endif
1081 key = HKEY(d, h->initval, t->htable_bits);
1082 n = hbucket(t, key);
1083 for (i = 0; i < n->pos; i++) {
1084 data = ahash_tdata(n, i);
1085 if (type_pf_data_equal(data, d, &multi) &&
1086 !type_pf_data_expired(data))
1087 return type_pf_data_match(data);
1088 }
1089 return 0;
1090}
1091
1092static int
1093type_pf_tlist(const struct ip_set *set,
1094 struct sk_buff *skb, struct netlink_callback *cb)
1095{
1096 const struct ip_set_hash *h = set->data;
1097 const struct htable *t = h->table;
1098 struct nlattr *atd, *nested;
1099 const struct hbucket *n;
1100 const struct type_pf_elem *data;
1101 u32 first = cb->args[2];
1102 /* We assume that one hash bucket fills into one page */
1103 void *incomplete;
1104 int i;
1105
1106 atd = ipset_nest_start(skb, IPSET_ATTR_ADT);
1107 if (!atd)
1108 return -EMSGSIZE;
1109 for (; cb->args[2] < jhash_size(t->htable_bits); cb->args[2]++) {
1110 incomplete = skb_tail_pointer(skb);
1111 n = hbucket(t, cb->args[2]);
1112 for (i = 0; i < n->pos; i++) {
1113 data = ahash_tdata(n, i);
1114 pr_debug("list %p %u\n", n, i);
1115 if (type_pf_data_expired(data))
1116 continue;
1117 pr_debug("do list %p %u\n", n, i);
1118 nested = ipset_nest_start(skb, IPSET_ATTR_DATA);
1119 if (!nested) {
1120 if (cb->args[2] == first) {
1121 nla_nest_cancel(skb, atd);
1122 return -EMSGSIZE;
1123 } else
1124 goto nla_put_failure;
1125 }
1126 if (type_pf_data_tlist(skb, data))
1127 goto nla_put_failure;
1128 ipset_nest_end(skb, nested);
1129 }
1130 }
1131 ipset_nest_end(skb, atd);
1132 /* Set listing finished */
1133 cb->args[2] = 0;
1134
1135 return 0;
1136
1137nla_put_failure:
1138 nlmsg_trim(skb, incomplete);
1139 ipset_nest_end(skb, atd);
1140 if (unlikely(first == cb->args[2])) {
1141 pr_warning("Can't list set %s: one bucket does not fit into "
1142 "a message. Please report it!\n", set->name);
1143 cb->args[2] = 0;
1144 return -EMSGSIZE;
1145 }
1146 return 0;
1147}
1148
1149static const struct ip_set_type_variant type_pf_tvariant = {
1150 .kadt = type_pf_kadt,
1151 .uadt = type_pf_uadt,
1152 .adt = {
1153 [IPSET_ADD] = type_pf_tadd,
1154 [IPSET_DEL] = type_pf_tdel,
1155 [IPSET_TEST] = type_pf_ttest,
1156 },
1157 .destroy = type_pf_destroy,
1158 .flush = type_pf_flush,
1159 .head = type_pf_head,
1160 .list = type_pf_tlist,
1161 .resize = type_pf_tresize,
1162 .same_set = type_pf_same_set,
1163};
1164
1165static void
1166type_pf_gc(unsigned long ul_set)
1167{
1168 struct ip_set *set = (struct ip_set *) ul_set;
1169 struct ip_set_hash *h = set->data;
1170
1171 pr_debug("called\n");
1172 write_lock_bh(&set->lock);
1173 type_pf_expire(h, NETS_LENGTH(set->family));
1174 write_unlock_bh(&set->lock);
1175
1176 h->gc.expires = jiffies + IPSET_GC_PERIOD(h->timeout) * HZ;
1177 add_timer(&h->gc);
1178}
1179
1180static void
1181type_pf_gc_init(struct ip_set *set)
1182{
1183 struct ip_set_hash *h = set->data;
1184
1185 init_timer(&h->gc);
1186 h->gc.data = (unsigned long) set;
1187 h->gc.function = type_pf_gc;
1188 h->gc.expires = jiffies + IPSET_GC_PERIOD(h->timeout) * HZ;
1189 add_timer(&h->gc);
1190 pr_debug("gc initialized, run in every %u\n",
1191 IPSET_GC_PERIOD(h->timeout));
1192}
1193
1194#undef HKEY_DATALEN
1195#undef HKEY
1196#undef type_pf_data_equal
1197#undef type_pf_data_isnull
1198#undef type_pf_data_copy
1199#undef type_pf_data_zero_out
1200#undef type_pf_data_netmask
1201#undef type_pf_data_list
1202#undef type_pf_data_tlist
1203#undef type_pf_data_next
1204#undef type_pf_data_flags
1205#undef type_pf_data_reset_flags
1206#undef type_pf_data_match
1207
1208#undef type_pf_elem
1209#undef type_pf_telem
1210#undef type_pf_data_timeout
1211#undef type_pf_data_expired
1212#undef type_pf_data_timeout_set
1213
1214#undef type_pf_elem_add
1215#undef type_pf_add
1216#undef type_pf_del
1217#undef type_pf_test_cidrs
1218#undef type_pf_test
1219
1220#undef type_pf_elem_tadd
1221#undef type_pf_del_telem
1222#undef type_pf_expire
1223#undef type_pf_tadd
1224#undef type_pf_tdel
1225#undef type_pf_ttest_cidrs
1226#undef type_pf_ttest
1227
1228#undef type_pf_resize
1229#undef type_pf_tresize
1230#undef type_pf_flush
1231#undef type_pf_destroy
1232#undef type_pf_head
1233#undef type_pf_list
1234#undef type_pf_tlist
1235#undef type_pf_same_set
1236#undef type_pf_kadt
1237#undef type_pf_uadt
1238#undef type_pf_gc
1239#undef type_pf_gc_init
1240#undef type_pf_variant
1241#undef type_pf_tvariant
diff --git a/include/linux/netfilter/ipset/ip_set_bitmap.h b/include/linux/netfilter/ipset/ip_set_bitmap.h
index 1a30646d5be8..5e4662a71e01 100644
--- a/include/linux/netfilter/ipset/ip_set_bitmap.h
+++ b/include/linux/netfilter/ipset/ip_set_bitmap.h
@@ -5,6 +5,12 @@
5 5
6#define IPSET_BITMAP_MAX_RANGE 0x0000FFFF 6#define IPSET_BITMAP_MAX_RANGE 0x0000FFFF
7 7
8enum {
9 IPSET_ADD_FAILED = 1,
10 IPSET_ADD_STORE_PLAIN_TIMEOUT,
11 IPSET_ADD_START_STORED_TIMEOUT,
12};
13
8/* Common functions */ 14/* Common functions */
9 15
10static inline u32 16static inline u32
diff --git a/include/linux/netfilter/ipset/ip_set_timeout.h b/include/linux/netfilter/ipset/ip_set_timeout.h
index 41d9cfa08167..3aac04167ca7 100644
--- a/include/linux/netfilter/ipset/ip_set_timeout.h
+++ b/include/linux/netfilter/ipset/ip_set_timeout.h
@@ -1,7 +1,7 @@
1#ifndef _IP_SET_TIMEOUT_H 1#ifndef _IP_SET_TIMEOUT_H
2#define _IP_SET_TIMEOUT_H 2#define _IP_SET_TIMEOUT_H
3 3
4/* Copyright (C) 2003-2011 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> 4/* Copyright (C) 2003-2013 Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -17,13 +17,14 @@
17#define IPSET_GC_PERIOD(timeout) \ 17#define IPSET_GC_PERIOD(timeout) \
18 ((timeout/3) ? min_t(u32, (timeout)/3, IPSET_GC_TIME) : 1) 18 ((timeout/3) ? min_t(u32, (timeout)/3, IPSET_GC_TIME) : 1)
19 19
20/* Set is defined without timeout support: timeout value may be 0 */ 20/* Entry is set with no timeout value */
21#define IPSET_NO_TIMEOUT UINT_MAX 21#define IPSET_ELEM_PERMANENT 0
22 22
23#define with_timeout(timeout) ((timeout) != IPSET_NO_TIMEOUT) 23/* Set is defined with timeout support: timeout value may be 0 */
24#define IPSET_NO_TIMEOUT UINT_MAX
24 25
25#define opt_timeout(opt, map) \ 26#define ip_set_adt_opt_timeout(opt, map) \
26 (with_timeout((opt)->timeout) ? (opt)->timeout : (map)->timeout) 27((opt)->ext.timeout != IPSET_NO_TIMEOUT ? (opt)->ext.timeout : (map)->timeout)
27 28
28static inline unsigned int 29static inline unsigned int
29ip_set_timeout_uget(struct nlattr *tb) 30ip_set_timeout_uget(struct nlattr *tb)
@@ -38,61 +39,6 @@ ip_set_timeout_uget(struct nlattr *tb)
38 return timeout == IPSET_NO_TIMEOUT ? IPSET_NO_TIMEOUT - 1 : timeout; 39 return timeout == IPSET_NO_TIMEOUT ? IPSET_NO_TIMEOUT - 1 : timeout;
39} 40}
40 41
41#ifdef IP_SET_BITMAP_TIMEOUT
42
43/* Bitmap specific timeout constants and macros for the entries */
44
45/* Bitmap entry is unset */
46#define IPSET_ELEM_UNSET 0
47/* Bitmap entry is set with no timeout value */
48#define IPSET_ELEM_PERMANENT (UINT_MAX/2)
49
50static inline bool
51ip_set_timeout_test(unsigned long timeout)
52{
53 return timeout != IPSET_ELEM_UNSET &&
54 (timeout == IPSET_ELEM_PERMANENT ||
55 time_is_after_jiffies(timeout));
56}
57
58static inline bool
59ip_set_timeout_expired(unsigned long timeout)
60{
61 return timeout != IPSET_ELEM_UNSET &&
62 timeout != IPSET_ELEM_PERMANENT &&
63 time_is_before_jiffies(timeout);
64}
65
66static inline unsigned long
67ip_set_timeout_set(u32 timeout)
68{
69 unsigned long t;
70
71 if (!timeout)
72 return IPSET_ELEM_PERMANENT;
73
74 t = msecs_to_jiffies(timeout * 1000) + jiffies;
75 if (t == IPSET_ELEM_UNSET || t == IPSET_ELEM_PERMANENT)
76 /* Bingo! */
77 t++;
78
79 return t;
80}
81
82static inline u32
83ip_set_timeout_get(unsigned long timeout)
84{
85 return timeout == IPSET_ELEM_PERMANENT ? 0 :
86 jiffies_to_msecs(timeout - jiffies)/1000;
87}
88
89#else
90
91/* Hash specific timeout constants and macros for the entries */
92
93/* Hash entry is set with no timeout value */
94#define IPSET_ELEM_PERMANENT 0
95
96static inline bool 42static inline bool
97ip_set_timeout_test(unsigned long timeout) 43ip_set_timeout_test(unsigned long timeout)
98{ 44{
@@ -101,36 +47,32 @@ ip_set_timeout_test(unsigned long timeout)
101} 47}
102 48
103static inline bool 49static inline bool
104ip_set_timeout_expired(unsigned long timeout) 50ip_set_timeout_expired(unsigned long *timeout)
105{ 51{
106 return timeout != IPSET_ELEM_PERMANENT && 52 return *timeout != IPSET_ELEM_PERMANENT &&
107 time_is_before_jiffies(timeout); 53 time_is_before_jiffies(*timeout);
108} 54}
109 55
110static inline unsigned long 56static inline void
111ip_set_timeout_set(u32 timeout) 57ip_set_timeout_set(unsigned long *timeout, u32 t)
112{ 58{
113 unsigned long t; 59 if (!t) {
114 60 *timeout = IPSET_ELEM_PERMANENT;
115 if (!timeout) 61 return;
116 return IPSET_ELEM_PERMANENT; 62 }
117 63
118 t = msecs_to_jiffies(timeout * 1000) + jiffies; 64 *timeout = msecs_to_jiffies(t * 1000) + jiffies;
119 if (t == IPSET_ELEM_PERMANENT) 65 if (*timeout == IPSET_ELEM_PERMANENT)
120 /* Bingo! :-) */ 66 /* Bingo! :-) */
121 t++; 67 (*timeout)--;
122
123 return t;
124} 68}
125 69
126static inline u32 70static inline u32
127ip_set_timeout_get(unsigned long timeout) 71ip_set_timeout_get(unsigned long *timeout)
128{ 72{
129 return timeout == IPSET_ELEM_PERMANENT ? 0 : 73 return *timeout == IPSET_ELEM_PERMANENT ? 0 :
130 jiffies_to_msecs(timeout - jiffies)/1000; 74 jiffies_to_msecs(*timeout - jiffies)/1000;
131} 75}
132#endif /* ! IP_SET_BITMAP_TIMEOUT */
133 76
134#endif /* __KERNEL__ */ 77#endif /* __KERNEL__ */
135
136#endif /* _IP_SET_TIMEOUT_H */ 78#endif /* _IP_SET_TIMEOUT_H */
diff --git a/include/linux/netfilter/ipset/pfxlen.h b/include/linux/netfilter/ipset/pfxlen.h
index 199fd11fedc0..1afbb94b4b65 100644
--- a/include/linux/netfilter/ipset/pfxlen.h
+++ b/include/linux/netfilter/ipset/pfxlen.h
@@ -41,4 +41,13 @@ do { \
41 to = from | ~ip_set_hostmask(cidr); \ 41 to = from | ~ip_set_hostmask(cidr); \
42} while (0) 42} while (0)
43 43
44static inline void
45ip6_netmask(union nf_inet_addr *ip, u8 prefix)
46{
47 ip->ip6[0] &= ip_set_netmask6(prefix)[0];
48 ip->ip6[1] &= ip_set_netmask6(prefix)[1];
49 ip->ip6[2] &= ip_set_netmask6(prefix)[2];
50 ip->ip6[3] &= ip_set_netmask6(prefix)[3];
51}
52
44#endif /*_PFXLEN_H */ 53#endif /*_PFXLEN_H */
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index ecbb8e495912..cadb7402d7a7 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -29,10 +29,13 @@ extern int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n);
29extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n); 29extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n);
30 30
31extern int nfnetlink_has_listeners(struct net *net, unsigned int group); 31extern int nfnetlink_has_listeners(struct net *net, unsigned int group);
32extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned int group, 32extern struct sk_buff *nfnetlink_alloc_skb(struct net *net, unsigned int size,
33 int echo, gfp_t flags); 33 u32 dst_portid, gfp_t gfp_mask);
34extern int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error); 34extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 portid,
35extern int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u_int32_t pid, int flags); 35 unsigned int group, int echo, gfp_t flags);
36extern int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error);
37extern int nfnetlink_unicast(struct sk_buff *skb, struct net *net,
38 u32 portid, int flags);
36 39
37extern void nfnl_lock(__u8 subsys_id); 40extern void nfnl_lock(__u8 subsys_id);
38extern void nfnl_unlock(__u8 subsys_id); 41extern void nfnl_unlock(__u8 subsys_id);
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index e0f746b7b95c..6358da5eeee8 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -15,11 +15,18 @@ static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
15 return (struct nlmsghdr *)skb->data; 15 return (struct nlmsghdr *)skb->data;
16} 16}
17 17
18enum netlink_skb_flags {
19 NETLINK_SKB_MMAPED = 0x1, /* Packet data is mmaped */
20 NETLINK_SKB_TX = 0x2, /* Packet was sent by userspace */
21 NETLINK_SKB_DELIVERED = 0x4, /* Packet was delivered */
22};
23
18struct netlink_skb_parms { 24struct netlink_skb_parms {
19 struct scm_creds creds; /* Skb credentials */ 25 struct scm_creds creds; /* Skb credentials */
20 __u32 portid; 26 __u32 portid;
21 __u32 dst_group; 27 __u32 dst_group;
22 struct sock *ssk; 28 __u32 flags;
29 struct sock *sk;
23}; 30};
24 31
25#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb)) 32#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
@@ -57,6 +64,8 @@ extern void __netlink_clear_multicast_users(struct sock *sk, unsigned int group)
57extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group); 64extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group);
58extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err); 65extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
59extern int netlink_has_listeners(struct sock *sk, unsigned int group); 66extern int netlink_has_listeners(struct sock *sk, unsigned int group);
67extern struct sk_buff *netlink_alloc_skb(struct sock *ssk, unsigned int size,
68 u32 dst_portid, gfp_t gfp_mask);
60extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock); 69extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock);
61extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid, 70extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
62 __u32 group, gfp_t allocation); 71 __u32 group, gfp_t allocation);
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 9d7d8c64f7c8..fa2cb76a7029 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -40,7 +40,7 @@ struct netpoll_info {
40 40
41 unsigned long rx_flags; 41 unsigned long rx_flags;
42 spinlock_t rx_lock; 42 spinlock_t rx_lock;
43 struct mutex dev_lock; 43 struct semaphore dev_lock;
44 struct list_head rx_np; /* netpolls that registered an rx_hook */ 44 struct list_head rx_np; /* netpolls that registered an rx_hook */
45 45
46 struct sk_buff_head neigh_tx; /* list of neigh requests to reply to */ 46 struct sk_buff_head neigh_tx; /* list of neigh requests to reply to */
diff --git a/include/linux/of_net.h b/include/linux/of_net.h
index f47464188710..61bf53b02779 100644
--- a/include/linux/of_net.h
+++ b/include/linux/of_net.h
@@ -11,6 +11,16 @@
11#include <linux/of.h> 11#include <linux/of.h>
12extern const int of_get_phy_mode(struct device_node *np); 12extern const int of_get_phy_mode(struct device_node *np);
13extern const void *of_get_mac_address(struct device_node *np); 13extern const void *of_get_mac_address(struct device_node *np);
14#else
15static inline const int of_get_phy_mode(struct device_node *np)
16{
17 return -ENODEV;
18}
19
20static inline const void *of_get_mac_address(struct device_node *np)
21{
22 return NULL;
23}
14#endif 24#endif
15 25
16#endif /* __LINUX_OF_NET_H */ 26#endif /* __LINUX_OF_NET_H */
diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index d42e174bd0c8..e6b240b6196c 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -19,435 +19,6 @@
19#ifndef _LINUX_OPENVSWITCH_H 19#ifndef _LINUX_OPENVSWITCH_H
20#define _LINUX_OPENVSWITCH_H 1 20#define _LINUX_OPENVSWITCH_H 1
21 21
22#include <linux/types.h> 22#include <uapi/linux/openvswitch.h>
23
24/**
25 * struct ovs_header - header for OVS Generic Netlink messages.
26 * @dp_ifindex: ifindex of local port for datapath (0 to make a request not
27 * specific to a datapath).
28 *
29 * Attributes following the header are specific to a particular OVS Generic
30 * Netlink family, but all of the OVS families use this header.
31 */
32
33struct ovs_header {
34 int dp_ifindex;
35};
36
37/* Datapaths. */
38
39#define OVS_DATAPATH_FAMILY "ovs_datapath"
40#define OVS_DATAPATH_MCGROUP "ovs_datapath"
41#define OVS_DATAPATH_VERSION 0x1
42
43enum ovs_datapath_cmd {
44 OVS_DP_CMD_UNSPEC,
45 OVS_DP_CMD_NEW,
46 OVS_DP_CMD_DEL,
47 OVS_DP_CMD_GET,
48 OVS_DP_CMD_SET
49};
50
51/**
52 * enum ovs_datapath_attr - attributes for %OVS_DP_* commands.
53 * @OVS_DP_ATTR_NAME: Name of the network device that serves as the "local
54 * port". This is the name of the network device whose dp_ifindex is given in
55 * the &struct ovs_header. Always present in notifications. Required in
56 * %OVS_DP_NEW requests. May be used as an alternative to specifying
57 * dp_ifindex in other requests (with a dp_ifindex of 0).
58 * @OVS_DP_ATTR_UPCALL_PID: The Netlink socket in userspace that is initially
59 * set on the datapath port (for OVS_ACTION_ATTR_MISS). Only valid on
60 * %OVS_DP_CMD_NEW requests. A value of zero indicates that upcalls should
61 * not be sent.
62 * @OVS_DP_ATTR_STATS: Statistics about packets that have passed through the
63 * datapath. Always present in notifications.
64 *
65 * These attributes follow the &struct ovs_header within the Generic Netlink
66 * payload for %OVS_DP_* commands.
67 */
68enum ovs_datapath_attr {
69 OVS_DP_ATTR_UNSPEC,
70 OVS_DP_ATTR_NAME, /* name of dp_ifindex netdev */
71 OVS_DP_ATTR_UPCALL_PID, /* Netlink PID to receive upcalls */
72 OVS_DP_ATTR_STATS, /* struct ovs_dp_stats */
73 __OVS_DP_ATTR_MAX
74};
75
76#define OVS_DP_ATTR_MAX (__OVS_DP_ATTR_MAX - 1)
77
78struct ovs_dp_stats {
79 __u64 n_hit; /* Number of flow table matches. */
80 __u64 n_missed; /* Number of flow table misses. */
81 __u64 n_lost; /* Number of misses not sent to userspace. */
82 __u64 n_flows; /* Number of flows present */
83};
84
85struct ovs_vport_stats {
86 __u64 rx_packets; /* total packets received */
87 __u64 tx_packets; /* total packets transmitted */
88 __u64 rx_bytes; /* total bytes received */
89 __u64 tx_bytes; /* total bytes transmitted */
90 __u64 rx_errors; /* bad packets received */
91 __u64 tx_errors; /* packet transmit problems */
92 __u64 rx_dropped; /* no space in linux buffers */
93 __u64 tx_dropped; /* no space available in linux */
94};
95
96/* Fixed logical ports. */
97#define OVSP_LOCAL ((__u16)0)
98
99/* Packet transfer. */
100
101#define OVS_PACKET_FAMILY "ovs_packet"
102#define OVS_PACKET_VERSION 0x1
103
104enum ovs_packet_cmd {
105 OVS_PACKET_CMD_UNSPEC,
106
107 /* Kernel-to-user notifications. */
108 OVS_PACKET_CMD_MISS, /* Flow table miss. */
109 OVS_PACKET_CMD_ACTION, /* OVS_ACTION_ATTR_USERSPACE action. */
110
111 /* Userspace commands. */
112 OVS_PACKET_CMD_EXECUTE /* Apply actions to a packet. */
113};
114
115/**
116 * enum ovs_packet_attr - attributes for %OVS_PACKET_* commands.
117 * @OVS_PACKET_ATTR_PACKET: Present for all notifications. Contains the entire
118 * packet as received, from the start of the Ethernet header onward. For
119 * %OVS_PACKET_CMD_ACTION, %OVS_PACKET_ATTR_PACKET reflects changes made by
120 * actions preceding %OVS_ACTION_ATTR_USERSPACE, but %OVS_PACKET_ATTR_KEY is
121 * the flow key extracted from the packet as originally received.
122 * @OVS_PACKET_ATTR_KEY: Present for all notifications. Contains the flow key
123 * extracted from the packet as nested %OVS_KEY_ATTR_* attributes. This allows
124 * userspace to adapt its flow setup strategy by comparing its notion of the
125 * flow key against the kernel's.
126 * @OVS_PACKET_ATTR_ACTIONS: Contains actions for the packet. Used
127 * for %OVS_PACKET_CMD_EXECUTE. It has nested %OVS_ACTION_ATTR_* attributes.
128 * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION
129 * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
130 * %OVS_USERSPACE_ATTR_USERDATA attribute.
131 *
132 * These attributes follow the &struct ovs_header within the Generic Netlink
133 * payload for %OVS_PACKET_* commands.
134 */
135enum ovs_packet_attr {
136 OVS_PACKET_ATTR_UNSPEC,
137 OVS_PACKET_ATTR_PACKET, /* Packet data. */
138 OVS_PACKET_ATTR_KEY, /* Nested OVS_KEY_ATTR_* attributes. */
139 OVS_PACKET_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */
140 OVS_PACKET_ATTR_USERDATA, /* u64 OVS_ACTION_ATTR_USERSPACE arg. */
141 __OVS_PACKET_ATTR_MAX
142};
143
144#define OVS_PACKET_ATTR_MAX (__OVS_PACKET_ATTR_MAX - 1)
145
146/* Virtual ports. */
147
148#define OVS_VPORT_FAMILY "ovs_vport"
149#define OVS_VPORT_MCGROUP "ovs_vport"
150#define OVS_VPORT_VERSION 0x1
151
152enum ovs_vport_cmd {
153 OVS_VPORT_CMD_UNSPEC,
154 OVS_VPORT_CMD_NEW,
155 OVS_VPORT_CMD_DEL,
156 OVS_VPORT_CMD_GET,
157 OVS_VPORT_CMD_SET
158};
159
160enum ovs_vport_type {
161 OVS_VPORT_TYPE_UNSPEC,
162 OVS_VPORT_TYPE_NETDEV, /* network device */
163 OVS_VPORT_TYPE_INTERNAL, /* network device implemented by datapath */
164 __OVS_VPORT_TYPE_MAX
165};
166
167#define OVS_VPORT_TYPE_MAX (__OVS_VPORT_TYPE_MAX - 1)
168
169/**
170 * enum ovs_vport_attr - attributes for %OVS_VPORT_* commands.
171 * @OVS_VPORT_ATTR_PORT_NO: 32-bit port number within datapath.
172 * @OVS_VPORT_ATTR_TYPE: 32-bit %OVS_VPORT_TYPE_* constant describing the type
173 * of vport.
174 * @OVS_VPORT_ATTR_NAME: Name of vport. For a vport based on a network device
175 * this is the name of the network device. Maximum length %IFNAMSIZ-1 bytes
176 * plus a null terminator.
177 * @OVS_VPORT_ATTR_OPTIONS: Vport-specific configuration information.
178 * @OVS_VPORT_ATTR_UPCALL_PID: The Netlink socket in userspace that
179 * OVS_PACKET_CMD_MISS upcalls will be directed to for packets received on
180 * this port. A value of zero indicates that upcalls should not be sent.
181 * @OVS_VPORT_ATTR_STATS: A &struct ovs_vport_stats giving statistics for
182 * packets sent or received through the vport.
183 *
184 * These attributes follow the &struct ovs_header within the Generic Netlink
185 * payload for %OVS_VPORT_* commands.
186 *
187 * For %OVS_VPORT_CMD_NEW requests, the %OVS_VPORT_ATTR_TYPE and
188 * %OVS_VPORT_ATTR_NAME attributes are required. %OVS_VPORT_ATTR_PORT_NO is
189 * optional; if not specified a free port number is automatically selected.
190 * Whether %OVS_VPORT_ATTR_OPTIONS is required or optional depends on the type
191 * of vport.
192 * and other attributes are ignored.
193 *
194 * For other requests, if %OVS_VPORT_ATTR_NAME is specified then it is used to
195 * look up the vport to operate on; otherwise dp_idx from the &struct
196 * ovs_header plus %OVS_VPORT_ATTR_PORT_NO determine the vport.
197 */
198enum ovs_vport_attr {
199 OVS_VPORT_ATTR_UNSPEC,
200 OVS_VPORT_ATTR_PORT_NO, /* u32 port number within datapath */
201 OVS_VPORT_ATTR_TYPE, /* u32 OVS_VPORT_TYPE_* constant. */
202 OVS_VPORT_ATTR_NAME, /* string name, up to IFNAMSIZ bytes long */
203 OVS_VPORT_ATTR_OPTIONS, /* nested attributes, varies by vport type */
204 OVS_VPORT_ATTR_UPCALL_PID, /* u32 Netlink PID to receive upcalls */
205 OVS_VPORT_ATTR_STATS, /* struct ovs_vport_stats */
206 __OVS_VPORT_ATTR_MAX
207};
208
209#define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1)
210
211/* Flows. */
212
213#define OVS_FLOW_FAMILY "ovs_flow"
214#define OVS_FLOW_MCGROUP "ovs_flow"
215#define OVS_FLOW_VERSION 0x1
216
217enum ovs_flow_cmd {
218 OVS_FLOW_CMD_UNSPEC,
219 OVS_FLOW_CMD_NEW,
220 OVS_FLOW_CMD_DEL,
221 OVS_FLOW_CMD_GET,
222 OVS_FLOW_CMD_SET
223};
224
225struct ovs_flow_stats {
226 __u64 n_packets; /* Number of matched packets. */
227 __u64 n_bytes; /* Number of matched bytes. */
228};
229
230enum ovs_key_attr {
231 OVS_KEY_ATTR_UNSPEC,
232 OVS_KEY_ATTR_ENCAP, /* Nested set of encapsulated attributes. */
233 OVS_KEY_ATTR_PRIORITY, /* u32 skb->priority */
234 OVS_KEY_ATTR_IN_PORT, /* u32 OVS dp port number */
235 OVS_KEY_ATTR_ETHERNET, /* struct ovs_key_ethernet */
236 OVS_KEY_ATTR_VLAN, /* be16 VLAN TCI */
237 OVS_KEY_ATTR_ETHERTYPE, /* be16 Ethernet type */
238 OVS_KEY_ATTR_IPV4, /* struct ovs_key_ipv4 */
239 OVS_KEY_ATTR_IPV6, /* struct ovs_key_ipv6 */
240 OVS_KEY_ATTR_TCP, /* struct ovs_key_tcp */
241 OVS_KEY_ATTR_UDP, /* struct ovs_key_udp */
242 OVS_KEY_ATTR_ICMP, /* struct ovs_key_icmp */
243 OVS_KEY_ATTR_ICMPV6, /* struct ovs_key_icmpv6 */
244 OVS_KEY_ATTR_ARP, /* struct ovs_key_arp */
245 OVS_KEY_ATTR_ND, /* struct ovs_key_nd */
246 OVS_KEY_ATTR_SKB_MARK, /* u32 skb mark */
247 __OVS_KEY_ATTR_MAX
248};
249
250#define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1)
251
252/**
253 * enum ovs_frag_type - IPv4 and IPv6 fragment type
254 * @OVS_FRAG_TYPE_NONE: Packet is not a fragment.
255 * @OVS_FRAG_TYPE_FIRST: Packet is a fragment with offset 0.
256 * @OVS_FRAG_TYPE_LATER: Packet is a fragment with nonzero offset.
257 *
258 * Used as the @ipv4_frag in &struct ovs_key_ipv4 and as @ipv6_frag &struct
259 * ovs_key_ipv6.
260 */
261enum ovs_frag_type {
262 OVS_FRAG_TYPE_NONE,
263 OVS_FRAG_TYPE_FIRST,
264 OVS_FRAG_TYPE_LATER,
265 __OVS_FRAG_TYPE_MAX
266};
267
268#define OVS_FRAG_TYPE_MAX (__OVS_FRAG_TYPE_MAX - 1)
269
270struct ovs_key_ethernet {
271 __u8 eth_src[6];
272 __u8 eth_dst[6];
273};
274
275struct ovs_key_ipv4 {
276 __be32 ipv4_src;
277 __be32 ipv4_dst;
278 __u8 ipv4_proto;
279 __u8 ipv4_tos;
280 __u8 ipv4_ttl;
281 __u8 ipv4_frag; /* One of OVS_FRAG_TYPE_*. */
282};
283
284struct ovs_key_ipv6 {
285 __be32 ipv6_src[4];
286 __be32 ipv6_dst[4];
287 __be32 ipv6_label; /* 20-bits in least-significant bits. */
288 __u8 ipv6_proto;
289 __u8 ipv6_tclass;
290 __u8 ipv6_hlimit;
291 __u8 ipv6_frag; /* One of OVS_FRAG_TYPE_*. */
292};
293
294struct ovs_key_tcp {
295 __be16 tcp_src;
296 __be16 tcp_dst;
297};
298
299struct ovs_key_udp {
300 __be16 udp_src;
301 __be16 udp_dst;
302};
303
304struct ovs_key_icmp {
305 __u8 icmp_type;
306 __u8 icmp_code;
307};
308
309struct ovs_key_icmpv6 {
310 __u8 icmpv6_type;
311 __u8 icmpv6_code;
312};
313
314struct ovs_key_arp {
315 __be32 arp_sip;
316 __be32 arp_tip;
317 __be16 arp_op;
318 __u8 arp_sha[6];
319 __u8 arp_tha[6];
320};
321
322struct ovs_key_nd {
323 __u32 nd_target[4];
324 __u8 nd_sll[6];
325 __u8 nd_tll[6];
326};
327
328/**
329 * enum ovs_flow_attr - attributes for %OVS_FLOW_* commands.
330 * @OVS_FLOW_ATTR_KEY: Nested %OVS_KEY_ATTR_* attributes specifying the flow
331 * key. Always present in notifications. Required for all requests (except
332 * dumps).
333 * @OVS_FLOW_ATTR_ACTIONS: Nested %OVS_ACTION_ATTR_* attributes specifying
334 * the actions to take for packets that match the key. Always present in
335 * notifications. Required for %OVS_FLOW_CMD_NEW requests, optional for
336 * %OVS_FLOW_CMD_SET requests.
337 * @OVS_FLOW_ATTR_STATS: &struct ovs_flow_stats giving statistics for this
338 * flow. Present in notifications if the stats would be nonzero. Ignored in
339 * requests.
340 * @OVS_FLOW_ATTR_TCP_FLAGS: An 8-bit value giving the OR'd value of all of the
341 * TCP flags seen on packets in this flow. Only present in notifications for
342 * TCP flows, and only if it would be nonzero. Ignored in requests.
343 * @OVS_FLOW_ATTR_USED: A 64-bit integer giving the time, in milliseconds on
344 * the system monotonic clock, at which a packet was last processed for this
345 * flow. Only present in notifications if a packet has been processed for this
346 * flow. Ignored in requests.
347 * @OVS_FLOW_ATTR_CLEAR: If present in a %OVS_FLOW_CMD_SET request, clears the
348 * last-used time, accumulated TCP flags, and statistics for this flow.
349 * Otherwise ignored in requests. Never present in notifications.
350 *
351 * These attributes follow the &struct ovs_header within the Generic Netlink
352 * payload for %OVS_FLOW_* commands.
353 */
354enum ovs_flow_attr {
355 OVS_FLOW_ATTR_UNSPEC,
356 OVS_FLOW_ATTR_KEY, /* Sequence of OVS_KEY_ATTR_* attributes. */
357 OVS_FLOW_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */
358 OVS_FLOW_ATTR_STATS, /* struct ovs_flow_stats. */
359 OVS_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */
360 OVS_FLOW_ATTR_USED, /* u64 msecs last used in monotonic time. */
361 OVS_FLOW_ATTR_CLEAR, /* Flag to clear stats, tcp_flags, used. */
362 __OVS_FLOW_ATTR_MAX
363};
364
365#define OVS_FLOW_ATTR_MAX (__OVS_FLOW_ATTR_MAX - 1)
366
367/**
368 * enum ovs_sample_attr - Attributes for %OVS_ACTION_ATTR_SAMPLE action.
369 * @OVS_SAMPLE_ATTR_PROBABILITY: 32-bit fraction of packets to sample with
370 * @OVS_ACTION_ATTR_SAMPLE. A value of 0 samples no packets, a value of
371 * %UINT32_MAX samples all packets and intermediate values sample intermediate
372 * fractions of packets.
373 * @OVS_SAMPLE_ATTR_ACTIONS: Set of actions to execute in sampling event.
374 * Actions are passed as nested attributes.
375 *
376 * Executes the specified actions with the given probability on a per-packet
377 * basis.
378 */
379enum ovs_sample_attr {
380 OVS_SAMPLE_ATTR_UNSPEC,
381 OVS_SAMPLE_ATTR_PROBABILITY, /* u32 number */
382 OVS_SAMPLE_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */
383 __OVS_SAMPLE_ATTR_MAX,
384};
385
386#define OVS_SAMPLE_ATTR_MAX (__OVS_SAMPLE_ATTR_MAX - 1)
387
388/**
389 * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action.
390 * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION
391 * message should be sent. Required.
392 * @OVS_USERSPACE_ATTR_USERDATA: If present, its u64 argument is copied to the
393 * %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA,
394 */
395enum ovs_userspace_attr {
396 OVS_USERSPACE_ATTR_UNSPEC,
397 OVS_USERSPACE_ATTR_PID, /* u32 Netlink PID to receive upcalls. */
398 OVS_USERSPACE_ATTR_USERDATA, /* u64 optional user-specified cookie. */
399 __OVS_USERSPACE_ATTR_MAX
400};
401
402#define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)
403
404/**
405 * struct ovs_action_push_vlan - %OVS_ACTION_ATTR_PUSH_VLAN action argument.
406 * @vlan_tpid: Tag protocol identifier (TPID) to push.
407 * @vlan_tci: Tag control identifier (TCI) to push. The CFI bit must be set
408 * (but it will not be set in the 802.1Q header that is pushed).
409 *
410 * The @vlan_tpid value is typically %ETH_P_8021Q. The only acceptable TPID
411 * values are those that the kernel module also parses as 802.1Q headers, to
412 * prevent %OVS_ACTION_ATTR_PUSH_VLAN followed by %OVS_ACTION_ATTR_POP_VLAN
413 * from having surprising results.
414 */
415struct ovs_action_push_vlan {
416 __be16 vlan_tpid; /* 802.1Q TPID. */
417 __be16 vlan_tci; /* 802.1Q TCI (VLAN ID and priority). */
418};
419
420/**
421 * enum ovs_action_attr - Action types.
422 *
423 * @OVS_ACTION_ATTR_OUTPUT: Output packet to port.
424 * @OVS_ACTION_ATTR_USERSPACE: Send packet to userspace according to nested
425 * %OVS_USERSPACE_ATTR_* attributes.
426 * @OVS_ACTION_ATTR_SET: Replaces the contents of an existing header. The
427 * single nested %OVS_KEY_ATTR_* attribute specifies a header to modify and its
428 * value.
429 * @OVS_ACTION_ATTR_PUSH_VLAN: Push a new outermost 802.1Q header onto the
430 * packet.
431 * @OVS_ACTION_ATTR_POP_VLAN: Pop the outermost 802.1Q header off the packet.
432 * @OVS_ACTION_ATTR_SAMPLE: Probabilitically executes actions, as specified in
433 * the nested %OVS_SAMPLE_ATTR_* attributes.
434 *
435 * Only a single header can be set with a single %OVS_ACTION_ATTR_SET. Not all
436 * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
437 * type may not be changed.
438 */
439
440enum ovs_action_attr {
441 OVS_ACTION_ATTR_UNSPEC,
442 OVS_ACTION_ATTR_OUTPUT, /* u32 port number. */
443 OVS_ACTION_ATTR_USERSPACE, /* Nested OVS_USERSPACE_ATTR_*. */
444 OVS_ACTION_ATTR_SET, /* One nested OVS_KEY_ATTR_*. */
445 OVS_ACTION_ATTR_PUSH_VLAN, /* struct ovs_action_push_vlan. */
446 OVS_ACTION_ATTR_POP_VLAN, /* No argument. */
447 OVS_ACTION_ATTR_SAMPLE, /* Nested OVS_SAMPLE_ATTR_*. */
448 __OVS_ACTION_ATTR_MAX
449};
450
451#define OVS_ACTION_ATTR_MAX (__OVS_ACTION_ATTR_MAX - 1)
452 23
453#endif /* _LINUX_OPENVSWITCH_H */ 24#endif /* _LINUX_OPENVSWITCH_H */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e73dfa308b87..3a24e4ff3248 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1661,6 +1661,7 @@ int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
1661void pci_disable_sriov(struct pci_dev *dev); 1661void pci_disable_sriov(struct pci_dev *dev);
1662irqreturn_t pci_sriov_migration(struct pci_dev *dev); 1662irqreturn_t pci_sriov_migration(struct pci_dev *dev);
1663int pci_num_vf(struct pci_dev *dev); 1663int pci_num_vf(struct pci_dev *dev);
1664int pci_vfs_assigned(struct pci_dev *dev);
1664int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs); 1665int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs);
1665int pci_sriov_get_totalvfs(struct pci_dev *dev); 1666int pci_sriov_get_totalvfs(struct pci_dev *dev);
1666#else 1667#else
@@ -1679,6 +1680,10 @@ static inline int pci_num_vf(struct pci_dev *dev)
1679{ 1680{
1680 return 0; 1681 return 0;
1681} 1682}
1683static inline int pci_vfs_assigned(struct pci_dev *dev)
1684{
1685 return 0;
1686}
1682static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) 1687static inline int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs)
1683{ 1688{
1684 return 0; 1689 return 0;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 33999adbf8c8..9e11039dd7a3 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -455,6 +455,14 @@ struct phy_driver {
455 */ 455 */
456 void (*txtstamp)(struct phy_device *dev, struct sk_buff *skb, int type); 456 void (*txtstamp)(struct phy_device *dev, struct sk_buff *skb, int type);
457 457
458 /* Some devices (e.g. qnap TS-119P II) require PHY register changes to
459 * enable Wake on LAN, so set_wol is provided to be called in the
460 * ethernet driver's set_wol function. */
461 int (*set_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
462
463 /* See set_wol, but for checking whether Wake on LAN is enabled. */
464 void (*get_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol);
465
458 struct device_driver driver; 466 struct device_driver driver;
459}; 467};
460#define to_phy_driver(d) container_of(d, struct phy_driver, driver) 468#define to_phy_driver(d) container_of(d, struct phy_driver, driver)
@@ -560,6 +568,8 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable);
560int phy_get_eee_err(struct phy_device *phydev); 568int phy_get_eee_err(struct phy_device *phydev);
561int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); 569int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data);
562int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data); 570int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data);
571int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol);
572void phy_ethtool_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol);
563 573
564int __init mdio_bus_init(void); 574int __init mdio_bus_init(void);
565void mdio_bus_exit(void); 575void mdio_bus_exit(void);
diff --git a/include/linux/platform_data/brcmfmac-sdio.h b/include/linux/platform_data/brcmfmac-sdio.h
new file mode 100644
index 000000000000..1ade657d5fc1
--- /dev/null
+++ b/include/linux/platform_data/brcmfmac-sdio.h
@@ -0,0 +1,124 @@
1/*
2 * Copyright (c) 2013 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _LINUX_BRCMFMAC_PLATFORM_H
18#define _LINUX_BRCMFMAC_PLATFORM_H
19
20/*
21 * Platform specific driver functions and data. Through the platform specific
22 * device data functions can be provided to help the brcmfmac driver to
23 * operate with the device in combination with the used platform.
24 *
25 * Use the platform data in the following (similar) way:
26 *
27 *
28#include <brcmfmac_platform.h>
29
30
31static void brcmfmac_power_on(void)
32{
33}
34
35static void brcmfmac_power_off(void)
36{
37}
38
39static void brcmfmac_reset(void)
40{
41}
42
43static struct brcmfmac_sdio_platform_data brcmfmac_sdio_pdata = {
44 .power_on = brcmfmac_power_on,
45 .power_off = brcmfmac_power_off,
46 .reset = brcmfmac_reset
47};
48
49static struct platform_device brcmfmac_device = {
50 .name = BRCMFMAC_SDIO_PDATA_NAME,
51 .id = PLATFORM_DEVID_NONE,
52 .dev.platform_data = &brcmfmac_sdio_pdata
53};
54
55void __init brcmfmac_init_pdata(void)
56{
57 brcmfmac_sdio_pdata.oob_irq_supported = true;
58 brcmfmac_sdio_pdata.oob_irq_nr = gpio_to_irq(GPIO_BRCMF_SDIO_OOB);
59 brcmfmac_sdio_pdata.oob_irq_flags = IORESOURCE_IRQ |
60 IORESOURCE_IRQ_HIGHLEVEL;
61 platform_device_register(&brcmfmac_device);
62}
63 *
64 *
65 * Note: the brcmfmac can be loaded as module or be statically built-in into
66 * the kernel. If built-in then do note that it uses module_init (and
67 * module_exit) routines which equal device_initcall. So if you intend to
68 * create a module with the platform specific data for the brcmfmac and have
69 * it built-in to the kernel then use a higher initcall then device_initcall
70 * (see init.h). If this is not done then brcmfmac will load without problems
71 * but will not pickup the platform data.
72 *
73 * When the driver does not "detect" platform driver data then it will continue
74 * without reporting anything and just assume there is no data needed. Which is
75 * probably true for most platforms.
76 *
77 * Explanation of the platform_data fields:
78 *
79 * drive_strength: is the preferred drive_strength to be used for the SDIO
80 * pins. If 0 then a default value will be used. This is the target drive
81 * strength, the exact drive strength which will be used depends on the
82 * capabilities of the device.
83 *
84 * oob_irq_supported: does the board have support for OOB interrupts. SDIO
85 * in-band interrupts are relatively slow and for having less overhead on
86 * interrupt processing an out of band interrupt can be used. If the HW
87 * supports this then enable this by setting this field to true and configure
88 * the oob related fields.
89 *
90 * oob_irq_nr, oob_irq_flags: the OOB interrupt information. The values are
91 * used for registering the irq using request_irq function.
92 *
93 * power_on: This function is called by the brcmfmac when the module gets
94 * loaded. This can be particularly useful for low power devices. The platform
95 * spcific routine may for example decide to power up the complete device.
96 * If there is no use-case for this function then provide NULL.
97 *
98 * power_off: This function is called by the brcmfmac when the module gets
99 * unloaded. At this point the device can be powered down or otherwise be reset.
100 * So if an actual power_off is not supported but reset is then reset the device
101 * when this function gets called. This can be particularly useful for low power
102 * devices. If there is no use-case for this function (either power-down or
103 * reset) then provide NULL.
104 *
105 * reset: This function can get called if the device communication broke down.
106 * This functionality is particularly useful in case of SDIO type devices. It is
107 * possible to reset a dongle via sdio data interface, but it requires that
108 * this is fully functional. This function is chip/module specific and this
109 * function should return only after the complete reset has completed.
110 */
111
112#define BRCMFMAC_SDIO_PDATA_NAME "brcmfmac_sdio"
113
114struct brcmfmac_sdio_platform_data {
115 unsigned int drive_strength;
116 bool oob_irq_supported;
117 unsigned int oob_irq_nr;
118 unsigned long oob_irq_flags;
119 void (*power_on)(void);
120 void (*power_off)(void);
121 void (*reset)(void);
122};
123
124#endif /* _LINUX_BRCMFMAC_PLATFORM_H */
diff --git a/include/linux/platform_data/cpsw.h b/include/linux/platform_data/cpsw.h
index 798fb80b024b..bb3cd58d71e3 100644
--- a/include/linux/platform_data/cpsw.h
+++ b/include/linux/platform_data/cpsw.h
@@ -30,7 +30,7 @@ struct cpsw_platform_data {
30 u32 channels; /* number of cpdma channels (symmetric) */ 30 u32 channels; /* number of cpdma channels (symmetric) */
31 u32 slaves; /* number of slave cpgmac ports */ 31 u32 slaves; /* number of slave cpgmac ports */
32 struct cpsw_slave_data *slave_data; 32 struct cpsw_slave_data *slave_data;
33 u32 cpts_active_slave; /* time stamping slave */ 33 u32 active_slave; /* time stamping, ethtool and SIOCGMIIPHY slave */
34 u32 cpts_clock_mult; /* convert input clock ticks to nanoseconds */ 34 u32 cpts_clock_mult; /* convert input clock ticks to nanoseconds */
35 u32 cpts_clock_shift; /* convert input clock ticks to nanoseconds */ 35 u32 cpts_clock_shift; /* convert input clock ticks to nanoseconds */
36 u32 ale_entries; /* ale table size */ 36 u32 ale_entries; /* ale table size */
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 489dd7bb28ec..f28544b2f9af 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -69,6 +69,15 @@ extern int ndo_dflt_fdb_dump(struct sk_buff *skb,
69 struct netlink_callback *cb, 69 struct netlink_callback *cb,
70 struct net_device *dev, 70 struct net_device *dev,
71 int idx); 71 int idx);
72extern int ndo_dflt_fdb_add(struct ndmsg *ndm,
73 struct nlattr *tb[],
74 struct net_device *dev,
75 const unsigned char *addr,
76 u16 flags);
77extern int ndo_dflt_fdb_del(struct ndmsg *ndm,
78 struct nlattr *tb[],
79 struct net_device *dev,
80 const unsigned char *addr);
72 81
73extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, 82extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
74 struct net_device *dev, u16 mode); 83 struct net_device *dev, u16 mode);
diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index c11a28706fa4..3bfe8d6ee248 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -53,7 +53,9 @@
53 53
54#include <linux/in.h> /* We need in_addr. */ 54#include <linux/in.h> /* We need in_addr. */
55#include <linux/in6.h> /* We need in6_addr. */ 55#include <linux/in6.h> /* We need in6_addr. */
56#include <linux/skbuff.h>
56 57
58#include <uapi/linux/sctp.h>
57 59
58/* Section 3.1. SCTP Common Header Format */ 60/* Section 3.1. SCTP Common Header Format */
59typedef struct sctphdr { 61typedef struct sctphdr {
@@ -63,14 +65,10 @@ typedef struct sctphdr {
63 __le32 checksum; 65 __le32 checksum;
64} __packed sctp_sctphdr_t; 66} __packed sctp_sctphdr_t;
65 67
66#ifdef __KERNEL__
67#include <linux/skbuff.h>
68
69static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb) 68static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
70{ 69{
71 return (struct sctphdr *)skb_transport_header(skb); 70 return (struct sctphdr *)skb_transport_header(skb);
72} 71}
73#endif
74 72
75/* Section 3.2. Chunk Field Descriptions. */ 73/* Section 3.2. Chunk Field Descriptions. */
76typedef struct sctp_chunkhdr { 74typedef struct sctp_chunkhdr {
diff --git a/include/linux/sh_eth.h b/include/linux/sh_eth.h
index b17d765ded84..fc305713fc6d 100644
--- a/include/linux/sh_eth.h
+++ b/include/linux/sh_eth.h
@@ -6,6 +6,7 @@
6enum {EDMAC_LITTLE_ENDIAN, EDMAC_BIG_ENDIAN}; 6enum {EDMAC_LITTLE_ENDIAN, EDMAC_BIG_ENDIAN};
7enum { 7enum {
8 SH_ETH_REG_GIGABIT, 8 SH_ETH_REG_GIGABIT,
9 SH_ETH_REG_FAST_RCAR,
9 SH_ETH_REG_FAST_SH4, 10 SH_ETH_REG_FAST_SH4,
10 SH_ETH_REG_FAST_SH3_SH2 11 SH_ETH_REG_FAST_SH3_SH2
11}; 12};
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index b8292d8cc9fa..2e0ced1af3b1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -32,6 +32,7 @@
32#include <linux/hrtimer.h> 32#include <linux/hrtimer.h>
33#include <linux/dma-mapping.h> 33#include <linux/dma-mapping.h>
34#include <linux/netdev_features.h> 34#include <linux/netdev_features.h>
35#include <net/flow_keys.h>
35 36
36/* Don't change this without changing skb_csum_unnecessary! */ 37/* Don't change this without changing skb_csum_unnecessary! */
37#define CHECKSUM_NONE 0 38#define CHECKSUM_NONE 0
@@ -316,6 +317,8 @@ enum {
316 SKB_GSO_FCOE = 1 << 5, 317 SKB_GSO_FCOE = 1 << 5,
317 318
318 SKB_GSO_GRE = 1 << 6, 319 SKB_GSO_GRE = 1 << 6,
320
321 SKB_GSO_UDP_TUNNEL = 1 << 7,
319}; 322};
320 323
321#if BITS_PER_LONG > 32 324#if BITS_PER_LONG > 32
@@ -384,9 +387,11 @@ typedef unsigned char *sk_buff_data_t;
384 * @secmark: security marking 387 * @secmark: security marking
385 * @mark: Generic packet mark 388 * @mark: Generic packet mark
386 * @dropcount: total number of sk_receive_queue overflows 389 * @dropcount: total number of sk_receive_queue overflows
390 * @vlan_proto: vlan encapsulation protocol
387 * @vlan_tci: vlan tag control information 391 * @vlan_tci: vlan tag control information
388 * @inner_transport_header: Inner transport layer header (encapsulation) 392 * @inner_transport_header: Inner transport layer header (encapsulation)
389 * @inner_network_header: Network layer header (encapsulation) 393 * @inner_network_header: Network layer header (encapsulation)
394 * @inner_mac_header: Link layer header (encapsulation)
390 * @transport_header: Transport layer header 395 * @transport_header: Transport layer header
391 * @network_header: Network layer header 396 * @network_header: Network layer header
392 * @mac_header: Link layer header 397 * @mac_header: Link layer header
@@ -461,6 +466,7 @@ struct sk_buff {
461 466
462 __u32 rxhash; 467 __u32 rxhash;
463 468
469 __be16 vlan_proto;
464 __u16 vlan_tci; 470 __u16 vlan_tci;
465 471
466#ifdef CONFIG_NET_SCHED 472#ifdef CONFIG_NET_SCHED
@@ -505,6 +511,7 @@ struct sk_buff {
505 511
506 sk_buff_data_t inner_transport_header; 512 sk_buff_data_t inner_transport_header;
507 sk_buff_data_t inner_network_header; 513 sk_buff_data_t inner_network_header;
514 sk_buff_data_t inner_mac_header;
508 sk_buff_data_t transport_header; 515 sk_buff_data_t transport_header;
509 sk_buff_data_t network_header; 516 sk_buff_data_t network_header;
510 sk_buff_data_t mac_header; 517 sk_buff_data_t mac_header;
@@ -570,7 +577,40 @@ static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst)
570 skb->_skb_refdst = (unsigned long)dst; 577 skb->_skb_refdst = (unsigned long)dst;
571} 578}
572 579
573extern void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst); 580extern void __skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst,
581 bool force);
582
583/**
584 * skb_dst_set_noref - sets skb dst, hopefully, without taking reference
585 * @skb: buffer
586 * @dst: dst entry
587 *
588 * Sets skb dst, assuming a reference was not taken on dst.
589 * If dst entry is cached, we do not take reference and dst_release
590 * will be avoided by refdst_drop. If dst entry is not cached, we take
591 * reference, so that last dst_release can destroy the dst immediately.
592 */
593static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst)
594{
595 __skb_dst_set_noref(skb, dst, false);
596}
597
598/**
599 * skb_dst_set_noref_force - sets skb dst, without taking reference
600 * @skb: buffer
601 * @dst: dst entry
602 *
603 * Sets skb dst, assuming a reference was not taken on dst.
604 * No reference is taken and no dst_release will be called. While for
605 * cached dsts deferred reclaim is a basic feature, for entries that are
606 * not cached it is caller's job to guarantee that last dst_release for
607 * provided dst happens when nobody uses it, eg. after a RCU grace period.
608 */
609static inline void skb_dst_set_noref_force(struct sk_buff *skb,
610 struct dst_entry *dst)
611{
612 __skb_dst_set_noref(skb, dst, true);
613}
574 614
575/** 615/**
576 * skb_dst_is_noref - Test if skb dst isn't refcounted 616 * skb_dst_is_noref - Test if skb dst isn't refcounted
@@ -611,6 +651,12 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
611 return __alloc_skb(size, priority, SKB_ALLOC_FCLONE, NUMA_NO_NODE); 651 return __alloc_skb(size, priority, SKB_ALLOC_FCLONE, NUMA_NO_NODE);
612} 652}
613 653
654extern struct sk_buff *__alloc_skb_head(gfp_t priority, int node);
655static inline struct sk_buff *alloc_skb_head(gfp_t priority)
656{
657 return __alloc_skb_head(priority, -1);
658}
659
614extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src); 660extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src);
615extern int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask); 661extern int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask);
616extern struct sk_buff *skb_clone(struct sk_buff *skb, 662extern struct sk_buff *skb_clone(struct sk_buff *skb,
@@ -1471,6 +1517,7 @@ static inline void skb_reserve(struct sk_buff *skb, int len)
1471 1517
1472static inline void skb_reset_inner_headers(struct sk_buff *skb) 1518static inline void skb_reset_inner_headers(struct sk_buff *skb)
1473{ 1519{
1520 skb->inner_mac_header = skb->mac_header;
1474 skb->inner_network_header = skb->network_header; 1521 skb->inner_network_header = skb->network_header;
1475 skb->inner_transport_header = skb->transport_header; 1522 skb->inner_transport_header = skb->transport_header;
1476} 1523}
@@ -1516,6 +1563,22 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb,
1516 skb->inner_network_header += offset; 1563 skb->inner_network_header += offset;
1517} 1564}
1518 1565
1566static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
1567{
1568 return skb->head + skb->inner_mac_header;
1569}
1570
1571static inline void skb_reset_inner_mac_header(struct sk_buff *skb)
1572{
1573 skb->inner_mac_header = skb->data - skb->head;
1574}
1575
1576static inline void skb_set_inner_mac_header(struct sk_buff *skb,
1577 const int offset)
1578{
1579 skb_reset_inner_mac_header(skb);
1580 skb->inner_mac_header += offset;
1581}
1519static inline bool skb_transport_header_was_set(const struct sk_buff *skb) 1582static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
1520{ 1583{
1521 return skb->transport_header != ~0U; 1584 return skb->transport_header != ~0U;
@@ -1609,6 +1672,21 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb,
1609 skb->inner_network_header = skb->data + offset; 1672 skb->inner_network_header = skb->data + offset;
1610} 1673}
1611 1674
1675static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
1676{
1677 return skb->inner_mac_header;
1678}
1679
1680static inline void skb_reset_inner_mac_header(struct sk_buff *skb)
1681{
1682 skb->inner_mac_header = skb->data;
1683}
1684
1685static inline void skb_set_inner_mac_header(struct sk_buff *skb,
1686 const int offset)
1687{
1688 skb->inner_mac_header = skb->data + offset;
1689}
1612static inline bool skb_transport_header_was_set(const struct sk_buff *skb) 1690static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
1613{ 1691{
1614 return skb->transport_header != NULL; 1692 return skb->transport_header != NULL;
@@ -1666,6 +1744,19 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1666} 1744}
1667#endif /* NET_SKBUFF_DATA_USES_OFFSET */ 1745#endif /* NET_SKBUFF_DATA_USES_OFFSET */
1668 1746
1747static inline void skb_probe_transport_header(struct sk_buff *skb,
1748 const int offset_hint)
1749{
1750 struct flow_keys keys;
1751
1752 if (skb_transport_header_was_set(skb))
1753 return;
1754 else if (skb_flow_dissect(skb, &keys))
1755 skb_set_transport_header(skb, keys.thoff);
1756 else
1757 skb_set_transport_header(skb, offset_hint);
1758}
1759
1669static inline void skb_mac_header_rebuild(struct sk_buff *skb) 1760static inline void skb_mac_header_rebuild(struct sk_buff *skb)
1670{ 1761{
1671 if (skb_mac_header_was_set(skb)) { 1762 if (skb_mac_header_was_set(skb)) {
@@ -2811,6 +2902,8 @@ static inline void skb_checksum_none_assert(const struct sk_buff *skb)
2811 2902
2812bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off); 2903bool skb_partial_csum_set(struct sk_buff *skb, u16 start, u16 off);
2813 2904
2905u32 __skb_get_poff(const struct sk_buff *skb);
2906
2814/** 2907/**
2815 * skb_head_is_locked - Determine if the skb->head is locked down 2908 * skb_head_is_locked - Determine if the skb->head is locked down
2816 * @skb: skb to check 2909 * @skb: skb to check
diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
index e8d702e0fd89..54f91d35e5fd 100644
--- a/include/linux/sock_diag.h
+++ b/include/linux/sock_diag.h
@@ -1,6 +1,7 @@
1#ifndef __SOCK_DIAG_H__ 1#ifndef __SOCK_DIAG_H__
2#define __SOCK_DIAG_H__ 2#define __SOCK_DIAG_H__
3 3
4#include <linux/user_namespace.h>
4#include <uapi/linux/sock_diag.h> 5#include <uapi/linux/sock_diag.h>
5 6
6struct sk_buff; 7struct sk_buff;
@@ -22,5 +23,7 @@ int sock_diag_check_cookie(void *sk, __u32 *cookie);
22void sock_diag_save_cookie(void *sk, __u32 *cookie); 23void sock_diag_save_cookie(void *sk, __u32 *cookie);
23 24
24int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr); 25int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr);
26int sock_diag_put_filterinfo(struct user_namespace *user_ns, struct sock *sk,
27 struct sk_buff *skb, int attrtype);
25 28
26#endif 29#endif
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 2b9f74b0ffea..428c37a1f95c 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -298,6 +298,7 @@ struct ucred {
298#define SOL_IUCV 277 298#define SOL_IUCV 277
299#define SOL_CAIF 278 299#define SOL_CAIF 278
300#define SOL_ALG 279 300#define SOL_ALG 279
301#define SOL_NFC 280
301 302
302/* IPX options */ 303/* IPX options */
303#define IPX_TYPE 1 304#define IPX_TYPE 1
diff --git a/include/linux/spi/at86rf230.h b/include/linux/spi/at86rf230.h
index b2b1afbb3202..aa327a8105ad 100644
--- a/include/linux/spi/at86rf230.h
+++ b/include/linux/spi/at86rf230.h
@@ -26,6 +26,20 @@ struct at86rf230_platform_data {
26 int rstn; 26 int rstn;
27 int slp_tr; 27 int slp_tr;
28 int dig2; 28 int dig2;
29
30 /* Setting the irq_type will configure the driver to request
31 * the platform irq trigger type according to the given value
32 * and configure the interrupt polarity of the device to the
33 * corresponding polarity.
34 *
35 * Allowed values are: IRQF_TRIGGER_RISING, IRQF_TRIGGER_FALLING,
36 * IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW
37 *
38 * Setting it to 0, the driver does not touch the trigger type
39 * configuration of the interrupt and sets the interrupt polarity
40 * of the device to high active (the default value).
41 */
42 int irq_type;
29}; 43};
30 44
31#endif 45#endif
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index 22958d68ecfe..c64999fd1660 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -26,9 +26,9 @@ struct ssb_sprom_core_pwr_info {
26 26
27struct ssb_sprom { 27struct ssb_sprom {
28 u8 revision; 28 u8 revision;
29 u8 il0mac[6]; /* MAC address for 802.11b/g */ 29 u8 il0mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11b/g */
30 u8 et0mac[6]; /* MAC address for Ethernet */ 30 u8 et0mac[6] __aligned(sizeof(u16)); /* MAC address for Ethernet */
31 u8 et1mac[6]; /* MAC address for 802.11a */ 31 u8 et1mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11a */
32 u8 et0phyaddr; /* MII address for enet0 */ 32 u8 et0phyaddr; /* MII address for enet0 */
33 u8 et1phyaddr; /* MII address for enet1 */ 33 u8 et1phyaddr; /* MII address for enet1 */
34 u8 et0mdcport; /* MDIO for enet0 */ 34 u8 et0mdcport; /* MDIO for enet0 */
@@ -340,13 +340,61 @@ enum ssb_bustype {
340#define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */ 340#define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */
341#define SSB_BOARDVENDOR_HP 0x0E11 /* HP */ 341#define SSB_BOARDVENDOR_HP 0x0E11 /* HP */
342/* board_type */ 342/* board_type */
343#define SSB_BOARD_BCM94301CB 0x0406
344#define SSB_BOARD_BCM94301MP 0x0407
345#define SSB_BOARD_BU4309 0x040A
346#define SSB_BOARD_BCM94309CB 0x040B
347#define SSB_BOARD_BCM4309MP 0x040C
348#define SSB_BOARD_BU4306 0x0416
343#define SSB_BOARD_BCM94306MP 0x0418 349#define SSB_BOARD_BCM94306MP 0x0418
344#define SSB_BOARD_BCM4309G 0x0421 350#define SSB_BOARD_BCM4309G 0x0421
345#define SSB_BOARD_BCM4306CB 0x0417 351#define SSB_BOARD_BCM4306CB 0x0417
346#define SSB_BOARD_BCM4309MP 0x040C 352#define SSB_BOARD_BCM94306PC 0x0425 /* pcmcia 3.3v 4306 card */
353#define SSB_BOARD_BCM94306CBSG 0x042B /* with SiGe PA */
354#define SSB_BOARD_PCSG94306 0x042D /* with SiGe PA */
355#define SSB_BOARD_BU4704SD 0x042E /* with sdram */
356#define SSB_BOARD_BCM94704AGR 0x042F /* dual 11a/11g Router */
357#define SSB_BOARD_BCM94308MP 0x0430 /* 11a-only minipci */
358#define SSB_BOARD_BU4318 0x0447
359#define SSB_BOARD_CB4318 0x0448
360#define SSB_BOARD_MPG4318 0x0449
347#define SSB_BOARD_MP4318 0x044A 361#define SSB_BOARD_MP4318 0x044A
348#define SSB_BOARD_BU4306 0x0416 362#define SSB_BOARD_SD4318 0x044B
349#define SSB_BOARD_BU4309 0x040A 363#define SSB_BOARD_BCM94306P 0x044C /* with SiGe */
364#define SSB_BOARD_BCM94303MP 0x044E
365#define SSB_BOARD_BCM94306MPM 0x0450
366#define SSB_BOARD_BCM94306MPL 0x0453
367#define SSB_BOARD_PC4303 0x0454 /* pcmcia */
368#define SSB_BOARD_BCM94306MPLNA 0x0457
369#define SSB_BOARD_BCM94306MPH 0x045B
370#define SSB_BOARD_BCM94306PCIV 0x045C
371#define SSB_BOARD_BCM94318MPGH 0x0463
372#define SSB_BOARD_BU4311 0x0464
373#define SSB_BOARD_BCM94311MC 0x0465
374#define SSB_BOARD_BCM94311MCAG 0x0466
375/* 4321 boards */
376#define SSB_BOARD_BU4321 0x046B
377#define SSB_BOARD_BU4321E 0x047C
378#define SSB_BOARD_MP4321 0x046C
379#define SSB_BOARD_CB2_4321 0x046D
380#define SSB_BOARD_CB2_4321_AG 0x0066
381#define SSB_BOARD_MC4321 0x046E
382/* 4325 boards */
383#define SSB_BOARD_BCM94325DEVBU 0x0490
384#define SSB_BOARD_BCM94325BGABU 0x0491
385#define SSB_BOARD_BCM94325SDGWB 0x0492
386#define SSB_BOARD_BCM94325SDGMDL 0x04AA
387#define SSB_BOARD_BCM94325SDGMDL2 0x04C6
388#define SSB_BOARD_BCM94325SDGMDL3 0x04C9
389#define SSB_BOARD_BCM94325SDABGWBA 0x04E1
390/* 4322 boards */
391#define SSB_BOARD_BCM94322MC 0x04A4
392#define SSB_BOARD_BCM94322USB 0x04A8 /* dualband */
393#define SSB_BOARD_BCM94322HM 0x04B0
394#define SSB_BOARD_BCM94322USB2D 0x04Bf /* single band discrete front end */
395/* 4312 boards */
396#define SSB_BOARD_BU4312 0x048A
397#define SSB_BOARD_BCM4312MCGSG 0x04B5
350/* chip_package */ 398/* chip_package */
351#define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */ 399#define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */
352#define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */ 400#define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */
diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h
index 6ecfa02ddbac..3a7256955b10 100644
--- a/include/linux/ssb/ssb_regs.h
+++ b/include/linux/ssb/ssb_regs.h
@@ -289,11 +289,11 @@
289#define SSB_SPROM4_ETHPHY_ET1A_SHIFT 5 289#define SSB_SPROM4_ETHPHY_ET1A_SHIFT 5
290#define SSB_SPROM4_ETHPHY_ET0M (1<<14) /* MDIO for enet0 */ 290#define SSB_SPROM4_ETHPHY_ET0M (1<<14) /* MDIO for enet0 */
291#define SSB_SPROM4_ETHPHY_ET1M (1<<15) /* MDIO for enet1 */ 291#define SSB_SPROM4_ETHPHY_ET1M (1<<15) /* MDIO for enet1 */
292#define SSB_SPROM4_ANTAVAIL 0x005D /* Antenna available bitfields */ 292#define SSB_SPROM4_ANTAVAIL 0x005C /* Antenna available bitfields */
293#define SSB_SPROM4_ANTAVAIL_A 0x00FF /* A-PHY bitfield */ 293#define SSB_SPROM4_ANTAVAIL_BG 0x00FF /* B-PHY and G-PHY bitfield */
294#define SSB_SPROM4_ANTAVAIL_A_SHIFT 0 294#define SSB_SPROM4_ANTAVAIL_BG_SHIFT 0
295#define SSB_SPROM4_ANTAVAIL_BG 0xFF00 /* B-PHY and G-PHY bitfield */ 295#define SSB_SPROM4_ANTAVAIL_A 0xFF00 /* A-PHY bitfield */
296#define SSB_SPROM4_ANTAVAIL_BG_SHIFT 8 296#define SSB_SPROM4_ANTAVAIL_A_SHIFT 8
297#define SSB_SPROM4_AGAIN01 0x005E /* Antenna Gain (in dBm Q5.2) */ 297#define SSB_SPROM4_AGAIN01 0x005E /* Antenna Gain (in dBm Q5.2) */
298#define SSB_SPROM4_AGAIN0 0x00FF /* Antenna 0 */ 298#define SSB_SPROM4_AGAIN0 0x00FF /* Antenna 0 */
299#define SSB_SPROM4_AGAIN0_SHIFT 0 299#define SSB_SPROM4_AGAIN0_SHIFT 0
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index f28408c07dc2..5adbc33d1ab3 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -90,9 +90,6 @@ struct tcp_options_received {
90 sack_ok : 4, /* SACK seen on SYN packet */ 90 sack_ok : 4, /* SACK seen on SYN packet */
91 snd_wscale : 4, /* Window scaling received from sender */ 91 snd_wscale : 4, /* Window scaling received from sender */
92 rcv_wscale : 4; /* Window scaling to send to receiver */ 92 rcv_wscale : 4; /* Window scaling to send to receiver */
93 u8 cookie_plus:6, /* bytes in authenticator/cookie option */
94 cookie_out_never:1,
95 cookie_in_always:1;
96 u8 num_sacks; /* Number of SACK blocks */ 93 u8 num_sacks; /* Number of SACK blocks */
97 u16 user_mss; /* mss requested by user in ioctl */ 94 u16 user_mss; /* mss requested by user in ioctl */
98 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ 95 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
@@ -102,7 +99,6 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt)
102{ 99{
103 rx_opt->tstamp_ok = rx_opt->sack_ok = 0; 100 rx_opt->tstamp_ok = rx_opt->sack_ok = 0;
104 rx_opt->wscale_ok = rx_opt->snd_wscale = 0; 101 rx_opt->wscale_ok = rx_opt->snd_wscale = 0;
105 rx_opt->cookie_plus = 0;
106} 102}
107 103
108/* This is the max number of SACKS that we'll generate and process. It's safe 104/* This is the max number of SACKS that we'll generate and process. It's safe
@@ -191,20 +187,19 @@ struct tcp_sock {
191 u32 window_clamp; /* Maximal window to advertise */ 187 u32 window_clamp; /* Maximal window to advertise */
192 u32 rcv_ssthresh; /* Current window clamp */ 188 u32 rcv_ssthresh; /* Current window clamp */
193 189
194 u32 frto_highmark; /* snd_nxt when RTO occurred */
195 u16 advmss; /* Advertised MSS */ 190 u16 advmss; /* Advertised MSS */
196 u8 frto_counter; /* Number of new acks after RTO */ 191 u8 unused;
197 u8 nonagle : 4,/* Disable Nagle algorithm? */ 192 u8 nonagle : 4,/* Disable Nagle algorithm? */
198 thin_lto : 1,/* Use linear timeouts for thin streams */ 193 thin_lto : 1,/* Use linear timeouts for thin streams */
199 thin_dupack : 1,/* Fast retransmit on first dupack */ 194 thin_dupack : 1,/* Fast retransmit on first dupack */
200 repair : 1, 195 repair : 1,
201 unused : 1; 196 frto : 1;/* F-RTO (RFC5682) activated in CA_Loss */
202 u8 repair_queue; 197 u8 repair_queue;
203 u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */ 198 u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */
204 early_retrans_delayed:1, /* Delayed ER timer installed */
205 syn_data:1, /* SYN includes data */ 199 syn_data:1, /* SYN includes data */
206 syn_fastopen:1, /* SYN includes Fast Open option */ 200 syn_fastopen:1, /* SYN includes Fast Open option */
207 syn_data_acked:1;/* data in SYN is acked by SYN-ACK */ 201 syn_data_acked:1;/* data in SYN is acked by SYN-ACK */
202 u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */
208 203
209/* RTT measurement */ 204/* RTT measurement */
210 u32 srtt; /* smoothed round trip time << 3 */ 205 u32 srtt; /* smoothed round trip time << 3 */
@@ -320,12 +315,6 @@ struct tcp_sock {
320 struct tcp_md5sig_info __rcu *md5sig_info; 315 struct tcp_md5sig_info __rcu *md5sig_info;
321#endif 316#endif
322 317
323 /* When the cookie options are generated and exchanged, then this
324 * object holds a reference to them (cookie_values->kref). Also
325 * contains related tcp_cookie_transactions fields.
326 */
327 struct tcp_cookie_values *cookie_values;
328
329/* TCP fastopen related information */ 318/* TCP fastopen related information */
330 struct tcp_fastopen_request *fastopen_req; 319 struct tcp_fastopen_request *fastopen_req;
331 /* fastopen_rsk points to request_sock that resulted in this big 320 /* fastopen_rsk points to request_sock that resulted in this big
@@ -361,10 +350,6 @@ struct tcp_timewait_sock {
361#ifdef CONFIG_TCP_MD5SIG 350#ifdef CONFIG_TCP_MD5SIG
362 struct tcp_md5sig_key *tw_md5_key; 351 struct tcp_md5sig_key *tw_md5_key;
363#endif 352#endif
364 /* Few sockets in timewait have cookies; in that case, then this
365 * object holds a reference to them (tw_cookie_values->kref).
366 */
367 struct tcp_cookie_values *tw_cookie_values;
368}; 353};
369 354
370static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk) 355static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 0e5ac93bab10..da46327fca17 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -72,6 +72,7 @@ struct usbnet {
72# define EVENT_DEVICE_REPORT_IDLE 8 72# define EVENT_DEVICE_REPORT_IDLE 8
73# define EVENT_NO_RUNTIME_PM 9 73# define EVENT_NO_RUNTIME_PM 9
74# define EVENT_RX_KILL 10 74# define EVENT_RX_KILL 10
75# define EVENT_LINK_CHANGE 11
75}; 76};
76 77
77static inline struct usb_driver *driver_of(struct usb_interface *intf) 78static inline struct usb_driver *driver_of(struct usb_interface *intf)
@@ -245,5 +246,6 @@ extern void usbnet_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
245extern int usbnet_nway_reset(struct net_device *net); 246extern int usbnet_nway_reset(struct net_device *net);
246 247
247extern int usbnet_manage_power(struct usbnet *, int); 248extern int usbnet_manage_power(struct usbnet *, int);
249extern void usbnet_link_change(struct usbnet *, bool, bool);
248 250
249#endif /* __LINUX_USB_USBNET_H */ 251#endif /* __LINUX_USB_USBNET_H */
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index ff6714e6d0f5..2d7a5e045908 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -58,12 +58,6 @@ void *virtqueue_detach_unused_buf(struct virtqueue *vq);
58 58
59unsigned int virtqueue_get_vring_size(struct virtqueue *vq); 59unsigned int virtqueue_get_vring_size(struct virtqueue *vq);
60 60
61/* FIXME: Obsolete accessor, but required for virtio_net merge. */
62static inline unsigned int virtqueue_get_queue_index(struct virtqueue *vq)
63{
64 return vq->index;
65}
66
67/** 61/**
68 * virtio_device - representation of a device using virtio 62 * virtio_device - representation of a device using virtio
69 * @index: unique position on the virtio bus 63 * @index: unique position on the virtio bus
diff --git a/include/linux/vm_sockets.h b/include/linux/vm_sockets.h
new file mode 100644
index 000000000000..0805eecba8f7
--- /dev/null
+++ b/include/linux/vm_sockets.h
@@ -0,0 +1,23 @@
1/*
2 * VMware vSockets Driver
3 *
4 * Copyright (C) 2007-2013 VMware, Inc. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation version 2 and no later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _VM_SOCKETS_H
17#define _VM_SOCKETS_H
18
19#include <uapi/linux/vm_sockets.h>
20
21int vm_sockets_get_local_cid(void);
22
23#endif /* _VM_SOCKETS_H */