]> Git Repo - linux.git/blob - drivers/s390/net/qeth_l3.h
net: dsa: sja1105: Implement state machine for TAS with PTP clock source
[linux.git] / drivers / s390 / net / qeth_l3.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *    Copyright IBM Corp. 2007
4  *    Author(s): Utz Bacher <[email protected]>,
5  *               Frank Pavlic <[email protected]>,
6  *               Thomas Spatzier <[email protected]>,
7  *               Frank Blaschka <[email protected]>
8  */
9
10 #ifndef __QETH_L3_H__
11 #define __QETH_L3_H__
12
13 #include "qeth_core.h"
14 #include <linux/hashtable.h>
15
16 #define QETH_SNIFF_AVAIL        0x0008
17
18 enum qeth_ip_types {
19         QETH_IP_TYPE_NORMAL,
20         QETH_IP_TYPE_VIPA,
21         QETH_IP_TYPE_RXIP,
22 };
23
24 struct qeth_ipaddr {
25         struct hlist_node hnode;
26         enum qeth_ip_types type;
27         u8 is_multicast:1;
28         u8 in_progress:1;
29         u8 disp_flag:2;
30         u8 ipato:1;                     /* ucast only */
31
32         /* is changed only for normal ip addresses
33          * for non-normal addresses it always is  1
34          */
35         int  ref_counter;
36         enum qeth_prot_versions proto;
37         union {
38                 struct {
39                         __be32 addr;
40                         unsigned int mask;
41                 } a4;
42                 struct {
43                         struct in6_addr addr;
44                         unsigned int pfxlen;
45                 } a6;
46         } u;
47 };
48
49 static inline void qeth_l3_init_ipaddr(struct qeth_ipaddr *addr,
50                                        enum qeth_ip_types type,
51                                        enum qeth_prot_versions proto)
52 {
53         memset(addr, 0, sizeof(*addr));
54         addr->type = type;
55         addr->proto = proto;
56         addr->disp_flag = QETH_DISP_ADDR_DO_NOTHING;
57 }
58
59 static inline bool qeth_l3_addr_match_ip(struct qeth_ipaddr *a1,
60                                          struct qeth_ipaddr *a2)
61 {
62         if (a1->proto != a2->proto)
63                 return false;
64         if (a1->proto == QETH_PROT_IPV6)
65                 return ipv6_addr_equal(&a1->u.a6.addr, &a2->u.a6.addr);
66         return a1->u.a4.addr == a2->u.a4.addr;
67 }
68
69 static inline bool qeth_l3_addr_match_all(struct qeth_ipaddr *a1,
70                                           struct qeth_ipaddr *a2)
71 {
72         /* Assumes that the pair was obtained via qeth_l3_addr_find_by_ip(),
73          * so 'proto' and 'addr' match for sure.
74          *
75          * For ucast:
76          * -    'mask'/'pfxlen' for RXIP/VIPA is always 0. For NORMAL, matching
77          *      values are required to avoid mixups in takeover eligibility.
78          *
79          * For mcast,
80          * -    'mask'/'pfxlen' is always 0.
81          */
82         if (a1->type != a2->type)
83                 return false;
84         if (a1->proto == QETH_PROT_IPV6)
85                 return a1->u.a6.pfxlen == a2->u.a6.pfxlen;
86         return a1->u.a4.mask == a2->u.a4.mask;
87 }
88
89 static inline u32 qeth_l3_ipaddr_hash(struct qeth_ipaddr *addr)
90 {
91         if (addr->proto == QETH_PROT_IPV6)
92                 return ipv6_addr_hash(&addr->u.a6.addr);
93         else
94                 return ipv4_addr_hash(addr->u.a4.addr);
95 }
96
97 struct qeth_ipato_entry {
98         struct list_head entry;
99         enum qeth_prot_versions proto;
100         char addr[16];
101         int mask_bits;
102 };
103
104 extern const struct attribute_group *qeth_l3_attr_groups[];
105
106 void qeth_l3_ipaddr_to_string(enum qeth_prot_versions, const __u8 *, char *);
107 int qeth_l3_create_device_attributes(struct device *);
108 void qeth_l3_remove_device_attributes(struct device *);
109 int qeth_l3_setrouting_v4(struct qeth_card *);
110 int qeth_l3_setrouting_v6(struct qeth_card *);
111 int qeth_l3_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *);
112 int qeth_l3_del_ipato_entry(struct qeth_card *card,
113                             enum qeth_prot_versions proto, u8 *addr,
114                             int mask_bits);
115 void qeth_l3_update_ipato(struct qeth_card *card);
116 int qeth_l3_modify_hsuid(struct qeth_card *card, bool add);
117 int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip,
118                              enum qeth_ip_types type,
119                              enum qeth_prot_versions proto);
120
121 #endif /* __QETH_L3_H__ */
This page took 0.0377960000000001 seconds and 4 git commands to generate.