aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/etherdevice.h20
-rw-r--r--include/linux/filter.h3
-rw-r--r--include/linux/hdlc/Kbuild1
-rw-r--r--include/linux/hdlc/ioctl.h81
-rw-r--r--include/linux/ktime.h19
-rw-r--r--include/linux/netdevice.h10
-rw-r--r--include/linux/platform_data/cpsw.h4
-rw-r--r--include/linux/platform_data/macb.h1
-rw-r--r--include/linux/rtnetlink.h3
-rw-r--r--include/linux/skbuff.h7
-rw-r--r--include/linux/timecompare.h125
-rw-r--r--include/linux/usb/cdc_ncm.h134
-rw-r--r--include/linux/usb/usbnet.h10
13 files changed, 209 insertions, 209 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index b006ba0a9f42..243eea1e33d8 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -51,6 +51,26 @@ extern struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
51#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1) 51#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
52#define alloc_etherdev_mq(sizeof_priv, count) alloc_etherdev_mqs(sizeof_priv, count, count) 52#define alloc_etherdev_mq(sizeof_priv, count) alloc_etherdev_mqs(sizeof_priv, count, count)
53 53
54/* Reserved Ethernet Addresses per IEEE 802.1Q */
55static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
56{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
57
58/**
59 * is_link_local_ether_addr - Determine if given Ethernet address is link-local
60 * @addr: Pointer to a six-byte array containing the Ethernet address
61 *
62 * Return true if address is link local reserved addr (01:80:c2:00:00:0X) per
63 * IEEE 802.1Q 8.6.3 Frame filtering.
64 */
65static inline bool is_link_local_ether_addr(const u8 *addr)
66{
67 __be16 *a = (__be16 *)addr;
68 static const __be16 *b = (const __be16 *)eth_reserved_addr_base;
69 static const __be16 m = cpu_to_be16(0xfff0);
70
71 return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | ((a[2] ^ b[2]) & m)) == 0;
72}
73
54/** 74/**
55 * is_zero_ether_addr - Determine if give Ethernet address is all zeros. 75 * is_zero_ether_addr - Determine if give Ethernet address is all zeros.
56 * @addr: Pointer to a six-byte array containing the Ethernet address 76 * @addr: Pointer to a six-byte array containing the Ethernet address
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 24d251f3bab0..c45eabc135e1 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -45,6 +45,7 @@ extern void sk_unattached_filter_destroy(struct sk_filter *fp);
45extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); 45extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
46extern int sk_detach_filter(struct sock *sk); 46extern int sk_detach_filter(struct sock *sk);
47extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen); 47extern 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);
48 49
49#ifdef CONFIG_BPF_JIT 50#ifdef CONFIG_BPF_JIT
50extern void bpf_jit_compile(struct sk_filter *fp); 51extern void bpf_jit_compile(struct sk_filter *fp);
@@ -123,6 +124,8 @@ enum {
123 BPF_S_ANC_CPU, 124 BPF_S_ANC_CPU,
124 BPF_S_ANC_ALU_XOR_X, 125 BPF_S_ANC_ALU_XOR_X,
125 BPF_S_ANC_SECCOMP_LD_W, 126 BPF_S_ANC_SECCOMP_LD_W,
127 BPF_S_ANC_VLAN_TAG,
128 BPF_S_ANC_VLAN_TAG_PRESENT,
126}; 129};
127 130
128#endif /* __LINUX_FILTER_H__ */ 131#endif /* __LINUX_FILTER_H__ */
diff --git a/include/linux/hdlc/Kbuild b/include/linux/hdlc/Kbuild
index 1fb26448faa9..e69de29bb2d1 100644
--- a/include/linux/hdlc/Kbuild
+++ b/include/linux/hdlc/Kbuild
@@ -1 +0,0 @@
1header-y += ioctl.h
diff --git a/include/linux/hdlc/ioctl.h b/include/linux/hdlc/ioctl.h
deleted file mode 100644
index 583972364357..000000000000
--- a/include/linux/hdlc/ioctl.h
+++ /dev/null
@@ -1,81 +0,0 @@
1#ifndef __HDLC_IOCTL_H__
2#define __HDLC_IOCTL_H__
3
4
5#define GENERIC_HDLC_VERSION 4 /* For synchronization with sethdlc utility */
6
7#define CLOCK_DEFAULT 0 /* Default setting */
8#define CLOCK_EXT 1 /* External TX and RX clock - DTE */
9#define CLOCK_INT 2 /* Internal TX and RX clock - DCE */
10#define CLOCK_TXINT 3 /* Internal TX and external RX clock */
11#define CLOCK_TXFROMRX 4 /* TX clock derived from external RX clock */
12
13
14#define ENCODING_DEFAULT 0 /* Default setting */
15#define ENCODING_NRZ 1
16#define ENCODING_NRZI 2
17#define ENCODING_FM_MARK 3
18#define ENCODING_FM_SPACE 4
19#define ENCODING_MANCHESTER 5
20
21
22#define PARITY_DEFAULT 0 /* Default setting */
23#define PARITY_NONE 1 /* No parity */
24#define PARITY_CRC16_PR0 2 /* CRC16, initial value 0x0000 */
25#define PARITY_CRC16_PR1 3 /* CRC16, initial value 0xFFFF */
26#define PARITY_CRC16_PR0_CCITT 4 /* CRC16, initial 0x0000, ITU-T version */
27#define PARITY_CRC16_PR1_CCITT 5 /* CRC16, initial 0xFFFF, ITU-T version */
28#define PARITY_CRC32_PR0_CCITT 6 /* CRC32, initial value 0x00000000 */
29#define PARITY_CRC32_PR1_CCITT 7 /* CRC32, initial value 0xFFFFFFFF */
30
31#define LMI_DEFAULT 0 /* Default setting */
32#define LMI_NONE 1 /* No LMI, all PVCs are static */
33#define LMI_ANSI 2 /* ANSI Annex D */
34#define LMI_CCITT 3 /* ITU-T Annex A */
35#define LMI_CISCO 4 /* The "original" LMI, aka Gang of Four */
36
37typedef struct {
38 unsigned int clock_rate; /* bits per second */
39 unsigned int clock_type; /* internal, external, TX-internal etc. */
40 unsigned short loopback;
41} sync_serial_settings; /* V.35, V.24, X.21 */
42
43typedef struct {
44 unsigned int clock_rate; /* bits per second */
45 unsigned int clock_type; /* internal, external, TX-internal etc. */
46 unsigned short loopback;
47 unsigned int slot_map;
48} te1_settings; /* T1, E1 */
49
50typedef struct {
51 unsigned short encoding;
52 unsigned short parity;
53} raw_hdlc_proto;
54
55typedef struct {
56 unsigned int t391;
57 unsigned int t392;
58 unsigned int n391;
59 unsigned int n392;
60 unsigned int n393;
61 unsigned short lmi;
62 unsigned short dce; /* 1 for DCE (network side) operation */
63} fr_proto;
64
65typedef struct {
66 unsigned int dlci;
67} fr_proto_pvc; /* for creating/deleting FR PVCs */
68
69typedef struct {
70 unsigned int dlci;
71 char master[IFNAMSIZ]; /* Name of master FRAD device */
72}fr_proto_pvc_info; /* for returning PVC information only */
73
74typedef struct {
75 unsigned int interval;
76 unsigned int timeout;
77} cisco_proto;
78
79/* PPP doesn't need any info now - supply length = 0 to ioctl */
80
81#endif /* __HDLC_IOCTL_H__ */
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 06177ba10a16..e83512f63df5 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -282,6 +282,25 @@ static inline int ktime_equal(const ktime_t cmp1, const ktime_t cmp2)
282 return cmp1.tv64 == cmp2.tv64; 282 return cmp1.tv64 == cmp2.tv64;
283} 283}
284 284
285/**
286 * ktime_compare - Compares two ktime_t variables for less, greater or equal
287 * @cmp1: comparable1
288 * @cmp2: comparable2
289 *
290 * Returns ...
291 * cmp1 < cmp2: return <0
292 * cmp1 == cmp2: return 0
293 * cmp1 > cmp2: return >0
294 */
295static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
296{
297 if (cmp1.tv64 < cmp2.tv64)
298 return -1;
299 if (cmp1.tv64 > cmp2.tv64)
300 return 1;
301 return 0;
302}
303
285static inline s64 ktime_to_us(const ktime_t kt) 304static inline s64 ktime_to_us(const ktime_t kt)
286{ 305{
287 struct timeval tv = ktime_to_timeval(kt); 306 struct timeval tv = ktime_to_timeval(kt);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f8eda0276f03..7bf867c97043 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -887,6 +887,10 @@ struct netdev_fcoe_hbainfo {
887 * struct net_device *dev, int idx) 887 * struct net_device *dev, int idx)
888 * Used to add FDB entries to dump requests. Implementers should add 888 * Used to add FDB entries to dump requests. Implementers should add
889 * entries to skb and update idx with the number of entries. 889 * entries to skb and update idx with the number of entries.
890 *
891 * int (*ndo_bridge_setlink)(struct net_device *dev, struct nlmsghdr *nlh)
892 * int (*ndo_bridge_getlink)(struct sk_buff *skb, u32 pid, u32 seq,
893 * struct net_device *dev)
890 */ 894 */
891struct net_device_ops { 895struct net_device_ops {
892 int (*ndo_init)(struct net_device *dev); 896 int (*ndo_init)(struct net_device *dev);
@@ -998,6 +1002,12 @@ struct net_device_ops {
998 struct netlink_callback *cb, 1002 struct netlink_callback *cb,
999 struct net_device *dev, 1003 struct net_device *dev,
1000 int idx); 1004 int idx);
1005
1006 int (*ndo_bridge_setlink)(struct net_device *dev,
1007 struct nlmsghdr *nlh);
1008 int (*ndo_bridge_getlink)(struct sk_buff *skb,
1009 u32 pid, u32 seq,
1010 struct net_device *dev);
1001}; 1011};
1002 1012
1003/* 1013/*
diff --git a/include/linux/platform_data/cpsw.h b/include/linux/platform_data/cpsw.h
index c4e23d029498..b5c16c3df458 100644
--- a/include/linux/platform_data/cpsw.h
+++ b/include/linux/platform_data/cpsw.h
@@ -33,6 +33,9 @@ struct cpsw_platform_data {
33 33
34 u32 slaves; /* number of slave cpgmac ports */ 34 u32 slaves; /* number of slave cpgmac ports */
35 struct cpsw_slave_data *slave_data; 35 struct cpsw_slave_data *slave_data;
36 u32 cpts_active_slave; /* time stamping slave */
37 u32 cpts_clock_mult; /* convert input clock ticks to nanoseconds */
38 u32 cpts_clock_shift; /* convert input clock ticks to nanoseconds */
36 39
37 u32 ale_reg_ofs; /* address lookup engine reg offset */ 40 u32 ale_reg_ofs; /* address lookup engine reg offset */
38 u32 ale_entries; /* ale table size */ 41 u32 ale_entries; /* ale table size */
@@ -41,6 +44,7 @@ struct cpsw_platform_data {
41 u32 host_port_num; /* The port number for the host port */ 44 u32 host_port_num; /* The port number for the host port */
42 45
43 u32 hw_stats_reg_ofs; /* cpsw hardware statistics counters */ 46 u32 hw_stats_reg_ofs; /* cpsw hardware statistics counters */
47 u32 cpts_reg_ofs; /* cpts registers */
44 48
45 u32 bd_ram_ofs; /* embedded buffer descriptor RAM offset*/ 49 u32 bd_ram_ofs; /* embedded buffer descriptor RAM offset*/
46 u32 bd_ram_size; /*buffer descriptor ram size */ 50 u32 bd_ram_size; /*buffer descriptor ram size */
diff --git a/include/linux/platform_data/macb.h b/include/linux/platform_data/macb.h
index b081c7245ec8..044a124bfbbc 100644
--- a/include/linux/platform_data/macb.h
+++ b/include/linux/platform_data/macb.h
@@ -12,6 +12,7 @@ struct macb_platform_data {
12 u32 phy_mask; 12 u32 phy_mask;
13 int phy_irq_pin; /* PHY IRQ */ 13 int phy_irq_pin; /* PHY IRQ */
14 u8 is_rmii; /* using RMII interface? */ 14 u8 is_rmii; /* using RMII interface? */
15 u8 rev_eth_addr; /* reverse Ethernet address byte order */
15}; 16};
16 17
17#endif /* __MACB_PDATA_H__ */ 18#endif /* __MACB_PDATA_H__ */
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 7002bbfd5d4a..489dd7bb28ec 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -69,4 +69,7 @@ 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);
72
73extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
74 struct net_device *dev, u16 mode);
72#endif /* __LINUX_RTNETLINK_H */ 75#endif /* __LINUX_RTNETLINK_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6a2c34e6d962..f2af494330ab 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -235,11 +235,13 @@ enum {
235/* 235/*
236 * The callback notifies userspace to release buffers when skb DMA is done in 236 * The callback notifies userspace to release buffers when skb DMA is done in
237 * lower device, the skb last reference should be 0 when calling this. 237 * lower device, the skb last reference should be 0 when calling this.
238 * The zerocopy_success argument is true if zero copy transmit occurred,
239 * false on data copy or out of memory error caused by data copy attempt.
238 * The ctx field is used to track device context. 240 * The ctx field is used to track device context.
239 * The desc field is used to track userspace buffer index. 241 * The desc field is used to track userspace buffer index.
240 */ 242 */
241struct ubuf_info { 243struct ubuf_info {
242 void (*callback)(struct ubuf_info *); 244 void (*callback)(struct ubuf_info *, bool zerocopy_success);
243 void *ctx; 245 void *ctx;
244 unsigned long desc; 246 unsigned long desc;
245}; 247};
@@ -566,6 +568,7 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb)
566} 568}
567 569
568extern void kfree_skb(struct sk_buff *skb); 570extern void kfree_skb(struct sk_buff *skb);
571extern void skb_tx_error(struct sk_buff *skb);
569extern void consume_skb(struct sk_buff *skb); 572extern void consume_skb(struct sk_buff *skb);
570extern void __kfree_skb(struct sk_buff *skb); 573extern void __kfree_skb(struct sk_buff *skb);
571extern struct kmem_cache *skbuff_head_cache; 574extern struct kmem_cache *skbuff_head_cache;
@@ -643,7 +646,7 @@ extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
643extern void __skb_get_rxhash(struct sk_buff *skb); 646extern void __skb_get_rxhash(struct sk_buff *skb);
644static inline __u32 skb_get_rxhash(struct sk_buff *skb) 647static inline __u32 skb_get_rxhash(struct sk_buff *skb)
645{ 648{
646 if (!skb->rxhash) 649 if (!skb->l4_rxhash)
647 __skb_get_rxhash(skb); 650 __skb_get_rxhash(skb);
648 651
649 return skb->rxhash; 652 return skb->rxhash;
diff --git a/include/linux/timecompare.h b/include/linux/timecompare.h
deleted file mode 100644
index 546e2234e4b3..000000000000
--- a/include/linux/timecompare.h
+++ /dev/null
@@ -1,125 +0,0 @@
1/*
2 * Utility code which helps transforming between two different time
3 * bases, called "source" and "target" time in this code.
4 *
5 * Source time has to be provided via the timecounter API while target
6 * time is accessed via a function callback whose prototype
7 * intentionally matches ktime_get() and ktime_get_real(). These
8 * interfaces where chosen like this so that the code serves its
9 * initial purpose without additional glue code.
10 *
11 * This purpose is synchronizing a hardware clock in a NIC with system
12 * time, in order to implement the Precision Time Protocol (PTP,
13 * IEEE1588) with more accurate hardware assisted time stamping. In
14 * that context only synchronization against system time (=
15 * ktime_get_real()) is currently needed. But this utility code might
16 * become useful in other situations, which is why it was written as
17 * general purpose utility code.
18 *
19 * The source timecounter is assumed to return monotonically
20 * increasing time (but this code does its best to compensate if that
21 * is not the case) whereas target time may jump.
22 *
23 * The target time corresponding to a source time is determined by
24 * reading target time, reading source time, reading target time
25 * again, then assuming that average target time corresponds to source
26 * time. In other words, the assumption is that reading the source
27 * time is slow and involves equal time for sending the request and
28 * receiving the reply, whereas reading target time is assumed to be
29 * fast.
30 *
31 * Copyright (C) 2009 Intel Corporation.
32 * Author: Patrick Ohly <patrick.ohly@intel.com>
33 *
34 * This program is free software; you can redistribute it and/or modify it
35 * under the terms and conditions of the GNU General Public License,
36 * version 2, as published by the Free Software Foundation.
37 *
38 * This program is distributed in the hope it will be useful, but WITHOUT
39 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
40 * FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for
41 * more details.
42 *
43 * You should have received a copy of the GNU General Public License along with
44 * this program; if not, write to the Free Software Foundation, Inc.,
45 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
46 */
47#ifndef _LINUX_TIMECOMPARE_H
48#define _LINUX_TIMECOMPARE_H
49
50#include <linux/clocksource.h>
51#include <linux/ktime.h>
52
53/**
54 * struct timecompare - stores state and configuration for the two clocks
55 *
56 * Initialize to zero, then set source/target/num_samples.
57 *
58 * Transformation between source time and target time is done with:
59 * target_time = source_time + offset +
60 * (source_time - last_update) * skew /
61 * TIMECOMPARE_SKEW_RESOLUTION
62 *
63 * @source: used to get source time stamps via timecounter_read()
64 * @target: function returning target time (for example, ktime_get
65 * for monotonic time, or ktime_get_real for wall clock)
66 * @num_samples: number of times that source time and target time are to
67 * be compared when determining their offset
68 * @offset: (target time - source time) at the time of the last update
69 * @skew: average (target time - source time) / delta source time *
70 * TIMECOMPARE_SKEW_RESOLUTION
71 * @last_update: last source time stamp when time offset was measured
72 */
73struct timecompare {
74 struct timecounter *source;
75 ktime_t (*target)(void);
76 int num_samples;
77
78 s64 offset;
79 s64 skew;
80 u64 last_update;
81};
82
83/**
84 * timecompare_transform - transform source time stamp into target time base
85 * @sync: context for time sync
86 * @source_tstamp: the result of timecounter_read() or
87 * timecounter_cyc2time()
88 */
89extern ktime_t timecompare_transform(struct timecompare *sync,
90 u64 source_tstamp);
91
92/**
93 * timecompare_offset - measure current (target time - source time) offset
94 * @sync: context for time sync
95 * @offset: average offset during sample period returned here
96 * @source_tstamp: average source time during sample period returned here
97 *
98 * Returns number of samples used. Might be zero (= no result) in the
99 * unlikely case that target time was monotonically decreasing for all
100 * samples (= broken).
101 */
102extern int timecompare_offset(struct timecompare *sync,
103 s64 *offset,
104 u64 *source_tstamp);
105
106extern void __timecompare_update(struct timecompare *sync,
107 u64 source_tstamp);
108
109/**
110 * timecompare_update - update offset and skew by measuring current offset
111 * @sync: context for time sync
112 * @source_tstamp: the result of timecounter_read() or
113 * timecounter_cyc2time(), pass zero to force update
114 *
115 * Updates are only done at most once per second.
116 */
117static inline void timecompare_update(struct timecompare *sync,
118 u64 source_tstamp)
119{
120 if (!source_tstamp ||
121 (s64)(source_tstamp - sync->last_update) >= NSEC_PER_SEC)
122 __timecompare_update(sync, source_tstamp);
123}
124
125#endif /* _LINUX_TIMECOMPARE_H */
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
new file mode 100644
index 000000000000..3b8f9d4fc3fe
--- /dev/null
+++ b/include/linux/usb/cdc_ncm.h
@@ -0,0 +1,134 @@
1/*
2 * Copyright (C) ST-Ericsson 2010-2012
3 * Contact: Alexey Orishko <alexey.orishko@stericsson.com>
4 * Original author: Hans Petter Selasky <hans.petter.selasky@stericsson.com>
5 *
6 * USB Host Driver for Network Control Model (NCM)
7 * http://www.usb.org/developers/devclass_docs/NCM10.zip
8 *
9 * The NCM encoding, decoding and initialization logic
10 * derives from FreeBSD 8.x. if_cdce.c and if_cdcereg.h
11 *
12 * This software is available to you under a choice of one of two
13 * licenses. You may choose this file to be licensed under the terms
14 * of the GNU General Public License (GPL) Version 2 or the 2-clause
15 * BSD license listed below:
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39#define CDC_NCM_COMM_ALTSETTING_NCM 0
40#define CDC_NCM_COMM_ALTSETTING_MBIM 1
41
42#define CDC_NCM_DATA_ALTSETTING_NCM 1
43#define CDC_NCM_DATA_ALTSETTING_MBIM 2
44
45/* CDC NCM subclass 3.2.1 */
46#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10
47
48/* Maximum NTB length */
49#define CDC_NCM_NTB_MAX_SIZE_TX 32768 /* bytes */
50#define CDC_NCM_NTB_MAX_SIZE_RX 32768 /* bytes */
51
52/* Minimum value for MaxDatagramSize, ch. 6.2.9 */
53#define CDC_NCM_MIN_DATAGRAM_SIZE 1514 /* bytes */
54
55/* Minimum value for MaxDatagramSize, ch. 8.1.3 */
56#define CDC_MBIM_MIN_DATAGRAM_SIZE 2048 /* bytes */
57
58#define CDC_NCM_MIN_TX_PKT 512 /* bytes */
59
60/* Default value for MaxDatagramSize */
61#define CDC_NCM_MAX_DATAGRAM_SIZE 8192 /* bytes */
62
63/*
64 * Maximum amount of datagrams in NCM Datagram Pointer Table, not counting
65 * the last NULL entry.
66 */
67#define CDC_NCM_DPT_DATAGRAMS_MAX 40
68
69/* Restart the timer, if amount of datagrams is less than given value */
70#define CDC_NCM_RESTART_TIMER_DATAGRAM_CNT 3
71#define CDC_NCM_TIMER_PENDING_CNT 2
72#define CDC_NCM_TIMER_INTERVAL (400UL * NSEC_PER_USEC)
73
74/* The following macro defines the minimum header space */
75#define CDC_NCM_MIN_HDR_SIZE \
76 (sizeof(struct usb_cdc_ncm_nth16) + sizeof(struct usb_cdc_ncm_ndp16) + \
77 (CDC_NCM_DPT_DATAGRAMS_MAX + 1) * sizeof(struct usb_cdc_ncm_dpe16))
78
79#define CDC_NCM_NDP_SIZE \
80 (sizeof(struct usb_cdc_ncm_ndp16) + \
81 (CDC_NCM_DPT_DATAGRAMS_MAX + 1) * sizeof(struct usb_cdc_ncm_dpe16))
82
83#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
84 (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
85#define cdc_ncm_data_intf_is_mbim(x) ((x)->desc.bInterfaceProtocol == USB_CDC_MBIM_PROTO_NTB)
86
87struct cdc_ncm_ctx {
88 struct usb_cdc_ncm_ntb_parameters ncm_parm;
89 struct hrtimer tx_timer;
90 struct tasklet_struct bh;
91
92 const struct usb_cdc_ncm_desc *func_desc;
93 const struct usb_cdc_mbim_desc *mbim_desc;
94 const struct usb_cdc_header_desc *header_desc;
95 const struct usb_cdc_union_desc *union_desc;
96 const struct usb_cdc_ether_desc *ether_desc;
97
98 struct net_device *netdev;
99 struct usb_device *udev;
100 struct usb_host_endpoint *in_ep;
101 struct usb_host_endpoint *out_ep;
102 struct usb_host_endpoint *status_ep;
103 struct usb_interface *intf;
104 struct usb_interface *control;
105 struct usb_interface *data;
106
107 struct sk_buff *tx_curr_skb;
108 struct sk_buff *tx_rem_skb;
109 __le32 tx_rem_sign;
110
111 spinlock_t mtx;
112 atomic_t stop;
113
114 u32 tx_timer_pending;
115 u32 tx_curr_frame_num;
116 u32 rx_speed;
117 u32 tx_speed;
118 u32 rx_max;
119 u32 tx_max;
120 u32 max_datagram_size;
121 u16 tx_max_datagrams;
122 u16 tx_remainder;
123 u16 tx_modulus;
124 u16 tx_ndp_modulus;
125 u16 tx_seq;
126 u16 rx_seq;
127 u16 connected;
128};
129
130extern int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting);
131extern void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf);
132extern struct sk_buff *cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb, __le32 sign);
133extern int cdc_ncm_rx_verify_nth16(struct cdc_ncm_ctx *ctx, struct sk_buff *skb_in);
134extern int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset);
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index ddbbb7de894b..9bbeabf66c54 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -163,6 +163,16 @@ extern int usbnet_resume(struct usb_interface *);
163extern void usbnet_disconnect(struct usb_interface *); 163extern void usbnet_disconnect(struct usb_interface *);
164extern void usbnet_device_suggests_idle(struct usbnet *dev); 164extern void usbnet_device_suggests_idle(struct usbnet *dev);
165 165
166extern int usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
167 u16 value, u16 index, void *data, u16 size);
168extern int usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype,
169 u16 value, u16 index, const void *data, u16 size);
170extern int usbnet_read_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
171 u16 value, u16 index, void *data, u16 size);
172extern int usbnet_write_cmd_nopm(struct usbnet *dev, u8 cmd, u8 reqtype,
173 u16 value, u16 index, const void *data, u16 size);
174extern int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
175 u16 value, u16 index, const void *data, u16 size);
166 176
167/* Drivers that reuse some of the standard USB CDC infrastructure 177/* Drivers that reuse some of the standard USB CDC infrastructure
168 * (notably, using multiple interfaces according to the CDC 178 * (notably, using multiple interfaces according to the CDC