Commit 57bf1451ac79640c5a0a4f31284c43539fac2903
Committed by
David S. Miller
1 parent
73eef4cddb
Exists in
master
and in
4 other branches
[NET]: net/802: more endian annotations
The rest of endian warnings now belongs to tr.c exclusively. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 7 changed files with 10 additions and 11 deletions Inline Diff
include/linux/hippidevice.h
1 | /* | 1 | /* |
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
3 | * operating system. INET is implemented using the BSD Socket | 3 | * operating system. INET is implemented using the BSD Socket |
4 | * interface as the means of communication with the user level. | 4 | * interface as the means of communication with the user level. |
5 | * | 5 | * |
6 | * Definitions for the HIPPI handlers. | 6 | * Definitions for the HIPPI handlers. |
7 | * | 7 | * |
8 | * Version: @(#)hippidevice.h 1.0.0 05/26/97 | 8 | * Version: @(#)hippidevice.h 1.0.0 05/26/97 |
9 | * | 9 | * |
10 | * Author: Jes Sorensen, <Jes.Sorensen@cern.ch> | 10 | * Author: Jes Sorensen, <Jes.Sorensen@cern.ch> |
11 | * | 11 | * |
12 | * hippidevice.h is based on previous fddidevice.h work by | 12 | * hippidevice.h is based on previous fddidevice.h work by |
13 | * Ross Biro | 13 | * Ross Biro |
14 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | 14 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
15 | * Alan Cox, <gw4pts@gw4pts.ampr.org> | 15 | * Alan Cox, <gw4pts@gw4pts.ampr.org> |
16 | * Lawrence V. Stefani, <stefani@lkg.dec.com> | 16 | * Lawrence V. Stefani, <stefani@lkg.dec.com> |
17 | * | 17 | * |
18 | * This program is free software; you can redistribute it and/or | 18 | * This program is free software; you can redistribute it and/or |
19 | * modify it under the terms of the GNU General Public License | 19 | * modify it under the terms of the GNU General Public License |
20 | * as published by the Free Software Foundation; either version | 20 | * as published by the Free Software Foundation; either version |
21 | * 2 of the License, or (at your option) any later version. | 21 | * 2 of the License, or (at your option) any later version. |
22 | */ | 22 | */ |
23 | #ifndef _LINUX_HIPPIDEVICE_H | 23 | #ifndef _LINUX_HIPPIDEVICE_H |
24 | #define _LINUX_HIPPIDEVICE_H | 24 | #define _LINUX_HIPPIDEVICE_H |
25 | 25 | ||
26 | #include <linux/if_hippi.h> | 26 | #include <linux/if_hippi.h> |
27 | 27 | ||
28 | #ifdef __KERNEL__ | 28 | #ifdef __KERNEL__ |
29 | 29 | ||
30 | struct hippi_cb { | 30 | struct hippi_cb { |
31 | __u32 ifield; | 31 | __u32 ifield; |
32 | }; | 32 | }; |
33 | 33 | ||
34 | extern unsigned short hippi_type_trans(struct sk_buff *skb, | 34 | extern __be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev); |
35 | struct net_device *dev); | ||
36 | 35 | ||
37 | extern struct net_device *alloc_hippi_dev(int sizeof_priv); | 36 | extern struct net_device *alloc_hippi_dev(int sizeof_priv); |
38 | #endif | 37 | #endif |
39 | 38 | ||
40 | #endif /* _LINUX_HIPPIDEVICE_H */ | 39 | #endif /* _LINUX_HIPPIDEVICE_H */ |
41 | 40 |
include/linux/if_fc.h
1 | /* | 1 | /* |
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
3 | * operating system. INET is implemented using the BSD Socket | 3 | * operating system. INET is implemented using the BSD Socket |
4 | * interface as the means of communication with the user level. | 4 | * interface as the means of communication with the user level. |
5 | * | 5 | * |
6 | * Global definitions for Fibre Channel. | 6 | * Global definitions for Fibre Channel. |
7 | * | 7 | * |
8 | * Version: @(#)if_fc.h 0.0 11/20/98 | 8 | * Version: @(#)if_fc.h 0.0 11/20/98 |
9 | * | 9 | * |
10 | * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | 10 | * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
11 | * Donald Becker, <becker@super.org> | 11 | * Donald Becker, <becker@super.org> |
12 | * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be> | 12 | * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be> |
13 | * Vineet Abraham, <vma@iol.unh.edu> | 13 | * Vineet Abraham, <vma@iol.unh.edu> |
14 | * | 14 | * |
15 | * This program is free software; you can redistribute it and/or | 15 | * This program is free software; you can redistribute it and/or |
16 | * modify it under the terms of the GNU General Public License | 16 | * modify it under the terms of the GNU General Public License |
17 | * as published by the Free Software Foundation; either version | 17 | * as published by the Free Software Foundation; either version |
18 | * 2 of the License, or (at your option) any later version. | 18 | * 2 of the License, or (at your option) any later version. |
19 | */ | 19 | */ |
20 | #ifndef _LINUX_IF_FC_H | 20 | #ifndef _LINUX_IF_FC_H |
21 | #define _LINUX_IF_FC_H | 21 | #define _LINUX_IF_FC_H |
22 | 22 | ||
23 | 23 | ||
24 | #define FC_ALEN 6 /* Octets in one ethernet addr */ | 24 | #define FC_ALEN 6 /* Octets in one ethernet addr */ |
25 | #define FC_HLEN (sizeof(struct fch_hdr)+sizeof(struct fcllc)) | 25 | #define FC_HLEN (sizeof(struct fch_hdr)+sizeof(struct fcllc)) |
26 | #define FC_ID_LEN 3 /* Octets in a Fibre Channel Address */ | 26 | #define FC_ID_LEN 3 /* Octets in a Fibre Channel Address */ |
27 | 27 | ||
28 | /* LLC and SNAP constants */ | 28 | /* LLC and SNAP constants */ |
29 | #define EXTENDED_SAP 0xAA | 29 | #define EXTENDED_SAP 0xAA |
30 | #define UI_CMD 0x03 | 30 | #define UI_CMD 0x03 |
31 | 31 | ||
32 | /* This is NOT the Fibre Channel frame header. The FC frame header is | 32 | /* This is NOT the Fibre Channel frame header. The FC frame header is |
33 | * constructed in the driver as the Tachyon needs certain fields in | 33 | * constructed in the driver as the Tachyon needs certain fields in |
34 | * certains positions. So, it can't be generalized here.*/ | 34 | * certains positions. So, it can't be generalized here.*/ |
35 | 35 | ||
36 | struct fch_hdr { | 36 | struct fch_hdr { |
37 | __u8 daddr[FC_ALEN]; /* destination address */ | 37 | __u8 daddr[FC_ALEN]; /* destination address */ |
38 | __u8 saddr[FC_ALEN]; /* source address */ | 38 | __u8 saddr[FC_ALEN]; /* source address */ |
39 | }; | 39 | }; |
40 | 40 | ||
41 | /* This is a Fibre Channel LLC structure */ | 41 | /* This is a Fibre Channel LLC structure */ |
42 | struct fcllc { | 42 | struct fcllc { |
43 | __u8 dsap; /* destination SAP */ | 43 | __u8 dsap; /* destination SAP */ |
44 | __u8 ssap; /* source SAP */ | 44 | __u8 ssap; /* source SAP */ |
45 | __u8 llc; /* LLC control field */ | 45 | __u8 llc; /* LLC control field */ |
46 | __u8 protid[3]; /* protocol id */ | 46 | __u8 protid[3]; /* protocol id */ |
47 | __u16 ethertype; /* ether type field */ | 47 | __be16 ethertype; /* ether type field */ |
48 | }; | 48 | }; |
49 | 49 | ||
50 | #endif /* _LINUX_IF_FC_H */ | 50 | #endif /* _LINUX_IF_FC_H */ |
51 | 51 |
include/linux/if_fddi.h
1 | /* | 1 | /* |
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
3 | * operating system. INET is implemented using the BSD Socket | 3 | * operating system. INET is implemented using the BSD Socket |
4 | * interface as the means of communication with the user level. | 4 | * interface as the means of communication with the user level. |
5 | * | 5 | * |
6 | * Global definitions for the ANSI FDDI interface. | 6 | * Global definitions for the ANSI FDDI interface. |
7 | * | 7 | * |
8 | * Version: @(#)if_fddi.h 1.0.2 Sep 29 2004 | 8 | * Version: @(#)if_fddi.h 1.0.2 Sep 29 2004 |
9 | * | 9 | * |
10 | * Author: Lawrence V. Stefani, <stefani@lkg.dec.com> | 10 | * Author: Lawrence V. Stefani, <stefani@lkg.dec.com> |
11 | * | 11 | * |
12 | * if_fddi.h is based on previous if_ether.h and if_tr.h work by | 12 | * if_fddi.h is based on previous if_ether.h and if_tr.h work by |
13 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | 13 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
14 | * Donald Becker, <becker@super.org> | 14 | * Donald Becker, <becker@super.org> |
15 | * Alan Cox, <alan@redhat.com> | 15 | * Alan Cox, <alan@redhat.com> |
16 | * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> | 16 | * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> |
17 | * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be> | 17 | * Peter De Schrijver, <stud11@cc4.kuleuven.ac.be> |
18 | * | 18 | * |
19 | * This program is free software; you can redistribute it and/or | 19 | * This program is free software; you can redistribute it and/or |
20 | * modify it under the terms of the GNU General Public License | 20 | * modify it under the terms of the GNU General Public License |
21 | * as published by the Free Software Foundation; either version | 21 | * as published by the Free Software Foundation; either version |
22 | * 2 of the License, or (at your option) any later version. | 22 | * 2 of the License, or (at your option) any later version. |
23 | */ | 23 | */ |
24 | #ifndef _LINUX_IF_FDDI_H | 24 | #ifndef _LINUX_IF_FDDI_H |
25 | #define _LINUX_IF_FDDI_H | 25 | #define _LINUX_IF_FDDI_H |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * Define max and min legal sizes. The frame sizes do not include | 28 | * Define max and min legal sizes. The frame sizes do not include |
29 | * 4 byte FCS/CRC (frame check sequence). | 29 | * 4 byte FCS/CRC (frame check sequence). |
30 | */ | 30 | */ |
31 | #define FDDI_K_ALEN 6 /* Octets in one FDDI address */ | 31 | #define FDDI_K_ALEN 6 /* Octets in one FDDI address */ |
32 | #define FDDI_K_8022_HLEN 16 /* Total octets in 802.2 header */ | 32 | #define FDDI_K_8022_HLEN 16 /* Total octets in 802.2 header */ |
33 | #define FDDI_K_SNAP_HLEN 21 /* Total octets in 802.2 SNAP header */ | 33 | #define FDDI_K_SNAP_HLEN 21 /* Total octets in 802.2 SNAP header */ |
34 | #define FDDI_K_8022_ZLEN 16 /* Min octets in 802.2 frame sans FCS */ | 34 | #define FDDI_K_8022_ZLEN 16 /* Min octets in 802.2 frame sans FCS */ |
35 | #define FDDI_K_SNAP_ZLEN 21 /* Min octets in 802.2 SNAP frame sans FCS */ | 35 | #define FDDI_K_SNAP_ZLEN 21 /* Min octets in 802.2 SNAP frame sans FCS */ |
36 | #define FDDI_K_8022_DLEN 4475 /* Max octets in 802.2 payload */ | 36 | #define FDDI_K_8022_DLEN 4475 /* Max octets in 802.2 payload */ |
37 | #define FDDI_K_SNAP_DLEN 4470 /* Max octets in 802.2 SNAP payload */ | 37 | #define FDDI_K_SNAP_DLEN 4470 /* Max octets in 802.2 SNAP payload */ |
38 | #define FDDI_K_LLC_ZLEN 13 /* Min octets in LLC frame sans FCS */ | 38 | #define FDDI_K_LLC_ZLEN 13 /* Min octets in LLC frame sans FCS */ |
39 | #define FDDI_K_LLC_LEN 4491 /* Max octets in LLC frame sans FCS */ | 39 | #define FDDI_K_LLC_LEN 4491 /* Max octets in LLC frame sans FCS */ |
40 | 40 | ||
41 | /* Define FDDI Frame Control (FC) Byte values */ | 41 | /* Define FDDI Frame Control (FC) Byte values */ |
42 | #define FDDI_FC_K_VOID 0x00 | 42 | #define FDDI_FC_K_VOID 0x00 |
43 | #define FDDI_FC_K_NON_RESTRICTED_TOKEN 0x80 | 43 | #define FDDI_FC_K_NON_RESTRICTED_TOKEN 0x80 |
44 | #define FDDI_FC_K_RESTRICTED_TOKEN 0xC0 | 44 | #define FDDI_FC_K_RESTRICTED_TOKEN 0xC0 |
45 | #define FDDI_FC_K_SMT_MIN 0x41 | 45 | #define FDDI_FC_K_SMT_MIN 0x41 |
46 | #define FDDI_FC_K_SMT_MAX 0x4F | 46 | #define FDDI_FC_K_SMT_MAX 0x4F |
47 | #define FDDI_FC_K_MAC_MIN 0xC1 | 47 | #define FDDI_FC_K_MAC_MIN 0xC1 |
48 | #define FDDI_FC_K_MAC_MAX 0xCF | 48 | #define FDDI_FC_K_MAC_MAX 0xCF |
49 | #define FDDI_FC_K_ASYNC_LLC_MIN 0x50 | 49 | #define FDDI_FC_K_ASYNC_LLC_MIN 0x50 |
50 | #define FDDI_FC_K_ASYNC_LLC_DEF 0x54 | 50 | #define FDDI_FC_K_ASYNC_LLC_DEF 0x54 |
51 | #define FDDI_FC_K_ASYNC_LLC_MAX 0x5F | 51 | #define FDDI_FC_K_ASYNC_LLC_MAX 0x5F |
52 | #define FDDI_FC_K_SYNC_LLC_MIN 0xD0 | 52 | #define FDDI_FC_K_SYNC_LLC_MIN 0xD0 |
53 | #define FDDI_FC_K_SYNC_LLC_MAX 0xD7 | 53 | #define FDDI_FC_K_SYNC_LLC_MAX 0xD7 |
54 | #define FDDI_FC_K_IMPLEMENTOR_MIN 0x60 | 54 | #define FDDI_FC_K_IMPLEMENTOR_MIN 0x60 |
55 | #define FDDI_FC_K_IMPLEMENTOR_MAX 0x6F | 55 | #define FDDI_FC_K_IMPLEMENTOR_MAX 0x6F |
56 | #define FDDI_FC_K_RESERVED_MIN 0x70 | 56 | #define FDDI_FC_K_RESERVED_MIN 0x70 |
57 | #define FDDI_FC_K_RESERVED_MAX 0x7F | 57 | #define FDDI_FC_K_RESERVED_MAX 0x7F |
58 | 58 | ||
59 | /* Define LLC and SNAP constants */ | 59 | /* Define LLC and SNAP constants */ |
60 | #define FDDI_EXTENDED_SAP 0xAA | 60 | #define FDDI_EXTENDED_SAP 0xAA |
61 | #define FDDI_UI_CMD 0x03 | 61 | #define FDDI_UI_CMD 0x03 |
62 | 62 | ||
63 | /* Define 802.2 Type 1 header */ | 63 | /* Define 802.2 Type 1 header */ |
64 | struct fddi_8022_1_hdr | 64 | struct fddi_8022_1_hdr |
65 | { | 65 | { |
66 | __u8 dsap; /* destination service access point */ | 66 | __u8 dsap; /* destination service access point */ |
67 | __u8 ssap; /* source service access point */ | 67 | __u8 ssap; /* source service access point */ |
68 | __u8 ctrl; /* control byte #1 */ | 68 | __u8 ctrl; /* control byte #1 */ |
69 | } __attribute__ ((packed)); | 69 | } __attribute__ ((packed)); |
70 | 70 | ||
71 | /* Define 802.2 Type 2 header */ | 71 | /* Define 802.2 Type 2 header */ |
72 | struct fddi_8022_2_hdr | 72 | struct fddi_8022_2_hdr |
73 | { | 73 | { |
74 | __u8 dsap; /* destination service access point */ | 74 | __u8 dsap; /* destination service access point */ |
75 | __u8 ssap; /* source service access point */ | 75 | __u8 ssap; /* source service access point */ |
76 | __u8 ctrl_1; /* control byte #1 */ | 76 | __u8 ctrl_1; /* control byte #1 */ |
77 | __u8 ctrl_2; /* control byte #2 */ | 77 | __u8 ctrl_2; /* control byte #2 */ |
78 | } __attribute__ ((packed)); | 78 | } __attribute__ ((packed)); |
79 | 79 | ||
80 | /* Define 802.2 SNAP header */ | 80 | /* Define 802.2 SNAP header */ |
81 | #define FDDI_K_OUI_LEN 3 | 81 | #define FDDI_K_OUI_LEN 3 |
82 | struct fddi_snap_hdr | 82 | struct fddi_snap_hdr |
83 | { | 83 | { |
84 | __u8 dsap; /* always 0xAA */ | 84 | __u8 dsap; /* always 0xAA */ |
85 | __u8 ssap; /* always 0xAA */ | 85 | __u8 ssap; /* always 0xAA */ |
86 | __u8 ctrl; /* always 0x03 */ | 86 | __u8 ctrl; /* always 0x03 */ |
87 | __u8 oui[FDDI_K_OUI_LEN]; /* organizational universal id */ | 87 | __u8 oui[FDDI_K_OUI_LEN]; /* organizational universal id */ |
88 | __u16 ethertype; /* packet type ID field */ | 88 | __be16 ethertype; /* packet type ID field */ |
89 | } __attribute__ ((packed)); | 89 | } __attribute__ ((packed)); |
90 | 90 | ||
91 | /* Define FDDI LLC frame header */ | 91 | /* Define FDDI LLC frame header */ |
92 | struct fddihdr | 92 | struct fddihdr |
93 | { | 93 | { |
94 | __u8 fc; /* frame control */ | 94 | __u8 fc; /* frame control */ |
95 | __u8 daddr[FDDI_K_ALEN]; /* destination address */ | 95 | __u8 daddr[FDDI_K_ALEN]; /* destination address */ |
96 | __u8 saddr[FDDI_K_ALEN]; /* source address */ | 96 | __u8 saddr[FDDI_K_ALEN]; /* source address */ |
97 | union | 97 | union |
98 | { | 98 | { |
99 | struct fddi_8022_1_hdr llc_8022_1; | 99 | struct fddi_8022_1_hdr llc_8022_1; |
100 | struct fddi_8022_2_hdr llc_8022_2; | 100 | struct fddi_8022_2_hdr llc_8022_2; |
101 | struct fddi_snap_hdr llc_snap; | 101 | struct fddi_snap_hdr llc_snap; |
102 | } hdr; | 102 | } hdr; |
103 | } __attribute__ ((packed)); | 103 | } __attribute__ ((packed)); |
104 | 104 | ||
105 | /* Define FDDI statistics structure */ | 105 | /* Define FDDI statistics structure */ |
106 | struct fddi_statistics { | 106 | struct fddi_statistics { |
107 | 107 | ||
108 | /* Generic statistics. */ | 108 | /* Generic statistics. */ |
109 | 109 | ||
110 | struct net_device_stats gen; | 110 | struct net_device_stats gen; |
111 | 111 | ||
112 | /* Detailed FDDI statistics. Adopted from RFC 1512 */ | 112 | /* Detailed FDDI statistics. Adopted from RFC 1512 */ |
113 | 113 | ||
114 | __u8 smt_station_id[8]; | 114 | __u8 smt_station_id[8]; |
115 | __u32 smt_op_version_id; | 115 | __u32 smt_op_version_id; |
116 | __u32 smt_hi_version_id; | 116 | __u32 smt_hi_version_id; |
117 | __u32 smt_lo_version_id; | 117 | __u32 smt_lo_version_id; |
118 | __u8 smt_user_data[32]; | 118 | __u8 smt_user_data[32]; |
119 | __u32 smt_mib_version_id; | 119 | __u32 smt_mib_version_id; |
120 | __u32 smt_mac_cts; | 120 | __u32 smt_mac_cts; |
121 | __u32 smt_non_master_cts; | 121 | __u32 smt_non_master_cts; |
122 | __u32 smt_master_cts; | 122 | __u32 smt_master_cts; |
123 | __u32 smt_available_paths; | 123 | __u32 smt_available_paths; |
124 | __u32 smt_config_capabilities; | 124 | __u32 smt_config_capabilities; |
125 | __u32 smt_config_policy; | 125 | __u32 smt_config_policy; |
126 | __u32 smt_connection_policy; | 126 | __u32 smt_connection_policy; |
127 | __u32 smt_t_notify; | 127 | __u32 smt_t_notify; |
128 | __u32 smt_stat_rpt_policy; | 128 | __u32 smt_stat_rpt_policy; |
129 | __u32 smt_trace_max_expiration; | 129 | __u32 smt_trace_max_expiration; |
130 | __u32 smt_bypass_present; | 130 | __u32 smt_bypass_present; |
131 | __u32 smt_ecm_state; | 131 | __u32 smt_ecm_state; |
132 | __u32 smt_cf_state; | 132 | __u32 smt_cf_state; |
133 | __u32 smt_remote_disconnect_flag; | 133 | __u32 smt_remote_disconnect_flag; |
134 | __u32 smt_station_status; | 134 | __u32 smt_station_status; |
135 | __u32 smt_peer_wrap_flag; | 135 | __u32 smt_peer_wrap_flag; |
136 | __u32 smt_time_stamp; | 136 | __u32 smt_time_stamp; |
137 | __u32 smt_transition_time_stamp; | 137 | __u32 smt_transition_time_stamp; |
138 | __u32 mac_frame_status_functions; | 138 | __u32 mac_frame_status_functions; |
139 | __u32 mac_t_max_capability; | 139 | __u32 mac_t_max_capability; |
140 | __u32 mac_tvx_capability; | 140 | __u32 mac_tvx_capability; |
141 | __u32 mac_available_paths; | 141 | __u32 mac_available_paths; |
142 | __u32 mac_current_path; | 142 | __u32 mac_current_path; |
143 | __u8 mac_upstream_nbr[FDDI_K_ALEN]; | 143 | __u8 mac_upstream_nbr[FDDI_K_ALEN]; |
144 | __u8 mac_downstream_nbr[FDDI_K_ALEN]; | 144 | __u8 mac_downstream_nbr[FDDI_K_ALEN]; |
145 | __u8 mac_old_upstream_nbr[FDDI_K_ALEN]; | 145 | __u8 mac_old_upstream_nbr[FDDI_K_ALEN]; |
146 | __u8 mac_old_downstream_nbr[FDDI_K_ALEN]; | 146 | __u8 mac_old_downstream_nbr[FDDI_K_ALEN]; |
147 | __u32 mac_dup_address_test; | 147 | __u32 mac_dup_address_test; |
148 | __u32 mac_requested_paths; | 148 | __u32 mac_requested_paths; |
149 | __u32 mac_downstream_port_type; | 149 | __u32 mac_downstream_port_type; |
150 | __u8 mac_smt_address[FDDI_K_ALEN]; | 150 | __u8 mac_smt_address[FDDI_K_ALEN]; |
151 | __u32 mac_t_req; | 151 | __u32 mac_t_req; |
152 | __u32 mac_t_neg; | 152 | __u32 mac_t_neg; |
153 | __u32 mac_t_max; | 153 | __u32 mac_t_max; |
154 | __u32 mac_tvx_value; | 154 | __u32 mac_tvx_value; |
155 | __u32 mac_frame_cts; | 155 | __u32 mac_frame_cts; |
156 | __u32 mac_copied_cts; | 156 | __u32 mac_copied_cts; |
157 | __u32 mac_transmit_cts; | 157 | __u32 mac_transmit_cts; |
158 | __u32 mac_error_cts; | 158 | __u32 mac_error_cts; |
159 | __u32 mac_lost_cts; | 159 | __u32 mac_lost_cts; |
160 | __u32 mac_frame_error_threshold; | 160 | __u32 mac_frame_error_threshold; |
161 | __u32 mac_frame_error_ratio; | 161 | __u32 mac_frame_error_ratio; |
162 | __u32 mac_rmt_state; | 162 | __u32 mac_rmt_state; |
163 | __u32 mac_da_flag; | 163 | __u32 mac_da_flag; |
164 | __u32 mac_una_da_flag; | 164 | __u32 mac_una_da_flag; |
165 | __u32 mac_frame_error_flag; | 165 | __u32 mac_frame_error_flag; |
166 | __u32 mac_ma_unitdata_available; | 166 | __u32 mac_ma_unitdata_available; |
167 | __u32 mac_hardware_present; | 167 | __u32 mac_hardware_present; |
168 | __u32 mac_ma_unitdata_enable; | 168 | __u32 mac_ma_unitdata_enable; |
169 | __u32 path_tvx_lower_bound; | 169 | __u32 path_tvx_lower_bound; |
170 | __u32 path_t_max_lower_bound; | 170 | __u32 path_t_max_lower_bound; |
171 | __u32 path_max_t_req; | 171 | __u32 path_max_t_req; |
172 | __u32 path_configuration[8]; | 172 | __u32 path_configuration[8]; |
173 | __u32 port_my_type[2]; | 173 | __u32 port_my_type[2]; |
174 | __u32 port_neighbor_type[2]; | 174 | __u32 port_neighbor_type[2]; |
175 | __u32 port_connection_policies[2]; | 175 | __u32 port_connection_policies[2]; |
176 | __u32 port_mac_indicated[2]; | 176 | __u32 port_mac_indicated[2]; |
177 | __u32 port_current_path[2]; | 177 | __u32 port_current_path[2]; |
178 | __u8 port_requested_paths[3*2]; | 178 | __u8 port_requested_paths[3*2]; |
179 | __u32 port_mac_placement[2]; | 179 | __u32 port_mac_placement[2]; |
180 | __u32 port_available_paths[2]; | 180 | __u32 port_available_paths[2]; |
181 | __u32 port_pmd_class[2]; | 181 | __u32 port_pmd_class[2]; |
182 | __u32 port_connection_capabilities[2]; | 182 | __u32 port_connection_capabilities[2]; |
183 | __u32 port_bs_flag[2]; | 183 | __u32 port_bs_flag[2]; |
184 | __u32 port_lct_fail_cts[2]; | 184 | __u32 port_lct_fail_cts[2]; |
185 | __u32 port_ler_estimate[2]; | 185 | __u32 port_ler_estimate[2]; |
186 | __u32 port_lem_reject_cts[2]; | 186 | __u32 port_lem_reject_cts[2]; |
187 | __u32 port_lem_cts[2]; | 187 | __u32 port_lem_cts[2]; |
188 | __u32 port_ler_cutoff[2]; | 188 | __u32 port_ler_cutoff[2]; |
189 | __u32 port_ler_alarm[2]; | 189 | __u32 port_ler_alarm[2]; |
190 | __u32 port_connect_state[2]; | 190 | __u32 port_connect_state[2]; |
191 | __u32 port_pcm_state[2]; | 191 | __u32 port_pcm_state[2]; |
192 | __u32 port_pc_withhold[2]; | 192 | __u32 port_pc_withhold[2]; |
193 | __u32 port_ler_flag[2]; | 193 | __u32 port_ler_flag[2]; |
194 | __u32 port_hardware_present[2]; | 194 | __u32 port_hardware_present[2]; |
195 | }; | 195 | }; |
196 | 196 | ||
197 | #endif /* _LINUX_IF_FDDI_H */ | 197 | #endif /* _LINUX_IF_FDDI_H */ |
198 | 198 |
include/linux/if_hippi.h
1 | /* | 1 | /* |
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
3 | * operating system. INET is implemented using the BSD Socket | 3 | * operating system. INET is implemented using the BSD Socket |
4 | * interface as the means of communication with the user level. | 4 | * interface as the means of communication with the user level. |
5 | * | 5 | * |
6 | * Global definitions for the HIPPI interface. | 6 | * Global definitions for the HIPPI interface. |
7 | * | 7 | * |
8 | * Version: @(#)if_hippi.h 1.0.0 05/26/97 | 8 | * Version: @(#)if_hippi.h 1.0.0 05/26/97 |
9 | * | 9 | * |
10 | * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | 10 | * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
11 | * Donald Becker, <becker@super.org> | 11 | * Donald Becker, <becker@super.org> |
12 | * Alan Cox, <alan@redhat.com> | 12 | * Alan Cox, <alan@redhat.com> |
13 | * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> | 13 | * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> |
14 | * Jes Sorensen, <Jes.Sorensen@cern.ch> | 14 | * Jes Sorensen, <Jes.Sorensen@cern.ch> |
15 | * | 15 | * |
16 | * This program is free software; you can redistribute it and/or | 16 | * This program is free software; you can redistribute it and/or |
17 | * modify it under the terms of the GNU General Public License | 17 | * modify it under the terms of the GNU General Public License |
18 | * as published by the Free Software Foundation; either version | 18 | * as published by the Free Software Foundation; either version |
19 | * 2 of the License, or (at your option) any later version. | 19 | * 2 of the License, or (at your option) any later version. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef _LINUX_IF_HIPPI_H | 22 | #ifndef _LINUX_IF_HIPPI_H |
23 | #define _LINUX_IF_HIPPI_H | 23 | #define _LINUX_IF_HIPPI_H |
24 | 24 | ||
25 | #include <asm/byteorder.h> | 25 | #include <asm/byteorder.h> |
26 | 26 | ||
27 | /* | 27 | /* |
28 | * HIPPI magic constants. | 28 | * HIPPI magic constants. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #define HIPPI_ALEN 6 /* Bytes in one HIPPI hw-addr */ | 31 | #define HIPPI_ALEN 6 /* Bytes in one HIPPI hw-addr */ |
32 | #define HIPPI_HLEN sizeof(struct hippi_hdr) | 32 | #define HIPPI_HLEN sizeof(struct hippi_hdr) |
33 | #define HIPPI_ZLEN 0 /* Min. bytes in frame without FCS */ | 33 | #define HIPPI_ZLEN 0 /* Min. bytes in frame without FCS */ |
34 | #define HIPPI_DATA_LEN 65280 /* Max. bytes in payload */ | 34 | #define HIPPI_DATA_LEN 65280 /* Max. bytes in payload */ |
35 | #define HIPPI_FRAME_LEN (HIPPI_DATA_LEN + HIPPI_HLEN) | 35 | #define HIPPI_FRAME_LEN (HIPPI_DATA_LEN + HIPPI_HLEN) |
36 | /* Max. bytes in frame without FCS */ | 36 | /* Max. bytes in frame without FCS */ |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Define LLC and SNAP constants. | 39 | * Define LLC and SNAP constants. |
40 | */ | 40 | */ |
41 | #define HIPPI_EXTENDED_SAP 0xAA | 41 | #define HIPPI_EXTENDED_SAP 0xAA |
42 | #define HIPPI_UI_CMD 0x03 | 42 | #define HIPPI_UI_CMD 0x03 |
43 | 43 | ||
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Do we need to list some sort of ID's here? | 46 | * Do we need to list some sort of ID's here? |
47 | */ | 47 | */ |
48 | 48 | ||
49 | /* | 49 | /* |
50 | * HIPPI statistics collection data. | 50 | * HIPPI statistics collection data. |
51 | */ | 51 | */ |
52 | 52 | ||
53 | struct hipnet_statistics | 53 | struct hipnet_statistics |
54 | { | 54 | { |
55 | int rx_packets; /* total packets received */ | 55 | int rx_packets; /* total packets received */ |
56 | int tx_packets; /* total packets transmitted */ | 56 | int tx_packets; /* total packets transmitted */ |
57 | int rx_errors; /* bad packets received */ | 57 | int rx_errors; /* bad packets received */ |
58 | int tx_errors; /* packet transmit problems */ | 58 | int tx_errors; /* packet transmit problems */ |
59 | int rx_dropped; /* no space in linux buffers */ | 59 | int rx_dropped; /* no space in linux buffers */ |
60 | int tx_dropped; /* no space available in linux */ | 60 | int tx_dropped; /* no space available in linux */ |
61 | 61 | ||
62 | /* detailed rx_errors: */ | 62 | /* detailed rx_errors: */ |
63 | int rx_length_errors; | 63 | int rx_length_errors; |
64 | int rx_over_errors; /* receiver ring buff overflow */ | 64 | int rx_over_errors; /* receiver ring buff overflow */ |
65 | int rx_crc_errors; /* recved pkt with crc error */ | 65 | int rx_crc_errors; /* recved pkt with crc error */ |
66 | int rx_frame_errors; /* recv'd frame alignment error */ | 66 | int rx_frame_errors; /* recv'd frame alignment error */ |
67 | int rx_fifo_errors; /* recv'r fifo overrun */ | 67 | int rx_fifo_errors; /* recv'r fifo overrun */ |
68 | int rx_missed_errors; /* receiver missed packet */ | 68 | int rx_missed_errors; /* receiver missed packet */ |
69 | 69 | ||
70 | /* detailed tx_errors */ | 70 | /* detailed tx_errors */ |
71 | int tx_aborted_errors; | 71 | int tx_aborted_errors; |
72 | int tx_carrier_errors; | 72 | int tx_carrier_errors; |
73 | int tx_fifo_errors; | 73 | int tx_fifo_errors; |
74 | int tx_heartbeat_errors; | 74 | int tx_heartbeat_errors; |
75 | int tx_window_errors; | 75 | int tx_window_errors; |
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | struct hippi_fp_hdr | 79 | struct hippi_fp_hdr |
80 | { | 80 | { |
81 | #if 0 | 81 | #if 0 |
82 | __u8 ulp; /* must contain 4 */ | 82 | __u8 ulp; /* must contain 4 */ |
83 | #if defined (__BIG_ENDIAN_BITFIELD) | 83 | #if defined (__BIG_ENDIAN_BITFIELD) |
84 | __u8 d1_data_present:1; /* must be 1 */ | 84 | __u8 d1_data_present:1; /* must be 1 */ |
85 | __u8 start_d2_burst_boundary:1; /* must be zero */ | 85 | __u8 start_d2_burst_boundary:1; /* must be zero */ |
86 | __u8 reserved:6; /* must be zero */ | 86 | __u8 reserved:6; /* must be zero */ |
87 | #if 0 | 87 | #if 0 |
88 | __u16 reserved1:5; | 88 | __u16 reserved1:5; |
89 | __u16 d1_area_size:8; /* must be 3 */ | 89 | __u16 d1_area_size:8; /* must be 3 */ |
90 | __u16 d2_offset:3; /* must be zero */ | 90 | __u16 d2_offset:3; /* must be zero */ |
91 | #endif | 91 | #endif |
92 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | 92 | #elif defined(__LITTLE_ENDIAN_BITFIELD) |
93 | __u8 reserved:6; /* must be zero */ | 93 | __u8 reserved:6; /* must be zero */ |
94 | __u8 start_d2_burst_boundary:1; /* must be zero */ | 94 | __u8 start_d2_burst_boundary:1; /* must be zero */ |
95 | __u8 d1_data_present:1; /* must be 1 */ | 95 | __u8 d1_data_present:1; /* must be 1 */ |
96 | #if 0 | 96 | #if 0 |
97 | __u16 d2_offset:3; /* must be zero */ | 97 | __u16 d2_offset:3; /* must be zero */ |
98 | __u16 d1_area_size:8; /* must be 3 */ | 98 | __u16 d1_area_size:8; /* must be 3 */ |
99 | __u16 reserved1:5; /* must be zero */ | 99 | __u16 reserved1:5; /* must be zero */ |
100 | #endif | 100 | #endif |
101 | #else | 101 | #else |
102 | #error "Please fix <asm/byteorder.h>" | 102 | #error "Please fix <asm/byteorder.h>" |
103 | #endif | 103 | #endif |
104 | #else | 104 | #else |
105 | __u32 fixed; | 105 | __be32 fixed; |
106 | #endif | 106 | #endif |
107 | __u32 d2_size; | 107 | __be32 d2_size; |
108 | } __attribute__ ((packed)); | 108 | } __attribute__ ((packed)); |
109 | 109 | ||
110 | struct hippi_le_hdr | 110 | struct hippi_le_hdr |
111 | { | 111 | { |
112 | #if defined (__BIG_ENDIAN_BITFIELD) | 112 | #if defined (__BIG_ENDIAN_BITFIELD) |
113 | __u8 fc:3; | 113 | __u8 fc:3; |
114 | __u8 double_wide:1; | 114 | __u8 double_wide:1; |
115 | __u8 message_type:4; | 115 | __u8 message_type:4; |
116 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | 116 | #elif defined(__LITTLE_ENDIAN_BITFIELD) |
117 | __u8 message_type:4; | 117 | __u8 message_type:4; |
118 | __u8 double_wide:1; | 118 | __u8 double_wide:1; |
119 | __u8 fc:3; | 119 | __u8 fc:3; |
120 | #endif | 120 | #endif |
121 | __u8 dest_switch_addr[3]; | 121 | __u8 dest_switch_addr[3]; |
122 | #if defined (__BIG_ENDIAN_BITFIELD) | 122 | #if defined (__BIG_ENDIAN_BITFIELD) |
123 | __u8 dest_addr_type:4, | 123 | __u8 dest_addr_type:4, |
124 | src_addr_type:4; | 124 | src_addr_type:4; |
125 | #elif defined(__LITTLE_ENDIAN_BITFIELD) | 125 | #elif defined(__LITTLE_ENDIAN_BITFIELD) |
126 | __u8 src_addr_type:4, | 126 | __u8 src_addr_type:4, |
127 | dest_addr_type:4; | 127 | dest_addr_type:4; |
128 | #endif | 128 | #endif |
129 | __u8 src_switch_addr[3]; | 129 | __u8 src_switch_addr[3]; |
130 | __u16 reserved; | 130 | __u16 reserved; |
131 | __u8 daddr[HIPPI_ALEN]; | 131 | __u8 daddr[HIPPI_ALEN]; |
132 | __u16 locally_administered; | 132 | __u16 locally_administered; |
133 | __u8 saddr[HIPPI_ALEN]; | 133 | __u8 saddr[HIPPI_ALEN]; |
134 | } __attribute__ ((packed)); | 134 | } __attribute__ ((packed)); |
135 | 135 | ||
136 | #define HIPPI_OUI_LEN 3 | 136 | #define HIPPI_OUI_LEN 3 |
137 | /* | 137 | /* |
138 | * Looks like the dsap and ssap fields have been swapped by mistake in | 138 | * Looks like the dsap and ssap fields have been swapped by mistake in |
139 | * RFC 2067 "IP over HIPPI". | 139 | * RFC 2067 "IP over HIPPI". |
140 | */ | 140 | */ |
141 | struct hippi_snap_hdr | 141 | struct hippi_snap_hdr |
142 | { | 142 | { |
143 | __u8 dsap; /* always 0xAA */ | 143 | __u8 dsap; /* always 0xAA */ |
144 | __u8 ssap; /* always 0xAA */ | 144 | __u8 ssap; /* always 0xAA */ |
145 | __u8 ctrl; /* always 0x03 */ | 145 | __u8 ctrl; /* always 0x03 */ |
146 | __u8 oui[HIPPI_OUI_LEN]; /* organizational universal id (zero)*/ | 146 | __u8 oui[HIPPI_OUI_LEN]; /* organizational universal id (zero)*/ |
147 | __u16 ethertype; /* packet type ID field */ | 147 | __be16 ethertype; /* packet type ID field */ |
148 | } __attribute__ ((packed)); | 148 | } __attribute__ ((packed)); |
149 | 149 | ||
150 | struct hippi_hdr | 150 | struct hippi_hdr |
151 | { | 151 | { |
152 | struct hippi_fp_hdr fp; | 152 | struct hippi_fp_hdr fp; |
153 | struct hippi_le_hdr le; | 153 | struct hippi_le_hdr le; |
154 | struct hippi_snap_hdr snap; | 154 | struct hippi_snap_hdr snap; |
155 | } __attribute__ ((packed)); | 155 | } __attribute__ ((packed)); |
156 | 156 | ||
157 | #endif /* _LINUX_IF_HIPPI_H */ | 157 | #endif /* _LINUX_IF_HIPPI_H */ |
158 | 158 |
net/802/fc.c
1 | /* | 1 | /* |
2 | * NET3: Fibre Channel device handling subroutines | 2 | * NET3: Fibre Channel device handling subroutines |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or | 4 | * This program is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU General Public License | 5 | * modify it under the terms of the GNU General Public License |
6 | * as published by the Free Software Foundation; either version | 6 | * as published by the Free Software Foundation; either version |
7 | * 2 of the License, or (at your option) any later version. | 7 | * 2 of the License, or (at your option) any later version. |
8 | * | 8 | * |
9 | * Vineet Abraham <vma@iol.unh.edu> | 9 | * Vineet Abraham <vma@iol.unh.edu> |
10 | * v 1.0 03/22/99 | 10 | * v 1.0 03/22/99 |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/config.h> | 13 | #include <linux/config.h> |
14 | #include <asm/uaccess.h> | 14 | #include <asm/uaccess.h> |
15 | #include <asm/system.h> | 15 | #include <asm/system.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/mm.h> | 20 | #include <linux/mm.h> |
21 | #include <linux/socket.h> | 21 | #include <linux/socket.h> |
22 | #include <linux/in.h> | 22 | #include <linux/in.h> |
23 | #include <linux/inet.h> | 23 | #include <linux/inet.h> |
24 | #include <linux/netdevice.h> | 24 | #include <linux/netdevice.h> |
25 | #include <linux/fcdevice.h> | 25 | #include <linux/fcdevice.h> |
26 | #include <linux/skbuff.h> | 26 | #include <linux/skbuff.h> |
27 | #include <linux/errno.h> | 27 | #include <linux/errno.h> |
28 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
29 | #include <linux/net.h> | 29 | #include <linux/net.h> |
30 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <net/arp.h> | 32 | #include <net/arp.h> |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Put the headers on a Fibre Channel packet. | 35 | * Put the headers on a Fibre Channel packet. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | static int fc_header(struct sk_buff *skb, struct net_device *dev, | 38 | static int fc_header(struct sk_buff *skb, struct net_device *dev, |
39 | unsigned short type, | 39 | unsigned short type, |
40 | void *daddr, void *saddr, unsigned len) | 40 | void *daddr, void *saddr, unsigned len) |
41 | { | 41 | { |
42 | struct fch_hdr *fch; | 42 | struct fch_hdr *fch; |
43 | int hdr_len; | 43 | int hdr_len; |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Add the 802.2 SNAP header if IP as the IPv4 code calls | 46 | * Add the 802.2 SNAP header if IP as the IPv4 code calls |
47 | * dev->hard_header directly. | 47 | * dev->hard_header directly. |
48 | */ | 48 | */ |
49 | if (type == ETH_P_IP || type == ETH_P_ARP) | 49 | if (type == ETH_P_IP || type == ETH_P_ARP) |
50 | { | 50 | { |
51 | struct fcllc *fcllc; | 51 | struct fcllc *fcllc; |
52 | 52 | ||
53 | hdr_len = sizeof(struct fch_hdr) + sizeof(struct fcllc); | 53 | hdr_len = sizeof(struct fch_hdr) + sizeof(struct fcllc); |
54 | fch = (struct fch_hdr *)skb_push(skb, hdr_len); | 54 | fch = (struct fch_hdr *)skb_push(skb, hdr_len); |
55 | fcllc = (struct fcllc *)(fch+1); | 55 | fcllc = (struct fcllc *)(fch+1); |
56 | fcllc->dsap = fcllc->ssap = EXTENDED_SAP; | 56 | fcllc->dsap = fcllc->ssap = EXTENDED_SAP; |
57 | fcllc->llc = UI_CMD; | 57 | fcllc->llc = UI_CMD; |
58 | fcllc->protid[0] = fcllc->protid[1] = fcllc->protid[2] = 0x00; | 58 | fcllc->protid[0] = fcllc->protid[1] = fcllc->protid[2] = 0x00; |
59 | fcllc->ethertype = htons(type); | 59 | fcllc->ethertype = htons(type); |
60 | } | 60 | } |
61 | else | 61 | else |
62 | { | 62 | { |
63 | hdr_len = sizeof(struct fch_hdr); | 63 | hdr_len = sizeof(struct fch_hdr); |
64 | fch = (struct fch_hdr *)skb_push(skb, hdr_len); | 64 | fch = (struct fch_hdr *)skb_push(skb, hdr_len); |
65 | } | 65 | } |
66 | 66 | ||
67 | if(saddr) | 67 | if(saddr) |
68 | memcpy(fch->saddr,saddr,dev->addr_len); | 68 | memcpy(fch->saddr,saddr,dev->addr_len); |
69 | else | 69 | else |
70 | memcpy(fch->saddr,dev->dev_addr,dev->addr_len); | 70 | memcpy(fch->saddr,dev->dev_addr,dev->addr_len); |
71 | 71 | ||
72 | if(daddr) | 72 | if(daddr) |
73 | { | 73 | { |
74 | memcpy(fch->daddr,daddr,dev->addr_len); | 74 | memcpy(fch->daddr,daddr,dev->addr_len); |
75 | return(hdr_len); | 75 | return(hdr_len); |
76 | } | 76 | } |
77 | return -hdr_len; | 77 | return -hdr_len; |
78 | } | 78 | } |
79 | 79 | ||
80 | /* | 80 | /* |
81 | * A neighbour discovery of some species (eg arp) has completed. We | 81 | * A neighbour discovery of some species (eg arp) has completed. We |
82 | * can now send the packet. | 82 | * can now send the packet. |
83 | */ | 83 | */ |
84 | 84 | ||
85 | static int fc_rebuild_header(struct sk_buff *skb) | 85 | static int fc_rebuild_header(struct sk_buff *skb) |
86 | { | 86 | { |
87 | struct fch_hdr *fch=(struct fch_hdr *)skb->data; | 87 | struct fch_hdr *fch=(struct fch_hdr *)skb->data; |
88 | struct fcllc *fcllc=(struct fcllc *)(skb->data+sizeof(struct fch_hdr)); | 88 | struct fcllc *fcllc=(struct fcllc *)(skb->data+sizeof(struct fch_hdr)); |
89 | if(fcllc->ethertype != htons(ETH_P_IP)) { | 89 | if(fcllc->ethertype != htons(ETH_P_IP)) { |
90 | printk("fc_rebuild_header: Don't know how to resolve type %04X addresses ?\n",(unsigned int)htons(fcllc->ethertype)); | 90 | printk("fc_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(fcllc->ethertype)); |
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | #ifdef CONFIG_INET | 93 | #ifdef CONFIG_INET |
94 | return arp_find(fch->daddr, skb); | 94 | return arp_find(fch->daddr, skb); |
95 | #else | 95 | #else |
96 | return 0; | 96 | return 0; |
97 | #endif | 97 | #endif |
98 | } | 98 | } |
99 | 99 | ||
100 | static void fc_setup(struct net_device *dev) | 100 | static void fc_setup(struct net_device *dev) |
101 | { | 101 | { |
102 | dev->hard_header = fc_header; | 102 | dev->hard_header = fc_header; |
103 | dev->rebuild_header = fc_rebuild_header; | 103 | dev->rebuild_header = fc_rebuild_header; |
104 | 104 | ||
105 | dev->type = ARPHRD_IEEE802; | 105 | dev->type = ARPHRD_IEEE802; |
106 | dev->hard_header_len = FC_HLEN; | 106 | dev->hard_header_len = FC_HLEN; |
107 | dev->mtu = 2024; | 107 | dev->mtu = 2024; |
108 | dev->addr_len = FC_ALEN; | 108 | dev->addr_len = FC_ALEN; |
109 | dev->tx_queue_len = 100; /* Long queues on fc */ | 109 | dev->tx_queue_len = 100; /* Long queues on fc */ |
110 | dev->flags = IFF_BROADCAST; | 110 | dev->flags = IFF_BROADCAST; |
111 | 111 | ||
112 | memset(dev->broadcast, 0xFF, FC_ALEN); | 112 | memset(dev->broadcast, 0xFF, FC_ALEN); |
113 | } | 113 | } |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * alloc_fcdev - Register fibre channel device | 116 | * alloc_fcdev - Register fibre channel device |
117 | * @sizeof_priv: Size of additional driver-private structure to be allocated | 117 | * @sizeof_priv: Size of additional driver-private structure to be allocated |
118 | * for this fibre channel device | 118 | * for this fibre channel device |
119 | * | 119 | * |
120 | * Fill in the fields of the device structure with fibre channel-generic values. | 120 | * Fill in the fields of the device structure with fibre channel-generic values. |
121 | * | 121 | * |
122 | * Constructs a new net device, complete with a private data area of | 122 | * Constructs a new net device, complete with a private data area of |
123 | * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for | 123 | * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for |
124 | * this private data area. | 124 | * this private data area. |
125 | */ | 125 | */ |
126 | struct net_device *alloc_fcdev(int sizeof_priv) | 126 | struct net_device *alloc_fcdev(int sizeof_priv) |
127 | { | 127 | { |
128 | return alloc_netdev(sizeof_priv, "fc%d", fc_setup); | 128 | return alloc_netdev(sizeof_priv, "fc%d", fc_setup); |
129 | } | 129 | } |
130 | EXPORT_SYMBOL(alloc_fcdev); | 130 | EXPORT_SYMBOL(alloc_fcdev); |
131 | 131 |
net/802/fddi.c
1 | /* | 1 | /* |
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
3 | * operating system. INET is implemented using the BSD Socket | 3 | * operating system. INET is implemented using the BSD Socket |
4 | * interface as the means of communication with the user level. | 4 | * interface as the means of communication with the user level. |
5 | * | 5 | * |
6 | * FDDI-type device handling. | 6 | * FDDI-type device handling. |
7 | * | 7 | * |
8 | * Version: @(#)fddi.c 1.0.0 08/12/96 | 8 | * Version: @(#)fddi.c 1.0.0 08/12/96 |
9 | * | 9 | * |
10 | * Authors: Lawrence V. Stefani, <stefani@lkg.dec.com> | 10 | * Authors: Lawrence V. Stefani, <stefani@lkg.dec.com> |
11 | * | 11 | * |
12 | * fddi.c is based on previous eth.c and tr.c work by | 12 | * fddi.c is based on previous eth.c and tr.c work by |
13 | * Ross Biro | 13 | * Ross Biro |
14 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | 14 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
15 | * Mark Evans, <evansmp@uhura.aston.ac.uk> | 15 | * Mark Evans, <evansmp@uhura.aston.ac.uk> |
16 | * Florian La Roche, <rzsfl@rz.uni-sb.de> | 16 | * Florian La Roche, <rzsfl@rz.uni-sb.de> |
17 | * Alan Cox, <gw4pts@gw4pts.ampr.org> | 17 | * Alan Cox, <gw4pts@gw4pts.ampr.org> |
18 | * | 18 | * |
19 | * This program is free software; you can redistribute it and/or | 19 | * This program is free software; you can redistribute it and/or |
20 | * modify it under the terms of the GNU General Public License | 20 | * modify it under the terms of the GNU General Public License |
21 | * as published by the Free Software Foundation; either version | 21 | * as published by the Free Software Foundation; either version |
22 | * 2 of the License, or (at your option) any later version. | 22 | * 2 of the License, or (at your option) any later version. |
23 | * | 23 | * |
24 | * Changes | 24 | * Changes |
25 | * Alan Cox : New arp/rebuild header | 25 | * Alan Cox : New arp/rebuild header |
26 | * Maciej W. Rozycki : IPv6 support | 26 | * Maciej W. Rozycki : IPv6 support |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/config.h> | 29 | #include <linux/config.h> |
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <asm/system.h> | 31 | #include <asm/system.h> |
32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
35 | #include <linux/string.h> | 35 | #include <linux/string.h> |
36 | #include <linux/mm.h> | 36 | #include <linux/mm.h> |
37 | #include <linux/socket.h> | 37 | #include <linux/socket.h> |
38 | #include <linux/in.h> | 38 | #include <linux/in.h> |
39 | #include <linux/inet.h> | 39 | #include <linux/inet.h> |
40 | #include <linux/netdevice.h> | 40 | #include <linux/netdevice.h> |
41 | #include <linux/fddidevice.h> | 41 | #include <linux/fddidevice.h> |
42 | #include <linux/if_ether.h> | 42 | #include <linux/if_ether.h> |
43 | #include <linux/skbuff.h> | 43 | #include <linux/skbuff.h> |
44 | #include <linux/errno.h> | 44 | #include <linux/errno.h> |
45 | #include <net/arp.h> | 45 | #include <net/arp.h> |
46 | #include <net/sock.h> | 46 | #include <net/sock.h> |
47 | 47 | ||
48 | /* | 48 | /* |
49 | * Create the FDDI MAC header for an arbitrary protocol layer | 49 | * Create the FDDI MAC header for an arbitrary protocol layer |
50 | * | 50 | * |
51 | * saddr=NULL means use device source address | 51 | * saddr=NULL means use device source address |
52 | * daddr=NULL means leave destination address (eg unresolved arp) | 52 | * daddr=NULL means leave destination address (eg unresolved arp) |
53 | */ | 53 | */ |
54 | 54 | ||
55 | static int fddi_header(struct sk_buff *skb, struct net_device *dev, | 55 | static int fddi_header(struct sk_buff *skb, struct net_device *dev, |
56 | unsigned short type, | 56 | unsigned short type, |
57 | void *daddr, void *saddr, unsigned len) | 57 | void *daddr, void *saddr, unsigned len) |
58 | { | 58 | { |
59 | int hl = FDDI_K_SNAP_HLEN; | 59 | int hl = FDDI_K_SNAP_HLEN; |
60 | struct fddihdr *fddi; | 60 | struct fddihdr *fddi; |
61 | 61 | ||
62 | if(type != ETH_P_IP && type != ETH_P_IPV6 && type != ETH_P_ARP) | 62 | if(type != ETH_P_IP && type != ETH_P_IPV6 && type != ETH_P_ARP) |
63 | hl=FDDI_K_8022_HLEN-3; | 63 | hl=FDDI_K_8022_HLEN-3; |
64 | fddi = (struct fddihdr *)skb_push(skb, hl); | 64 | fddi = (struct fddihdr *)skb_push(skb, hl); |
65 | fddi->fc = FDDI_FC_K_ASYNC_LLC_DEF; | 65 | fddi->fc = FDDI_FC_K_ASYNC_LLC_DEF; |
66 | if(type == ETH_P_IP || type == ETH_P_IPV6 || type == ETH_P_ARP) | 66 | if(type == ETH_P_IP || type == ETH_P_IPV6 || type == ETH_P_ARP) |
67 | { | 67 | { |
68 | fddi->hdr.llc_snap.dsap = FDDI_EXTENDED_SAP; | 68 | fddi->hdr.llc_snap.dsap = FDDI_EXTENDED_SAP; |
69 | fddi->hdr.llc_snap.ssap = FDDI_EXTENDED_SAP; | 69 | fddi->hdr.llc_snap.ssap = FDDI_EXTENDED_SAP; |
70 | fddi->hdr.llc_snap.ctrl = FDDI_UI_CMD; | 70 | fddi->hdr.llc_snap.ctrl = FDDI_UI_CMD; |
71 | fddi->hdr.llc_snap.oui[0] = 0x00; | 71 | fddi->hdr.llc_snap.oui[0] = 0x00; |
72 | fddi->hdr.llc_snap.oui[1] = 0x00; | 72 | fddi->hdr.llc_snap.oui[1] = 0x00; |
73 | fddi->hdr.llc_snap.oui[2] = 0x00; | 73 | fddi->hdr.llc_snap.oui[2] = 0x00; |
74 | fddi->hdr.llc_snap.ethertype = htons(type); | 74 | fddi->hdr.llc_snap.ethertype = htons(type); |
75 | } | 75 | } |
76 | 76 | ||
77 | /* Set the source and destination hardware addresses */ | 77 | /* Set the source and destination hardware addresses */ |
78 | 78 | ||
79 | if (saddr != NULL) | 79 | if (saddr != NULL) |
80 | memcpy(fddi->saddr, saddr, dev->addr_len); | 80 | memcpy(fddi->saddr, saddr, dev->addr_len); |
81 | else | 81 | else |
82 | memcpy(fddi->saddr, dev->dev_addr, dev->addr_len); | 82 | memcpy(fddi->saddr, dev->dev_addr, dev->addr_len); |
83 | 83 | ||
84 | if (daddr != NULL) | 84 | if (daddr != NULL) |
85 | { | 85 | { |
86 | memcpy(fddi->daddr, daddr, dev->addr_len); | 86 | memcpy(fddi->daddr, daddr, dev->addr_len); |
87 | return(hl); | 87 | return(hl); |
88 | } | 88 | } |
89 | 89 | ||
90 | return(-hl); | 90 | return(-hl); |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | /* | 94 | /* |
95 | * Rebuild the FDDI MAC header. This is called after an ARP | 95 | * Rebuild the FDDI MAC header. This is called after an ARP |
96 | * (or in future other address resolution) has completed on | 96 | * (or in future other address resolution) has completed on |
97 | * this sk_buff. We now let ARP fill in the other fields. | 97 | * this sk_buff. We now let ARP fill in the other fields. |
98 | */ | 98 | */ |
99 | 99 | ||
100 | static int fddi_rebuild_header(struct sk_buff *skb) | 100 | static int fddi_rebuild_header(struct sk_buff *skb) |
101 | { | 101 | { |
102 | struct fddihdr *fddi = (struct fddihdr *)skb->data; | 102 | struct fddihdr *fddi = (struct fddihdr *)skb->data; |
103 | 103 | ||
104 | #ifdef CONFIG_INET | 104 | #ifdef CONFIG_INET |
105 | if (fddi->hdr.llc_snap.ethertype == __constant_htons(ETH_P_IP)) | 105 | if (fddi->hdr.llc_snap.ethertype == __constant_htons(ETH_P_IP)) |
106 | /* Try to get ARP to resolve the header and fill destination address */ | 106 | /* Try to get ARP to resolve the header and fill destination address */ |
107 | return arp_find(fddi->daddr, skb); | 107 | return arp_find(fddi->daddr, skb); |
108 | else | 108 | else |
109 | #endif | 109 | #endif |
110 | { | 110 | { |
111 | printk("%s: Don't know how to resolve type %02X addresses.\n", | 111 | printk("%s: Don't know how to resolve type %04X addresses.\n", |
112 | skb->dev->name, htons(fddi->hdr.llc_snap.ethertype)); | 112 | skb->dev->name, ntohs(fddi->hdr.llc_snap.ethertype)); |
113 | return(0); | 113 | return(0); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | /* | 118 | /* |
119 | * Determine the packet's protocol ID and fill in skb fields. | 119 | * Determine the packet's protocol ID and fill in skb fields. |
120 | * This routine is called before an incoming packet is passed | 120 | * This routine is called before an incoming packet is passed |
121 | * up. It's used to fill in specific skb fields and to set | 121 | * up. It's used to fill in specific skb fields and to set |
122 | * the proper pointer to the start of packet data (skb->data). | 122 | * the proper pointer to the start of packet data (skb->data). |
123 | */ | 123 | */ |
124 | 124 | ||
125 | __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev) | 125 | __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev) |
126 | { | 126 | { |
127 | struct fddihdr *fddi = (struct fddihdr *)skb->data; | 127 | struct fddihdr *fddi = (struct fddihdr *)skb->data; |
128 | __be16 type; | 128 | __be16 type; |
129 | 129 | ||
130 | /* | 130 | /* |
131 | * Set mac.raw field to point to FC byte, set data field to point | 131 | * Set mac.raw field to point to FC byte, set data field to point |
132 | * to start of packet data. Assume 802.2 SNAP frames for now. | 132 | * to start of packet data. Assume 802.2 SNAP frames for now. |
133 | */ | 133 | */ |
134 | 134 | ||
135 | skb->mac.raw = skb->data; /* point to frame control (FC) */ | 135 | skb->mac.raw = skb->data; /* point to frame control (FC) */ |
136 | 136 | ||
137 | if(fddi->hdr.llc_8022_1.dsap==0xe0) | 137 | if(fddi->hdr.llc_8022_1.dsap==0xe0) |
138 | { | 138 | { |
139 | skb_pull(skb, FDDI_K_8022_HLEN-3); | 139 | skb_pull(skb, FDDI_K_8022_HLEN-3); |
140 | type = __constant_htons(ETH_P_802_2); | 140 | type = __constant_htons(ETH_P_802_2); |
141 | } | 141 | } |
142 | else | 142 | else |
143 | { | 143 | { |
144 | skb_pull(skb, FDDI_K_SNAP_HLEN); /* adjust for 21 byte header */ | 144 | skb_pull(skb, FDDI_K_SNAP_HLEN); /* adjust for 21 byte header */ |
145 | type=fddi->hdr.llc_snap.ethertype; | 145 | type=fddi->hdr.llc_snap.ethertype; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* Set packet type based on destination address and flag settings */ | 148 | /* Set packet type based on destination address and flag settings */ |
149 | 149 | ||
150 | if (*fddi->daddr & 0x01) | 150 | if (*fddi->daddr & 0x01) |
151 | { | 151 | { |
152 | if (memcmp(fddi->daddr, dev->broadcast, FDDI_K_ALEN) == 0) | 152 | if (memcmp(fddi->daddr, dev->broadcast, FDDI_K_ALEN) == 0) |
153 | skb->pkt_type = PACKET_BROADCAST; | 153 | skb->pkt_type = PACKET_BROADCAST; |
154 | else | 154 | else |
155 | skb->pkt_type = PACKET_MULTICAST; | 155 | skb->pkt_type = PACKET_MULTICAST; |
156 | } | 156 | } |
157 | 157 | ||
158 | else if (dev->flags & IFF_PROMISC) | 158 | else if (dev->flags & IFF_PROMISC) |
159 | { | 159 | { |
160 | if (memcmp(fddi->daddr, dev->dev_addr, FDDI_K_ALEN)) | 160 | if (memcmp(fddi->daddr, dev->dev_addr, FDDI_K_ALEN)) |
161 | skb->pkt_type = PACKET_OTHERHOST; | 161 | skb->pkt_type = PACKET_OTHERHOST; |
162 | } | 162 | } |
163 | 163 | ||
164 | /* Assume 802.2 SNAP frames, for now */ | 164 | /* Assume 802.2 SNAP frames, for now */ |
165 | 165 | ||
166 | return(type); | 166 | return(type); |
167 | } | 167 | } |
168 | 168 | ||
169 | EXPORT_SYMBOL(fddi_type_trans); | 169 | EXPORT_SYMBOL(fddi_type_trans); |
170 | 170 | ||
171 | static int fddi_change_mtu(struct net_device *dev, int new_mtu) | 171 | static int fddi_change_mtu(struct net_device *dev, int new_mtu) |
172 | { | 172 | { |
173 | if ((new_mtu < FDDI_K_SNAP_HLEN) || (new_mtu > FDDI_K_SNAP_DLEN)) | 173 | if ((new_mtu < FDDI_K_SNAP_HLEN) || (new_mtu > FDDI_K_SNAP_DLEN)) |
174 | return(-EINVAL); | 174 | return(-EINVAL); |
175 | dev->mtu = new_mtu; | 175 | dev->mtu = new_mtu; |
176 | return(0); | 176 | return(0); |
177 | } | 177 | } |
178 | 178 | ||
179 | static void fddi_setup(struct net_device *dev) | 179 | static void fddi_setup(struct net_device *dev) |
180 | { | 180 | { |
181 | dev->change_mtu = fddi_change_mtu; | 181 | dev->change_mtu = fddi_change_mtu; |
182 | dev->hard_header = fddi_header; | 182 | dev->hard_header = fddi_header; |
183 | dev->rebuild_header = fddi_rebuild_header; | 183 | dev->rebuild_header = fddi_rebuild_header; |
184 | 184 | ||
185 | dev->type = ARPHRD_FDDI; | 185 | dev->type = ARPHRD_FDDI; |
186 | dev->hard_header_len = FDDI_K_SNAP_HLEN+3; /* Assume 802.2 SNAP hdr len + 3 pad bytes */ | 186 | dev->hard_header_len = FDDI_K_SNAP_HLEN+3; /* Assume 802.2 SNAP hdr len + 3 pad bytes */ |
187 | dev->mtu = FDDI_K_SNAP_DLEN; /* Assume max payload of 802.2 SNAP frame */ | 187 | dev->mtu = FDDI_K_SNAP_DLEN; /* Assume max payload of 802.2 SNAP frame */ |
188 | dev->addr_len = FDDI_K_ALEN; | 188 | dev->addr_len = FDDI_K_ALEN; |
189 | dev->tx_queue_len = 100; /* Long queues on FDDI */ | 189 | dev->tx_queue_len = 100; /* Long queues on FDDI */ |
190 | dev->flags = IFF_BROADCAST | IFF_MULTICAST; | 190 | dev->flags = IFF_BROADCAST | IFF_MULTICAST; |
191 | 191 | ||
192 | memset(dev->broadcast, 0xFF, FDDI_K_ALEN); | 192 | memset(dev->broadcast, 0xFF, FDDI_K_ALEN); |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * alloc_fddidev - Register FDDI device | 196 | * alloc_fddidev - Register FDDI device |
197 | * @sizeof_priv: Size of additional driver-private structure to be allocated | 197 | * @sizeof_priv: Size of additional driver-private structure to be allocated |
198 | * for this FDDI device | 198 | * for this FDDI device |
199 | * | 199 | * |
200 | * Fill in the fields of the device structure with FDDI-generic values. | 200 | * Fill in the fields of the device structure with FDDI-generic values. |
201 | * | 201 | * |
202 | * Constructs a new net device, complete with a private data area of | 202 | * Constructs a new net device, complete with a private data area of |
203 | * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for | 203 | * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for |
204 | * this private data area. | 204 | * this private data area. |
205 | */ | 205 | */ |
206 | struct net_device *alloc_fddidev(int sizeof_priv) | 206 | struct net_device *alloc_fddidev(int sizeof_priv) |
207 | { | 207 | { |
208 | return alloc_netdev(sizeof_priv, "fddi%d", fddi_setup); | 208 | return alloc_netdev(sizeof_priv, "fddi%d", fddi_setup); |
209 | } | 209 | } |
210 | EXPORT_SYMBOL(alloc_fddidev); | 210 | EXPORT_SYMBOL(alloc_fddidev); |
211 | 211 |
net/802/hippi.c
1 | /* | 1 | /* |
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
3 | * operating system. INET is implemented using the BSD Socket | 3 | * operating system. INET is implemented using the BSD Socket |
4 | * interface as the means of communication with the user level. | 4 | * interface as the means of communication with the user level. |
5 | * | 5 | * |
6 | * HIPPI-type device handling. | 6 | * HIPPI-type device handling. |
7 | * | 7 | * |
8 | * Version: @(#)hippi.c 1.0.0 05/29/97 | 8 | * Version: @(#)hippi.c 1.0.0 05/29/97 |
9 | * | 9 | * |
10 | * Authors: Ross Biro | 10 | * Authors: Ross Biro |
11 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> | 11 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
12 | * Mark Evans, <evansmp@uhura.aston.ac.uk> | 12 | * Mark Evans, <evansmp@uhura.aston.ac.uk> |
13 | * Florian La Roche, <rzsfl@rz.uni-sb.de> | 13 | * Florian La Roche, <rzsfl@rz.uni-sb.de> |
14 | * Alan Cox, <gw4pts@gw4pts.ampr.org> | 14 | * Alan Cox, <gw4pts@gw4pts.ampr.org> |
15 | * Jes Sorensen, <Jes.Sorensen@cern.ch> | 15 | * Jes Sorensen, <Jes.Sorensen@cern.ch> |
16 | * | 16 | * |
17 | * This program is free software; you can redistribute it and/or | 17 | * This program is free software; you can redistribute it and/or |
18 | * modify it under the terms of the GNU General Public License | 18 | * modify it under the terms of the GNU General Public License |
19 | * as published by the Free Software Foundation; either version | 19 | * as published by the Free Software Foundation; either version |
20 | * 2 of the License, or (at your option) any later version. | 20 | * 2 of the License, or (at your option) any later version. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <linux/string.h> | 27 | #include <linux/string.h> |
28 | #include <linux/mm.h> | 28 | #include <linux/mm.h> |
29 | #include <linux/socket.h> | 29 | #include <linux/socket.h> |
30 | #include <linux/in.h> | 30 | #include <linux/in.h> |
31 | #include <linux/inet.h> | 31 | #include <linux/inet.h> |
32 | #include <linux/netdevice.h> | 32 | #include <linux/netdevice.h> |
33 | #include <linux/hippidevice.h> | 33 | #include <linux/hippidevice.h> |
34 | #include <linux/skbuff.h> | 34 | #include <linux/skbuff.h> |
35 | #include <linux/errno.h> | 35 | #include <linux/errno.h> |
36 | #include <net/arp.h> | 36 | #include <net/arp.h> |
37 | #include <net/sock.h> | 37 | #include <net/sock.h> |
38 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
39 | #include <asm/checksum.h> | 39 | #include <asm/checksum.h> |
40 | #include <asm/system.h> | 40 | #include <asm/system.h> |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * Create the HIPPI MAC header for an arbitrary protocol layer | 43 | * Create the HIPPI MAC header for an arbitrary protocol layer |
44 | * | 44 | * |
45 | * saddr=NULL means use device source address | 45 | * saddr=NULL means use device source address |
46 | * daddr=NULL means leave destination address (eg unresolved arp) | 46 | * daddr=NULL means leave destination address (eg unresolved arp) |
47 | */ | 47 | */ |
48 | 48 | ||
49 | static int hippi_header(struct sk_buff *skb, struct net_device *dev, | 49 | static int hippi_header(struct sk_buff *skb, struct net_device *dev, |
50 | unsigned short type, void *daddr, void *saddr, | 50 | unsigned short type, void *daddr, void *saddr, |
51 | unsigned len) | 51 | unsigned len) |
52 | { | 52 | { |
53 | struct hippi_hdr *hip = (struct hippi_hdr *)skb_push(skb, HIPPI_HLEN); | 53 | struct hippi_hdr *hip = (struct hippi_hdr *)skb_push(skb, HIPPI_HLEN); |
54 | struct hippi_cb *hcb = (struct hippi_cb *) skb->cb; | 54 | struct hippi_cb *hcb = (struct hippi_cb *) skb->cb; |
55 | 55 | ||
56 | if (!len){ | 56 | if (!len){ |
57 | len = skb->len - HIPPI_HLEN; | 57 | len = skb->len - HIPPI_HLEN; |
58 | printk("hippi_header(): length not supplied\n"); | 58 | printk("hippi_header(): length not supplied\n"); |
59 | } | 59 | } |
60 | 60 | ||
61 | /* | 61 | /* |
62 | * Due to the stupidity of the little endian byte-order we | 62 | * Due to the stupidity of the little endian byte-order we |
63 | * have to set the fp field this way. | 63 | * have to set the fp field this way. |
64 | */ | 64 | */ |
65 | hip->fp.fixed = __constant_htonl(0x04800018); | 65 | hip->fp.fixed = __constant_htonl(0x04800018); |
66 | hip->fp.d2_size = htonl(len + 8); | 66 | hip->fp.d2_size = htonl(len + 8); |
67 | hip->le.fc = 0; | 67 | hip->le.fc = 0; |
68 | hip->le.double_wide = 0; /* only HIPPI 800 for the time being */ | 68 | hip->le.double_wide = 0; /* only HIPPI 800 for the time being */ |
69 | hip->le.message_type = 0; /* Data PDU */ | 69 | hip->le.message_type = 0; /* Data PDU */ |
70 | 70 | ||
71 | hip->le.dest_addr_type = 2; /* 12 bit SC address */ | 71 | hip->le.dest_addr_type = 2; /* 12 bit SC address */ |
72 | hip->le.src_addr_type = 2; /* 12 bit SC address */ | 72 | hip->le.src_addr_type = 2; /* 12 bit SC address */ |
73 | 73 | ||
74 | memcpy(hip->le.src_switch_addr, dev->dev_addr + 3, 3); | 74 | memcpy(hip->le.src_switch_addr, dev->dev_addr + 3, 3); |
75 | memset(&hip->le.reserved, 0, 16); | 75 | memset(&hip->le.reserved, 0, 16); |
76 | 76 | ||
77 | hip->snap.dsap = HIPPI_EXTENDED_SAP; | 77 | hip->snap.dsap = HIPPI_EXTENDED_SAP; |
78 | hip->snap.ssap = HIPPI_EXTENDED_SAP; | 78 | hip->snap.ssap = HIPPI_EXTENDED_SAP; |
79 | hip->snap.ctrl = HIPPI_UI_CMD; | 79 | hip->snap.ctrl = HIPPI_UI_CMD; |
80 | hip->snap.oui[0] = 0x00; | 80 | hip->snap.oui[0] = 0x00; |
81 | hip->snap.oui[1] = 0x00; | 81 | hip->snap.oui[1] = 0x00; |
82 | hip->snap.oui[2] = 0x00; | 82 | hip->snap.oui[2] = 0x00; |
83 | hip->snap.ethertype = htons(type); | 83 | hip->snap.ethertype = htons(type); |
84 | 84 | ||
85 | if (daddr) | 85 | if (daddr) |
86 | { | 86 | { |
87 | memcpy(hip->le.dest_switch_addr, daddr + 3, 3); | 87 | memcpy(hip->le.dest_switch_addr, daddr + 3, 3); |
88 | memcpy(&hcb->ifield, daddr + 2, 4); | 88 | memcpy(&hcb->ifield, daddr + 2, 4); |
89 | return HIPPI_HLEN; | 89 | return HIPPI_HLEN; |
90 | } | 90 | } |
91 | hcb->ifield = 0; | 91 | hcb->ifield = 0; |
92 | return -((int)HIPPI_HLEN); | 92 | return -((int)HIPPI_HLEN); |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | /* | 96 | /* |
97 | * Rebuild the HIPPI MAC header. This is called after an ARP has | 97 | * Rebuild the HIPPI MAC header. This is called after an ARP has |
98 | * completed on this sk_buff. We now let ARP fill in the other fields. | 98 | * completed on this sk_buff. We now let ARP fill in the other fields. |
99 | */ | 99 | */ |
100 | 100 | ||
101 | static int hippi_rebuild_header(struct sk_buff *skb) | 101 | static int hippi_rebuild_header(struct sk_buff *skb) |
102 | { | 102 | { |
103 | struct hippi_hdr *hip = (struct hippi_hdr *)skb->data; | 103 | struct hippi_hdr *hip = (struct hippi_hdr *)skb->data; |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * Only IP is currently supported | 106 | * Only IP is currently supported |
107 | */ | 107 | */ |
108 | 108 | ||
109 | if(hip->snap.ethertype != __constant_htons(ETH_P_IP)) | 109 | if(hip->snap.ethertype != __constant_htons(ETH_P_IP)) |
110 | { | 110 | { |
111 | printk(KERN_DEBUG "%s: unable to resolve type %X addresses.\n",skb->dev->name,ntohs(hip->snap.ethertype)); | 111 | printk(KERN_DEBUG "%s: unable to resolve type %X addresses.\n",skb->dev->name,ntohs(hip->snap.ethertype)); |
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
114 | 114 | ||
115 | /* | 115 | /* |
116 | * We don't support dynamic ARP on HIPPI, but we use the ARP | 116 | * We don't support dynamic ARP on HIPPI, but we use the ARP |
117 | * static ARP tables to hold the I-FIELDs. | 117 | * static ARP tables to hold the I-FIELDs. |
118 | */ | 118 | */ |
119 | return arp_find(hip->le.daddr, skb); | 119 | return arp_find(hip->le.daddr, skb); |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | /* | 123 | /* |
124 | * Determine the packet's protocol ID. | 124 | * Determine the packet's protocol ID. |
125 | */ | 125 | */ |
126 | 126 | ||
127 | unsigned short hippi_type_trans(struct sk_buff *skb, struct net_device *dev) | 127 | __be16 hippi_type_trans(struct sk_buff *skb, struct net_device *dev) |
128 | { | 128 | { |
129 | struct hippi_hdr *hip; | 129 | struct hippi_hdr *hip; |
130 | 130 | ||
131 | hip = (struct hippi_hdr *) skb->data; | 131 | hip = (struct hippi_hdr *) skb->data; |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * This is actually wrong ... question is if we really should | 134 | * This is actually wrong ... question is if we really should |
135 | * set the raw address here. | 135 | * set the raw address here. |
136 | */ | 136 | */ |
137 | skb->mac.raw = skb->data; | 137 | skb->mac.raw = skb->data; |
138 | skb_pull(skb, HIPPI_HLEN); | 138 | skb_pull(skb, HIPPI_HLEN); |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * No fancy promisc stuff here now. | 141 | * No fancy promisc stuff here now. |
142 | */ | 142 | */ |
143 | 143 | ||
144 | return hip->snap.ethertype; | 144 | return hip->snap.ethertype; |
145 | } | 145 | } |
146 | 146 | ||
147 | EXPORT_SYMBOL(hippi_type_trans); | 147 | EXPORT_SYMBOL(hippi_type_trans); |
148 | 148 | ||
149 | static int hippi_change_mtu(struct net_device *dev, int new_mtu) | 149 | static int hippi_change_mtu(struct net_device *dev, int new_mtu) |
150 | { | 150 | { |
151 | /* | 151 | /* |
152 | * HIPPI's got these nice large MTUs. | 152 | * HIPPI's got these nice large MTUs. |
153 | */ | 153 | */ |
154 | if ((new_mtu < 68) || (new_mtu > 65280)) | 154 | if ((new_mtu < 68) || (new_mtu > 65280)) |
155 | return -EINVAL; | 155 | return -EINVAL; |
156 | dev->mtu = new_mtu; | 156 | dev->mtu = new_mtu; |
157 | return(0); | 157 | return(0); |
158 | } | 158 | } |
159 | 159 | ||
160 | /* | 160 | /* |
161 | * For HIPPI we will actually use the lower 4 bytes of the hardware | 161 | * For HIPPI we will actually use the lower 4 bytes of the hardware |
162 | * address as the I-FIELD rather than the actual hardware address. | 162 | * address as the I-FIELD rather than the actual hardware address. |
163 | */ | 163 | */ |
164 | static int hippi_mac_addr(struct net_device *dev, void *p) | 164 | static int hippi_mac_addr(struct net_device *dev, void *p) |
165 | { | 165 | { |
166 | struct sockaddr *addr = p; | 166 | struct sockaddr *addr = p; |
167 | if (netif_running(dev)) | 167 | if (netif_running(dev)) |
168 | return -EBUSY; | 168 | return -EBUSY; |
169 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | 169 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); |
170 | return 0; | 170 | return 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p) | 173 | static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p) |
174 | { | 174 | { |
175 | /* Never send broadcast/multicast ARP messages */ | 175 | /* Never send broadcast/multicast ARP messages */ |
176 | p->mcast_probes = 0; | 176 | p->mcast_probes = 0; |
177 | 177 | ||
178 | /* In IPv6 unicast probes are valid even on NBMA, | 178 | /* In IPv6 unicast probes are valid even on NBMA, |
179 | * because they are encapsulated in normal IPv6 protocol. | 179 | * because they are encapsulated in normal IPv6 protocol. |
180 | * Should be a generic flag. | 180 | * Should be a generic flag. |
181 | */ | 181 | */ |
182 | if (p->tbl->family != AF_INET6) | 182 | if (p->tbl->family != AF_INET6) |
183 | p->ucast_probes = 0; | 183 | p->ucast_probes = 0; |
184 | return 0; | 184 | return 0; |
185 | } | 185 | } |
186 | 186 | ||
187 | static void hippi_setup(struct net_device *dev) | 187 | static void hippi_setup(struct net_device *dev) |
188 | { | 188 | { |
189 | dev->set_multicast_list = NULL; | 189 | dev->set_multicast_list = NULL; |
190 | dev->change_mtu = hippi_change_mtu; | 190 | dev->change_mtu = hippi_change_mtu; |
191 | dev->hard_header = hippi_header; | 191 | dev->hard_header = hippi_header; |
192 | dev->rebuild_header = hippi_rebuild_header; | 192 | dev->rebuild_header = hippi_rebuild_header; |
193 | dev->set_mac_address = hippi_mac_addr; | 193 | dev->set_mac_address = hippi_mac_addr; |
194 | dev->hard_header_parse = NULL; | 194 | dev->hard_header_parse = NULL; |
195 | dev->hard_header_cache = NULL; | 195 | dev->hard_header_cache = NULL; |
196 | dev->header_cache_update = NULL; | 196 | dev->header_cache_update = NULL; |
197 | dev->neigh_setup = hippi_neigh_setup_dev; | 197 | dev->neigh_setup = hippi_neigh_setup_dev; |
198 | 198 | ||
199 | /* | 199 | /* |
200 | * We don't support HIPPI `ARP' for the time being, and probably | 200 | * We don't support HIPPI `ARP' for the time being, and probably |
201 | * never will unless someone else implements it. However we | 201 | * never will unless someone else implements it. However we |
202 | * still need a fake ARPHRD to make ifconfig and friends play ball. | 202 | * still need a fake ARPHRD to make ifconfig and friends play ball. |
203 | */ | 203 | */ |
204 | dev->type = ARPHRD_HIPPI; | 204 | dev->type = ARPHRD_HIPPI; |
205 | dev->hard_header_len = HIPPI_HLEN; | 205 | dev->hard_header_len = HIPPI_HLEN; |
206 | dev->mtu = 65280; | 206 | dev->mtu = 65280; |
207 | dev->addr_len = HIPPI_ALEN; | 207 | dev->addr_len = HIPPI_ALEN; |
208 | dev->tx_queue_len = 25 /* 5 */; | 208 | dev->tx_queue_len = 25 /* 5 */; |
209 | memset(dev->broadcast, 0xFF, HIPPI_ALEN); | 209 | memset(dev->broadcast, 0xFF, HIPPI_ALEN); |
210 | 210 | ||
211 | 211 | ||
212 | /* | 212 | /* |
213 | * HIPPI doesn't support broadcast+multicast and we only use | 213 | * HIPPI doesn't support broadcast+multicast and we only use |
214 | * static ARP tables. ARP is disabled by hippi_neigh_setup_dev. | 214 | * static ARP tables. ARP is disabled by hippi_neigh_setup_dev. |
215 | */ | 215 | */ |
216 | dev->flags = 0; | 216 | dev->flags = 0; |
217 | } | 217 | } |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * alloc_hippi_dev - Register HIPPI device | 220 | * alloc_hippi_dev - Register HIPPI device |
221 | * @sizeof_priv: Size of additional driver-private structure to be allocated | 221 | * @sizeof_priv: Size of additional driver-private structure to be allocated |
222 | * for this HIPPI device | 222 | * for this HIPPI device |
223 | * | 223 | * |
224 | * Fill in the fields of the device structure with HIPPI-generic values. | 224 | * Fill in the fields of the device structure with HIPPI-generic values. |
225 | * | 225 | * |
226 | * Constructs a new net device, complete with a private data area of | 226 | * Constructs a new net device, complete with a private data area of |
227 | * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for | 227 | * size @sizeof_priv. A 32-byte (not bit) alignment is enforced for |
228 | * this private data area. | 228 | * this private data area. |
229 | */ | 229 | */ |
230 | 230 | ||
231 | struct net_device *alloc_hippi_dev(int sizeof_priv) | 231 | struct net_device *alloc_hippi_dev(int sizeof_priv) |
232 | { | 232 | { |
233 | return alloc_netdev(sizeof_priv, "hip%d", hippi_setup); | 233 | return alloc_netdev(sizeof_priv, "hip%d", hippi_setup); |
234 | } | 234 | } |
235 | 235 | ||
236 | EXPORT_SYMBOL(alloc_hippi_dev); | 236 | EXPORT_SYMBOL(alloc_hippi_dev); |
237 | 237 |