diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/ABI/testing/sysfs-class-net-mesh | 8 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/net/can/atmel-can.txt | 14 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/net/cpsw.txt | 16 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/net/dsa/dsa.txt | 91 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/net/marvell-orion-mdio.txt | 3 | ||||
-rw-r--r-- | Documentation/networking/ip-sysctl.txt | 53 | ||||
-rw-r--r-- | Documentation/networking/packet_mmap.txt | 327 | ||||
-rw-r--r-- | Documentation/networking/stmmac.txt | 33 |
8 files changed, 498 insertions, 47 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-net-mesh b/Documentation/ABI/testing/sysfs-class-net-mesh index bc41da61608d..bdcd8b4e38f2 100644 --- a/Documentation/ABI/testing/sysfs-class-net-mesh +++ b/Documentation/ABI/testing/sysfs-class-net-mesh | |||
@@ -67,6 +67,14 @@ Description: | |||
67 | Defines the penalty which will be applied to an | 67 | Defines the penalty which will be applied to an |
68 | originator message's tq-field on every hop. | 68 | originator message's tq-field on every hop. |
69 | 69 | ||
70 | What: /sys/class/net/<mesh_iface>/mesh/network_coding | ||
71 | Date: Nov 2012 | ||
72 | Contact: Martin Hundeboll <martin@hundeboll.net> | ||
73 | Description: | ||
74 | Controls whether Network Coding (using some magic | ||
75 | to send fewer wifi packets but still the same | ||
76 | content) is enabled or not. | ||
77 | |||
70 | What: /sys/class/net/<mesh_iface>/mesh/orig_interval | 78 | What: /sys/class/net/<mesh_iface>/mesh/orig_interval |
71 | Date: May 2010 | 79 | Date: May 2010 |
72 | Contact: Marek Lindner <lindner_marek@yahoo.de> | 80 | Contact: Marek Lindner <lindner_marek@yahoo.de> |
diff --git a/Documentation/devicetree/bindings/net/can/atmel-can.txt b/Documentation/devicetree/bindings/net/can/atmel-can.txt new file mode 100644 index 000000000000..72cf0c5daff4 --- /dev/null +++ b/Documentation/devicetree/bindings/net/can/atmel-can.txt | |||
@@ -0,0 +1,14 @@ | |||
1 | * AT91 CAN * | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: Should be "atmel,at91sam9263-can" or "atmel,at91sam9x5-can" | ||
5 | - reg: Should contain CAN controller registers location and length | ||
6 | - interrupts: Should contain IRQ line for the CAN controller | ||
7 | |||
8 | Example: | ||
9 | |||
10 | can0: can@f000c000 { | ||
11 | compatbile = "atmel,at91sam9x5-can"; | ||
12 | reg = <0xf000c000 0x300>; | ||
13 | interrupts = <40 4 5> | ||
14 | }; | ||
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt index ecfdf756d10f..4f2ca6b4a182 100644 --- a/Documentation/devicetree/bindings/net/cpsw.txt +++ b/Documentation/devicetree/bindings/net/cpsw.txt | |||
@@ -15,16 +15,22 @@ Required properties: | |||
15 | - mac_control : Specifies Default MAC control register content | 15 | - mac_control : Specifies Default MAC control register content |
16 | for the specific platform | 16 | for the specific platform |
17 | - slaves : Specifies number for slaves | 17 | - slaves : Specifies number for slaves |
18 | - cpts_active_slave : Specifies the slave to use for time stamping | 18 | - active_slave : Specifies the slave to use for time stamping, |
19 | ethtool and SIOCGMIIPHY | ||
19 | - cpts_clock_mult : Numerator to convert input clock ticks into nanoseconds | 20 | - cpts_clock_mult : Numerator to convert input clock ticks into nanoseconds |
20 | - cpts_clock_shift : Denominator to convert input clock ticks into nanoseconds | 21 | - cpts_clock_shift : Denominator to convert input clock ticks into nanoseconds |
21 | - phy_id : Specifies slave phy id | ||
22 | - mac-address : Specifies slave MAC address | ||
23 | 22 | ||
24 | Optional properties: | 23 | Optional properties: |
25 | - ti,hwmods : Must be "cpgmac0" | 24 | - ti,hwmods : Must be "cpgmac0" |
26 | - no_bd_ram : Must be 0 or 1 | 25 | - no_bd_ram : Must be 0 or 1 |
27 | - dual_emac : Specifies Switch to act as Dual EMAC | 26 | - dual_emac : Specifies Switch to act as Dual EMAC |
27 | |||
28 | Slave Properties: | ||
29 | Required properties: | ||
30 | - phy_id : Specifies slave phy id | ||
31 | - mac-address : Specifies slave MAC address | ||
32 | |||
33 | Optional properties: | ||
28 | - dual_emac_res_vlan : Specifies VID to be used to segregate the ports | 34 | - dual_emac_res_vlan : Specifies VID to be used to segregate the ports |
29 | 35 | ||
30 | Note: "ti,hwmods" field is used to fetch the base address and irq | 36 | Note: "ti,hwmods" field is used to fetch the base address and irq |
@@ -47,7 +53,7 @@ Examples: | |||
47 | rx_descs = <64>; | 53 | rx_descs = <64>; |
48 | mac_control = <0x20>; | 54 | mac_control = <0x20>; |
49 | slaves = <2>; | 55 | slaves = <2>; |
50 | cpts_active_slave = <0>; | 56 | active_slave = <0>; |
51 | cpts_clock_mult = <0x80000000>; | 57 | cpts_clock_mult = <0x80000000>; |
52 | cpts_clock_shift = <29>; | 58 | cpts_clock_shift = <29>; |
53 | cpsw_emac0: slave@0 { | 59 | cpsw_emac0: slave@0 { |
@@ -73,7 +79,7 @@ Examples: | |||
73 | rx_descs = <64>; | 79 | rx_descs = <64>; |
74 | mac_control = <0x20>; | 80 | mac_control = <0x20>; |
75 | slaves = <2>; | 81 | slaves = <2>; |
76 | cpts_active_slave = <0>; | 82 | active_slave = <0>; |
77 | cpts_clock_mult = <0x80000000>; | 83 | cpts_clock_mult = <0x80000000>; |
78 | cpts_clock_shift = <29>; | 84 | cpts_clock_shift = <29>; |
79 | cpsw_emac0: slave@0 { | 85 | cpsw_emac0: slave@0 { |
diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt new file mode 100644 index 000000000000..49f4f7ae3f51 --- /dev/null +++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt | |||
@@ -0,0 +1,91 @@ | |||
1 | Marvell Distributed Switch Architecture Device Tree Bindings | ||
2 | ------------------------------------------------------------ | ||
3 | |||
4 | Required properties: | ||
5 | - compatible : Should be "marvell,dsa" | ||
6 | - #address-cells : Must be 2, first cell is the address on the MDIO bus | ||
7 | and second cell is the address in the switch tree. | ||
8 | Second cell is used only when cascading/chaining. | ||
9 | - #size-cells : Must be 0 | ||
10 | - dsa,ethernet : Should be a phandle to a valid Ethernet device node | ||
11 | - dsa,mii-bus : Should be a phandle to a valid MDIO bus device node | ||
12 | |||
13 | Optionnal properties: | ||
14 | - interrupts : property with a value describing the switch | ||
15 | interrupt number (not supported by the driver) | ||
16 | |||
17 | A DSA node can contain multiple switch chips which are therefore child nodes of | ||
18 | the parent DSA node. The maximum number of allowed child nodes is 4 | ||
19 | (DSA_MAX_SWITCHES). | ||
20 | Each of these switch child nodes should have the following required properties: | ||
21 | |||
22 | - reg : Describes the switch address on the MII bus | ||
23 | - #address-cells : Must be 1 | ||
24 | - #size-cells : Must be 0 | ||
25 | |||
26 | A switch may have multiple "port" children nodes | ||
27 | |||
28 | Each port children node must have the following mandatory properties: | ||
29 | - reg : Describes the port address in the switch | ||
30 | - label : Describes the label associated with this port, special | ||
31 | labels are "cpu" to indicate a CPU port and "dsa" to | ||
32 | indicate an uplink/downlink port. | ||
33 | |||
34 | Note that a port labelled "dsa" will imply checking for the uplink phandle | ||
35 | described below. | ||
36 | |||
37 | Optionnal property: | ||
38 | - link : Should be a phandle to another switch's DSA port. | ||
39 | This property is only used when switches are being | ||
40 | chained/cascaded together. | ||
41 | |||
42 | Example: | ||
43 | |||
44 | dsa@0 { | ||
45 | compatible = "marvell,dsa"; | ||
46 | #address-cells = <2>; | ||
47 | #size-cells = <0>; | ||
48 | |||
49 | interrupts = <10>; | ||
50 | dsa,ethernet = <ðernet0>; | ||
51 | dsa,mii-bus = <&mii_bus0>; | ||
52 | |||
53 | switch@0 { | ||
54 | #address-cells = <1>; | ||
55 | #size-cells = <0>; | ||
56 | reg = <16 0>; /* MDIO address 16, switch 0 in tree */ | ||
57 | |||
58 | port@0 { | ||
59 | reg = <0>; | ||
60 | label = "lan1"; | ||
61 | }; | ||
62 | |||
63 | port@1 { | ||
64 | reg = <1>; | ||
65 | label = "lan2"; | ||
66 | }; | ||
67 | |||
68 | port@5 { | ||
69 | reg = <5>; | ||
70 | label = "cpu"; | ||
71 | }; | ||
72 | |||
73 | switch0uplink: port@6 { | ||
74 | reg = <6>; | ||
75 | label = "dsa"; | ||
76 | link = <&switch1uplink>; | ||
77 | }; | ||
78 | }; | ||
79 | |||
80 | switch@1 { | ||
81 | #address-cells = <1>; | ||
82 | #size-cells = <0>; | ||
83 | reg = <17 1>; /* MDIO address 17, switch 1 in tree */ | ||
84 | |||
85 | switch1uplink: port@0 { | ||
86 | reg = <0>; | ||
87 | label = "dsa"; | ||
88 | link = <&switch0uplink>; | ||
89 | }; | ||
90 | }; | ||
91 | }; | ||
diff --git a/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt b/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt index 34e7aafa321c..052b5f28a624 100644 --- a/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt +++ b/Documentation/devicetree/bindings/net/marvell-orion-mdio.txt | |||
@@ -9,6 +9,9 @@ Required properties: | |||
9 | - compatible: "marvell,orion-mdio" | 9 | - compatible: "marvell,orion-mdio" |
10 | - reg: address and length of the SMI register | 10 | - reg: address and length of the SMI register |
11 | 11 | ||
12 | Optional properties: | ||
13 | - interrupts: interrupt line number for the SMI error/done interrupt | ||
14 | |||
12 | The child nodes of the MDIO driver are the individual PHY devices | 15 | The child nodes of the MDIO driver are the individual PHY devices |
13 | connected to this MDIO bus. They must have a "reg" property given the | 16 | connected to this MDIO bus. They must have a "reg" property given the |
14 | PHY address on the MDIO bus. | 17 | PHY address on the MDIO bus. |
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index dc2dc87d2557..f98ca633b528 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt | |||
@@ -29,7 +29,7 @@ route/max_size - INTEGER | |||
29 | neigh/default/gc_thresh1 - INTEGER | 29 | neigh/default/gc_thresh1 - INTEGER |
30 | Minimum number of entries to keep. Garbage collector will not | 30 | Minimum number of entries to keep. Garbage collector will not |
31 | purge entries if there are fewer than this number. | 31 | purge entries if there are fewer than this number. |
32 | Default: 256 | 32 | Default: 128 |
33 | 33 | ||
34 | neigh/default/gc_thresh3 - INTEGER | 34 | neigh/default/gc_thresh3 - INTEGER |
35 | Maximum number of neighbor entries allowed. Increase this | 35 | Maximum number of neighbor entries allowed. Increase this |
@@ -175,14 +175,6 @@ tcp_congestion_control - STRING | |||
175 | is inherited. | 175 | is inherited. |
176 | [see setsockopt(listenfd, SOL_TCP, TCP_CONGESTION, "name" ...) ] | 176 | [see setsockopt(listenfd, SOL_TCP, TCP_CONGESTION, "name" ...) ] |
177 | 177 | ||
178 | tcp_cookie_size - INTEGER | ||
179 | Default size of TCP Cookie Transactions (TCPCT) option, that may be | ||
180 | overridden on a per socket basis by the TCPCT socket option. | ||
181 | Values greater than the maximum (16) are interpreted as the maximum. | ||
182 | Values greater than zero and less than the minimum (8) are interpreted | ||
183 | as the minimum. Odd values are interpreted as the next even value. | ||
184 | Default: 0 (off). | ||
185 | |||
186 | tcp_dsack - BOOLEAN | 178 | tcp_dsack - BOOLEAN |
187 | Allows TCP to send "duplicate" SACKs. | 179 | Allows TCP to send "duplicate" SACKs. |
188 | 180 | ||
@@ -190,7 +182,9 @@ tcp_early_retrans - INTEGER | |||
190 | Enable Early Retransmit (ER), per RFC 5827. ER lowers the threshold | 182 | Enable Early Retransmit (ER), per RFC 5827. ER lowers the threshold |
191 | for triggering fast retransmit when the amount of outstanding data is | 183 | for triggering fast retransmit when the amount of outstanding data is |
192 | small and when no previously unsent data can be transmitted (such | 184 | small and when no previously unsent data can be transmitted (such |
193 | that limited transmit could be used). | 185 | that limited transmit could be used). Also controls the use of |
186 | Tail loss probe (TLP) that converts RTOs occuring due to tail | ||
187 | losses into fast recovery (draft-dukkipati-tcpm-tcp-loss-probe-01). | ||
194 | Possible values: | 188 | Possible values: |
195 | 0 disables ER | 189 | 0 disables ER |
196 | 1 enables ER | 190 | 1 enables ER |
@@ -198,7 +192,9 @@ tcp_early_retrans - INTEGER | |||
198 | by a fourth of RTT. This mitigates connection falsely | 192 | by a fourth of RTT. This mitigates connection falsely |
199 | recovers when network has a small degree of reordering | 193 | recovers when network has a small degree of reordering |
200 | (less than 3 packets). | 194 | (less than 3 packets). |
201 | Default: 2 | 195 | 3 enables delayed ER and TLP. |
196 | 4 enables TLP only. | ||
197 | Default: 3 | ||
202 | 198 | ||
203 | tcp_ecn - INTEGER | 199 | tcp_ecn - INTEGER |
204 | Control use of Explicit Congestion Notification (ECN) by TCP. | 200 | Control use of Explicit Congestion Notification (ECN) by TCP. |
@@ -229,36 +225,13 @@ tcp_fin_timeout - INTEGER | |||
229 | Default: 60 seconds | 225 | Default: 60 seconds |
230 | 226 | ||
231 | tcp_frto - INTEGER | 227 | tcp_frto - INTEGER |
232 | Enables Forward RTO-Recovery (F-RTO) defined in RFC4138. | 228 | Enables Forward RTO-Recovery (F-RTO) defined in RFC5682. |
233 | F-RTO is an enhanced recovery algorithm for TCP retransmission | 229 | F-RTO is an enhanced recovery algorithm for TCP retransmission |
234 | timeouts. It is particularly beneficial in wireless environments | 230 | timeouts. It is particularly beneficial in networks where the |
235 | where packet loss is typically due to random radio interference | 231 | RTT fluctuates (e.g., wireless). F-RTO is sender-side only |
236 | rather than intermediate router congestion. F-RTO is sender-side | 232 | modification. It does not require any support from the peer. |
237 | only modification. Therefore it does not require any support from | 233 | |
238 | the peer. | 234 | By default it's enabled with a non-zero value. 0 disables F-RTO. |
239 | |||
240 | If set to 1, basic version is enabled. 2 enables SACK enhanced | ||
241 | F-RTO if flow uses SACK. The basic version can be used also when | ||
242 | SACK is in use though scenario(s) with it exists where F-RTO | ||
243 | interacts badly with the packet counting of the SACK enabled TCP | ||
244 | flow. | ||
245 | |||
246 | tcp_frto_response - INTEGER | ||
247 | When F-RTO has detected that a TCP retransmission timeout was | ||
248 | spurious (i.e, the timeout would have been avoided had TCP set a | ||
249 | longer retransmission timeout), TCP has several options what to do | ||
250 | next. Possible values are: | ||
251 | 0 Rate halving based; a smooth and conservative response, | ||
252 | results in halved cwnd and ssthresh after one RTT | ||
253 | 1 Very conservative response; not recommended because even | ||
254 | though being valid, it interacts poorly with the rest of | ||
255 | Linux TCP, halves cwnd and ssthresh immediately | ||
256 | 2 Aggressive response; undoes congestion control measures | ||
257 | that are now known to be unnecessary (ignoring the | ||
258 | possibility of a lost retransmission that would require | ||
259 | TCP to be more cautious), cwnd and ssthresh are restored | ||
260 | to the values prior timeout | ||
261 | Default: 0 (rate halving based) | ||
262 | 235 | ||
263 | tcp_keepalive_time - INTEGER | 236 | tcp_keepalive_time - INTEGER |
264 | How often TCP sends out keepalive messages when keepalive is enabled. | 237 | How often TCP sends out keepalive messages when keepalive is enabled. |
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt index 94444b152fbc..65efb85e49de 100644 --- a/Documentation/networking/packet_mmap.txt +++ b/Documentation/networking/packet_mmap.txt | |||
@@ -685,6 +685,333 @@ int main(int argc, char **argp) | |||
685 | } | 685 | } |
686 | 686 | ||
687 | ------------------------------------------------------------------------------- | 687 | ------------------------------------------------------------------------------- |
688 | + AF_PACKET TPACKET_V3 example | ||
689 | ------------------------------------------------------------------------------- | ||
690 | |||
691 | AF_PACKET's TPACKET_V3 ring buffer can be configured to use non-static frame | ||
692 | sizes by doing it's own memory management. It is based on blocks where polling | ||
693 | works on a per block basis instead of per ring as in TPACKET_V2 and predecessor. | ||
694 | |||
695 | It is said that TPACKET_V3 brings the following benefits: | ||
696 | *) ~15 - 20% reduction in CPU-usage | ||
697 | *) ~20% increase in packet capture rate | ||
698 | *) ~2x increase in packet density | ||
699 | *) Port aggregation analysis | ||
700 | *) Non static frame size to capture entire packet payload | ||
701 | |||
702 | So it seems to be a good candidate to be used with packet fanout. | ||
703 | |||
704 | Minimal example code by Daniel Borkmann based on Chetan Loke's lolpcap (compile | ||
705 | it with gcc -Wall -O2 blob.c, and try things like "./a.out eth0", etc.): | ||
706 | |||
707 | #include <stdio.h> | ||
708 | #include <stdlib.h> | ||
709 | #include <stdint.h> | ||
710 | #include <string.h> | ||
711 | #include <assert.h> | ||
712 | #include <net/if.h> | ||
713 | #include <arpa/inet.h> | ||
714 | #include <netdb.h> | ||
715 | #include <poll.h> | ||
716 | #include <unistd.h> | ||
717 | #include <signal.h> | ||
718 | #include <inttypes.h> | ||
719 | #include <sys/socket.h> | ||
720 | #include <sys/mman.h> | ||
721 | #include <linux/if_packet.h> | ||
722 | #include <linux/if_ether.h> | ||
723 | #include <linux/ip.h> | ||
724 | |||
725 | #define BLOCK_SIZE (1 << 22) | ||
726 | #define FRAME_SIZE 2048 | ||
727 | |||
728 | #define NUM_BLOCKS 64 | ||
729 | #define NUM_FRAMES ((BLOCK_SIZE * NUM_BLOCKS) / FRAME_SIZE) | ||
730 | |||
731 | #define BLOCK_RETIRE_TOV_IN_MS 64 | ||
732 | #define BLOCK_PRIV_AREA_SZ 13 | ||
733 | |||
734 | #define ALIGN_8(x) (((x) + 8 - 1) & ~(8 - 1)) | ||
735 | |||
736 | #define BLOCK_STATUS(x) ((x)->h1.block_status) | ||
737 | #define BLOCK_NUM_PKTS(x) ((x)->h1.num_pkts) | ||
738 | #define BLOCK_O2FP(x) ((x)->h1.offset_to_first_pkt) | ||
739 | #define BLOCK_LEN(x) ((x)->h1.blk_len) | ||
740 | #define BLOCK_SNUM(x) ((x)->h1.seq_num) | ||
741 | #define BLOCK_O2PRIV(x) ((x)->offset_to_priv) | ||
742 | #define BLOCK_PRIV(x) ((void *) ((uint8_t *) (x) + BLOCK_O2PRIV(x))) | ||
743 | #define BLOCK_HDR_LEN (ALIGN_8(sizeof(struct block_desc))) | ||
744 | #define BLOCK_PLUS_PRIV(sz_pri) (BLOCK_HDR_LEN + ALIGN_8((sz_pri))) | ||
745 | |||
746 | #ifndef likely | ||
747 | # define likely(x) __builtin_expect(!!(x), 1) | ||
748 | #endif | ||
749 | #ifndef unlikely | ||
750 | # define unlikely(x) __builtin_expect(!!(x), 0) | ||
751 | #endif | ||
752 | |||
753 | struct block_desc { | ||
754 | uint32_t version; | ||
755 | uint32_t offset_to_priv; | ||
756 | struct tpacket_hdr_v1 h1; | ||
757 | }; | ||
758 | |||
759 | struct ring { | ||
760 | struct iovec *rd; | ||
761 | uint8_t *map; | ||
762 | struct tpacket_req3 req; | ||
763 | }; | ||
764 | |||
765 | static unsigned long packets_total = 0, bytes_total = 0; | ||
766 | static sig_atomic_t sigint = 0; | ||
767 | |||
768 | void sighandler(int num) | ||
769 | { | ||
770 | sigint = 1; | ||
771 | } | ||
772 | |||
773 | static int setup_socket(struct ring *ring, char *netdev) | ||
774 | { | ||
775 | int err, i, fd, v = TPACKET_V3; | ||
776 | struct sockaddr_ll ll; | ||
777 | |||
778 | fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); | ||
779 | if (fd < 0) { | ||
780 | perror("socket"); | ||
781 | exit(1); | ||
782 | } | ||
783 | |||
784 | err = setsockopt(fd, SOL_PACKET, PACKET_VERSION, &v, sizeof(v)); | ||
785 | if (err < 0) { | ||
786 | perror("setsockopt"); | ||
787 | exit(1); | ||
788 | } | ||
789 | |||
790 | memset(&ring->req, 0, sizeof(ring->req)); | ||
791 | ring->req.tp_block_size = BLOCK_SIZE; | ||
792 | ring->req.tp_frame_size = FRAME_SIZE; | ||
793 | ring->req.tp_block_nr = NUM_BLOCKS; | ||
794 | ring->req.tp_frame_nr = NUM_FRAMES; | ||
795 | ring->req.tp_retire_blk_tov = BLOCK_RETIRE_TOV_IN_MS; | ||
796 | ring->req.tp_sizeof_priv = BLOCK_PRIV_AREA_SZ; | ||
797 | ring->req.tp_feature_req_word |= TP_FT_REQ_FILL_RXHASH; | ||
798 | |||
799 | err = setsockopt(fd, SOL_PACKET, PACKET_RX_RING, &ring->req, | ||
800 | sizeof(ring->req)); | ||
801 | if (err < 0) { | ||
802 | perror("setsockopt"); | ||
803 | exit(1); | ||
804 | } | ||
805 | |||
806 | ring->map = mmap(NULL, ring->req.tp_block_size * ring->req.tp_block_nr, | ||
807 | PROT_READ | PROT_WRITE, MAP_SHARED | MAP_LOCKED, | ||
808 | fd, 0); | ||
809 | if (ring->map == MAP_FAILED) { | ||
810 | perror("mmap"); | ||
811 | exit(1); | ||
812 | } | ||
813 | |||
814 | ring->rd = malloc(ring->req.tp_block_nr * sizeof(*ring->rd)); | ||
815 | assert(ring->rd); | ||
816 | for (i = 0; i < ring->req.tp_block_nr; ++i) { | ||
817 | ring->rd[i].iov_base = ring->map + (i * ring->req.tp_block_size); | ||
818 | ring->rd[i].iov_len = ring->req.tp_block_size; | ||
819 | } | ||
820 | |||
821 | memset(&ll, 0, sizeof(ll)); | ||
822 | ll.sll_family = PF_PACKET; | ||
823 | ll.sll_protocol = htons(ETH_P_ALL); | ||
824 | ll.sll_ifindex = if_nametoindex(netdev); | ||
825 | ll.sll_hatype = 0; | ||
826 | ll.sll_pkttype = 0; | ||
827 | ll.sll_halen = 0; | ||
828 | |||
829 | err = bind(fd, (struct sockaddr *) &ll, sizeof(ll)); | ||
830 | if (err < 0) { | ||
831 | perror("bind"); | ||
832 | exit(1); | ||
833 | } | ||
834 | |||
835 | return fd; | ||
836 | } | ||
837 | |||
838 | #ifdef __checked | ||
839 | static uint64_t prev_block_seq_num = 0; | ||
840 | |||
841 | void assert_block_seq_num(struct block_desc *pbd) | ||
842 | { | ||
843 | if (unlikely(prev_block_seq_num + 1 != BLOCK_SNUM(pbd))) { | ||
844 | printf("prev_block_seq_num:%"PRIu64", expected seq:%"PRIu64" != " | ||
845 | "actual seq:%"PRIu64"\n", prev_block_seq_num, | ||
846 | prev_block_seq_num + 1, (uint64_t) BLOCK_SNUM(pbd)); | ||
847 | exit(1); | ||
848 | } | ||
849 | |||
850 | prev_block_seq_num = BLOCK_SNUM(pbd); | ||
851 | } | ||
852 | |||
853 | static void assert_block_len(struct block_desc *pbd, uint32_t bytes, int block_num) | ||
854 | { | ||
855 | if (BLOCK_NUM_PKTS(pbd)) { | ||
856 | if (unlikely(bytes != BLOCK_LEN(pbd))) { | ||
857 | printf("block:%u with %upackets, expected len:%u != actual len:%u\n", | ||
858 | block_num, BLOCK_NUM_PKTS(pbd), bytes, BLOCK_LEN(pbd)); | ||
859 | exit(1); | ||
860 | } | ||
861 | } else { | ||
862 | if (unlikely(BLOCK_LEN(pbd) != BLOCK_PLUS_PRIV(BLOCK_PRIV_AREA_SZ))) { | ||
863 | printf("block:%u, expected len:%lu != actual len:%u\n", | ||
864 | block_num, BLOCK_HDR_LEN, BLOCK_LEN(pbd)); | ||
865 | exit(1); | ||
866 | } | ||
867 | } | ||
868 | } | ||
869 | |||
870 | static void assert_block_header(struct block_desc *pbd, const int block_num) | ||
871 | { | ||
872 | uint32_t block_status = BLOCK_STATUS(pbd); | ||
873 | |||
874 | if (unlikely((block_status & TP_STATUS_USER) == 0)) { | ||
875 | printf("block:%u, not in TP_STATUS_USER\n", block_num); | ||
876 | exit(1); | ||
877 | } | ||
878 | |||
879 | assert_block_seq_num(pbd); | ||
880 | } | ||
881 | #else | ||
882 | static inline void assert_block_header(struct block_desc *pbd, const int block_num) | ||
883 | { | ||
884 | } | ||
885 | static void assert_block_len(struct block_desc *pbd, uint32_t bytes, int block_num) | ||
886 | { | ||
887 | } | ||
888 | #endif | ||
889 | |||
890 | static void display(struct tpacket3_hdr *ppd) | ||
891 | { | ||
892 | struct ethhdr *eth = (struct ethhdr *) ((uint8_t *) ppd + ppd->tp_mac); | ||
893 | struct iphdr *ip = (struct iphdr *) ((uint8_t *) eth + ETH_HLEN); | ||
894 | |||
895 | if (eth->h_proto == htons(ETH_P_IP)) { | ||
896 | struct sockaddr_in ss, sd; | ||
897 | char sbuff[NI_MAXHOST], dbuff[NI_MAXHOST]; | ||
898 | |||
899 | memset(&ss, 0, sizeof(ss)); | ||
900 | ss.sin_family = PF_INET; | ||
901 | ss.sin_addr.s_addr = ip->saddr; | ||
902 | getnameinfo((struct sockaddr *) &ss, sizeof(ss), | ||
903 | sbuff, sizeof(sbuff), NULL, 0, NI_NUMERICHOST); | ||
904 | |||
905 | memset(&sd, 0, sizeof(sd)); | ||
906 | sd.sin_family = PF_INET; | ||
907 | sd.sin_addr.s_addr = ip->daddr; | ||
908 | getnameinfo((struct sockaddr *) &sd, sizeof(sd), | ||
909 | dbuff, sizeof(dbuff), NULL, 0, NI_NUMERICHOST); | ||
910 | |||
911 | printf("%s -> %s, ", sbuff, dbuff); | ||
912 | } | ||
913 | |||
914 | printf("rxhash: 0x%x\n", ppd->hv1.tp_rxhash); | ||
915 | } | ||
916 | |||
917 | static void walk_block(struct block_desc *pbd, const int block_num) | ||
918 | { | ||
919 | int num_pkts = BLOCK_NUM_PKTS(pbd), i; | ||
920 | unsigned long bytes = 0; | ||
921 | unsigned long bytes_with_padding = BLOCK_PLUS_PRIV(BLOCK_PRIV_AREA_SZ); | ||
922 | struct tpacket3_hdr *ppd; | ||
923 | |||
924 | assert_block_header(pbd, block_num); | ||
925 | |||
926 | ppd = (struct tpacket3_hdr *) ((uint8_t *) pbd + BLOCK_O2FP(pbd)); | ||
927 | for (i = 0; i < num_pkts; ++i) { | ||
928 | bytes += ppd->tp_snaplen; | ||
929 | if (ppd->tp_next_offset) | ||
930 | bytes_with_padding += ppd->tp_next_offset; | ||
931 | else | ||
932 | bytes_with_padding += ALIGN_8(ppd->tp_snaplen + ppd->tp_mac); | ||
933 | |||
934 | display(ppd); | ||
935 | |||
936 | ppd = (struct tpacket3_hdr *) ((uint8_t *) ppd + ppd->tp_next_offset); | ||
937 | __sync_synchronize(); | ||
938 | } | ||
939 | |||
940 | assert_block_len(pbd, bytes_with_padding, block_num); | ||
941 | |||
942 | packets_total += num_pkts; | ||
943 | bytes_total += bytes; | ||
944 | } | ||
945 | |||
946 | void flush_block(struct block_desc *pbd) | ||
947 | { | ||
948 | BLOCK_STATUS(pbd) = TP_STATUS_KERNEL; | ||
949 | __sync_synchronize(); | ||
950 | } | ||
951 | |||
952 | static void teardown_socket(struct ring *ring, int fd) | ||
953 | { | ||
954 | munmap(ring->map, ring->req.tp_block_size * ring->req.tp_block_nr); | ||
955 | free(ring->rd); | ||
956 | close(fd); | ||
957 | } | ||
958 | |||
959 | int main(int argc, char **argp) | ||
960 | { | ||
961 | int fd, err; | ||
962 | socklen_t len; | ||
963 | struct ring ring; | ||
964 | struct pollfd pfd; | ||
965 | unsigned int block_num = 0; | ||
966 | struct block_desc *pbd; | ||
967 | struct tpacket_stats_v3 stats; | ||
968 | |||
969 | if (argc != 2) { | ||
970 | fprintf(stderr, "Usage: %s INTERFACE\n", argp[0]); | ||
971 | return EXIT_FAILURE; | ||
972 | } | ||
973 | |||
974 | signal(SIGINT, sighandler); | ||
975 | |||
976 | memset(&ring, 0, sizeof(ring)); | ||
977 | fd = setup_socket(&ring, argp[argc - 1]); | ||
978 | assert(fd > 0); | ||
979 | |||
980 | memset(&pfd, 0, sizeof(pfd)); | ||
981 | pfd.fd = fd; | ||
982 | pfd.events = POLLIN | POLLERR; | ||
983 | pfd.revents = 0; | ||
984 | |||
985 | while (likely(!sigint)) { | ||
986 | pbd = (struct block_desc *) ring.rd[block_num].iov_base; | ||
987 | retry_block: | ||
988 | if ((BLOCK_STATUS(pbd) & TP_STATUS_USER) == 0) { | ||
989 | poll(&pfd, 1, -1); | ||
990 | goto retry_block; | ||
991 | } | ||
992 | |||
993 | walk_block(pbd, block_num); | ||
994 | flush_block(pbd); | ||
995 | block_num = (block_num + 1) % NUM_BLOCKS; | ||
996 | } | ||
997 | |||
998 | len = sizeof(stats); | ||
999 | err = getsockopt(fd, SOL_PACKET, PACKET_STATISTICS, &stats, &len); | ||
1000 | if (err < 0) { | ||
1001 | perror("getsockopt"); | ||
1002 | exit(1); | ||
1003 | } | ||
1004 | |||
1005 | fflush(stdout); | ||
1006 | printf("\nReceived %u packets, %lu bytes, %u dropped, freeze_q_cnt: %u\n", | ||
1007 | stats.tp_packets, bytes_total, stats.tp_drops, | ||
1008 | stats.tp_freeze_q_cnt); | ||
1009 | |||
1010 | teardown_socket(&ring, fd); | ||
1011 | return 0; | ||
1012 | } | ||
1013 | |||
1014 | ------------------------------------------------------------------------------- | ||
688 | + PACKET_TIMESTAMP | 1015 | + PACKET_TIMESTAMP |
689 | ------------------------------------------------------------------------------- | 1016 | ------------------------------------------------------------------------------- |
690 | 1017 | ||
diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt index f9fa6db40a52..8efe0b3c8b83 100644 --- a/Documentation/networking/stmmac.txt +++ b/Documentation/networking/stmmac.txt | |||
@@ -326,6 +326,35 @@ To enter in Tx LPI mode the driver needs to have a software timer | |||
326 | that enable and disable the LPI mode when there is nothing to be | 326 | that enable and disable the LPI mode when there is nothing to be |
327 | transmitted. | 327 | transmitted. |
328 | 328 | ||
329 | 7) TODO: | 329 | 7) Extended descriptors |
330 | The extended descriptors give us information about the receive Ethernet payload | ||
331 | when it is carrying PTP packets or TCP/UDP/ICMP over IP. | ||
332 | These are not available on GMAC Synopsys chips older than the 3.50. | ||
333 | At probe time the driver will decide if these can be actually used. | ||
334 | This support also is mandatory for PTPv2 because the extra descriptors 6 and 7 | ||
335 | are used for saving the hardware timestamps. | ||
336 | |||
337 | 8) Precision Time Protocol (PTP) | ||
338 | The driver supports the IEEE 1588-2002, Precision Time Protocol (PTP), | ||
339 | which enables precise synchronization of clocks in measurement and | ||
340 | control systems implemented with technologies such as network | ||
341 | communication. | ||
342 | |||
343 | In addition to the basic timestamp features mentioned in IEEE 1588-2002 | ||
344 | Timestamps, new GMAC cores support the advanced timestamp features. | ||
345 | IEEE 1588-2008 that can be enabled when configure the Kernel. | ||
346 | |||
347 | 9) SGMII/RGMII supports | ||
348 | New GMAC devices provide own way to manage RGMII/SGMII. | ||
349 | This information is available at run-time by looking at the | ||
350 | HW capability register. This means that the stmmac can manage | ||
351 | auto-negotiation and link status w/o using the PHYLIB stuff | ||
352 | In fact, the HW provides a subset of extended registers to | ||
353 | restart the ANE, verify Full/Half duplex mode and Speed. | ||
354 | Also thanks to these registers it is possible to look at the | ||
355 | Auto-negotiated Link Parter Ability. | ||
356 | |||
357 | 10) TODO: | ||
330 | o XGMAC is not supported. | 358 | o XGMAC is not supported. |
331 | o Add the PTP - precision time protocol | 359 | o Complete the TBI & RTBI support. |
360 | o extened VLAN support for 3.70a SYNP GMAC. | ||