summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/intel/ice/ice_eswitch_br.h
blob: e1b4eda7a8900bb345798b2b5acde25ebb567fc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2023, Intel Corporation. */

#ifndef _ICE_ESWITCH_BR_H_
#define _ICE_ESWITCH_BR_H_

#include <linux/rhashtable.h>

struct ice_esw_br_fdb_data {
	unsigned char addr[ETH_ALEN];
	u16 vid;
};

struct ice_esw_br_flow {
	struct ice_rule_query_data *fwd_rule;
};

enum {
	ICE_ESWITCH_BR_FDB_ADDED_BY_USER = BIT(0),
};

struct ice_esw_br_fdb_entry {
	struct ice_esw_br_fdb_data data;
	struct rhash_head ht_node;
	struct list_head list;

	int flags;

	struct net_device *dev;
	struct ice_esw_br_port *br_port;
	struct ice_esw_br_flow *flow;
};

enum ice_esw_br_port_type {
	ICE_ESWITCH_BR_UPLINK_PORT = 0,
	ICE_ESWITCH_BR_VF_REPR_PORT = 1,
};

struct ice_esw_br_port {
	struct ice_esw_br *bridge;
	struct ice_vsi *vsi;
	enum ice_esw_br_port_type type;
	u16 vsi_idx;
};

struct ice_esw_br {
	struct ice_esw_br_offloads *br_offloads;
	struct xarray ports;

	struct rhashtable fdb_ht;
	struct list_head fdb_list;

	int ifindex;
};

struct ice_esw_br_offloads {
	struct ice_pf *pf;
	struct ice_esw_br *bridge;
	struct notifier_block netdev_nb;
	struct notifier_block switchdev_nb;

	struct workqueue_struct *wq;
};

struct ice_esw_br_fdb_work {
	struct work_struct work;
	struct switchdev_notifier_fdb_info fdb_info;
	struct net_device *dev;
	unsigned long event;
};

#define ice_nb_to_br_offloads(nb, nb_name) \
	container_of(nb, \
		     struct ice_esw_br_offloads, \
		     nb_name)

#define ice_work_to_fdb_work(w) \
	container_of(w, \
		     struct ice_esw_br_fdb_work, \
		     work)

void
ice_eswitch_br_offloads_deinit(struct ice_pf *pf);
int
ice_eswitch_br_offloads_init(struct ice_pf *pf);

#endif /* _ICE_ESWITCH_BR_H_ */