License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / drivers / s390 / net / qeth_l3.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
4a71df50 2/*
4a71df50
FB
3 * Copyright IBM Corp. 2007
4 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
5 * Frank Pavlic <fpavlic@de.ibm.com>,
6 * Thomas Spatzier <tspat@de.ibm.com>,
7 * Frank Blaschka <frank.blaschka@de.ibm.com>
8 */
9
10#ifndef __QETH_L3_H__
11#define __QETH_L3_H__
12
13#include "qeth_core.h"
5f78e29c 14#include <linux/hashtable.h>
4a71df50 15
76b11f8e
UB
16#define QETH_SNIFF_AVAIL 0x0008
17
4a71df50 18struct qeth_ipaddr {
5f78e29c 19 struct hlist_node hnode;
4a71df50
FB
20 enum qeth_ip_types type;
21 enum qeth_ipa_setdelip_flags set_flags;
22 enum qeth_ipa_setdelip_flags del_flags;
5f78e29c
LD
23 u8 is_multicast:1;
24 u8 in_progress:1;
25 u8 disp_flag:2;
26
27 /* is changed only for normal ip addresses
28 * for non-normal addresses it always is 1
29 */
30 int ref_counter;
4a71df50
FB
31 enum qeth_prot_versions proto;
32 unsigned char mac[OSA_ADDR_LEN];
33 union {
34 struct {
35 unsigned int addr;
36 unsigned int mask;
37 } a4;
38 struct {
39 struct in6_addr addr;
40 unsigned int pfxlen;
41 } a6;
42 } u;
5f78e29c 43
4a71df50 44};
5f78e29c
LD
45static inline u64 qeth_l3_ipaddr_hash(struct qeth_ipaddr *addr)
46{
47 u64 ret = 0;
48 u8 *point;
49
50 if (addr->proto == QETH_PROT_IPV6) {
51 point = (u8 *) &addr->u.a6.addr;
52 ret = get_unaligned((u64 *)point) ^
53 get_unaligned((u64 *) (point + 8));
54 }
55 if (addr->proto == QETH_PROT_IPV4) {
56 point = (u8 *) &addr->u.a4.addr;
57 ret = get_unaligned((u32 *) point);
58 }
59 return ret;
60}
4a71df50
FB
61
62struct qeth_ipato_entry {
63 struct list_head entry;
64 enum qeth_prot_versions proto;
65 char addr[16];
66 int mask_bits;
67};
68
79a04e40 69extern const struct attribute_group *qeth_l3_attr_groups[];
4a71df50 70
4a71df50
FB
71void qeth_l3_ipaddr_to_string(enum qeth_prot_versions, const __u8 *, char *);
72int qeth_l3_string_to_ipaddr(const char *, enum qeth_prot_versions, __u8 *);
73int qeth_l3_create_device_attributes(struct device *);
74void qeth_l3_remove_device_attributes(struct device *);
75int qeth_l3_setrouting_v4(struct qeth_card *);
76int qeth_l3_setrouting_v6(struct qeth_card *);
77int qeth_l3_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *);
78void qeth_l3_del_ipato_entry(struct qeth_card *, enum qeth_prot_versions,
79 u8 *, int);
80int qeth_l3_add_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
81void qeth_l3_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);
82int qeth_l3_add_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *);
83void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions,
84 const u8 *);
6298263a 85int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *, struct qeth_ipaddr *);
b3332930
FB
86struct qeth_ipaddr *qeth_l3_get_addr_buffer(enum qeth_prot_versions);
87int qeth_l3_add_ip(struct qeth_card *, struct qeth_ipaddr *);
88int qeth_l3_delete_ip(struct qeth_card *, struct qeth_ipaddr *);
4a71df50
FB
89
90#endif /* __QETH_L3_H__ */