Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 1 | /* |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 2 | * Copyright IBM Corp. 2007 |
| 3 | * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, |
| 4 | * Frank Pavlic <fpavlic@de.ibm.com>, |
| 5 | * Thomas Spatzier <tspat@de.ibm.com>, |
| 6 | * Frank Blaschka <frank.blaschka@de.ibm.com> |
| 7 | */ |
| 8 | |
| 9 | #ifndef __QETH_L3_H__ |
| 10 | #define __QETH_L3_H__ |
| 11 | |
| 12 | #include "qeth_core.h" |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 13 | #include <linux/hashtable.h> |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 14 | |
Ursula Braun | 76b11f8 | 2010-01-11 02:50:50 +0000 | [diff] [blame] | 15 | #define QETH_SNIFF_AVAIL 0x0008 |
| 16 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 17 | struct qeth_ipaddr { |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 18 | struct hlist_node hnode; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 19 | enum qeth_ip_types type; |
| 20 | enum qeth_ipa_setdelip_flags set_flags; |
| 21 | enum qeth_ipa_setdelip_flags del_flags; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 22 | u8 is_multicast:1; |
| 23 | u8 in_progress:1; |
| 24 | u8 disp_flag:2; |
| 25 | |
| 26 | /* is changed only for normal ip addresses |
| 27 | * for non-normal addresses it always is 1 |
| 28 | */ |
| 29 | int ref_counter; |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 30 | enum qeth_prot_versions proto; |
| 31 | unsigned char mac[OSA_ADDR_LEN]; |
| 32 | union { |
| 33 | struct { |
| 34 | unsigned int addr; |
| 35 | unsigned int mask; |
| 36 | } a4; |
| 37 | struct { |
| 38 | struct in6_addr addr; |
| 39 | unsigned int pfxlen; |
| 40 | } a6; |
| 41 | } u; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 42 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 43 | }; |
Lakhvich Dmitriy | 5f78e29 | 2016-06-16 16:18:58 +0200 | [diff] [blame] | 44 | static inline u64 qeth_l3_ipaddr_hash(struct qeth_ipaddr *addr) |
| 45 | { |
| 46 | u64 ret = 0; |
| 47 | u8 *point; |
| 48 | |
| 49 | if (addr->proto == QETH_PROT_IPV6) { |
| 50 | point = (u8 *) &addr->u.a6.addr; |
| 51 | ret = get_unaligned((u64 *)point) ^ |
| 52 | get_unaligned((u64 *) (point + 8)); |
| 53 | } |
| 54 | if (addr->proto == QETH_PROT_IPV4) { |
| 55 | point = (u8 *) &addr->u.a4.addr; |
| 56 | ret = get_unaligned((u32 *) point); |
| 57 | } |
| 58 | return ret; |
| 59 | } |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 60 | |
| 61 | struct qeth_ipato_entry { |
| 62 | struct list_head entry; |
| 63 | enum qeth_prot_versions proto; |
| 64 | char addr[16]; |
| 65 | int mask_bits; |
| 66 | }; |
| 67 | |
| 68 | |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 69 | void qeth_l3_ipaddr_to_string(enum qeth_prot_versions, const __u8 *, char *); |
| 70 | int qeth_l3_string_to_ipaddr(const char *, enum qeth_prot_versions, __u8 *); |
| 71 | int qeth_l3_create_device_attributes(struct device *); |
| 72 | void qeth_l3_remove_device_attributes(struct device *); |
| 73 | int qeth_l3_setrouting_v4(struct qeth_card *); |
| 74 | int qeth_l3_setrouting_v6(struct qeth_card *); |
| 75 | int qeth_l3_add_ipato_entry(struct qeth_card *, struct qeth_ipato_entry *); |
| 76 | void qeth_l3_del_ipato_entry(struct qeth_card *, enum qeth_prot_versions, |
| 77 | u8 *, int); |
| 78 | int qeth_l3_add_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *); |
| 79 | void qeth_l3_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *); |
| 80 | int qeth_l3_add_rxip(struct qeth_card *, enum qeth_prot_versions, const u8 *); |
| 81 | void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions, |
| 82 | const u8 *); |
Klaus-Dieter Wacker | 6298263 | 2010-07-22 23:15:03 +0000 | [diff] [blame] | 83 | int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *, struct qeth_ipaddr *); |
Frank Blaschka | b333293 | 2011-08-08 01:33:59 +0000 | [diff] [blame] | 84 | struct qeth_ipaddr *qeth_l3_get_addr_buffer(enum qeth_prot_versions); |
| 85 | int qeth_l3_add_ip(struct qeth_card *, struct qeth_ipaddr *); |
| 86 | int qeth_l3_delete_ip(struct qeth_card *, struct qeth_ipaddr *); |
Frank Blaschka | 4a71df5 | 2008-02-15 09:19:42 +0100 | [diff] [blame] | 87 | |
| 88 | #endif /* __QETH_L3_H__ */ |