xref: /linux/drivers/net/ethernet/intel/ice/devlink/port.h (revision 0ad9617c78acbc71373fb341a6f75d4012b01d69)
1*2846fe56SPrzemek Kitszel /* SPDX-License-Identifier: GPL-2.0 */
2*2846fe56SPrzemek Kitszel /* Copyright (c) 2024, Intel Corporation. */
3*2846fe56SPrzemek Kitszel 
4*2846fe56SPrzemek Kitszel #ifndef _DEVLINK_PORT_H_
5*2846fe56SPrzemek Kitszel #define _DEVLINK_PORT_H_
6*2846fe56SPrzemek Kitszel 
7*2846fe56SPrzemek Kitszel #include "../ice.h"
8*2846fe56SPrzemek Kitszel #include "../ice_sf_eth.h"
9*2846fe56SPrzemek Kitszel 
10*2846fe56SPrzemek Kitszel /**
11*2846fe56SPrzemek Kitszel  * struct ice_dynamic_port - Track dynamically added devlink port instance
12*2846fe56SPrzemek Kitszel  * @hw_addr: the HW address for this port
13*2846fe56SPrzemek Kitszel  * @active: true if the port has been activated
14*2846fe56SPrzemek Kitszel  * @attached: true it the prot is attached
15*2846fe56SPrzemek Kitszel  * @devlink_port: the associated devlink port structure
16*2846fe56SPrzemek Kitszel  * @pf: pointer to the PF private structure
17*2846fe56SPrzemek Kitszel  * @vsi: the VSI associated with this port
18*2846fe56SPrzemek Kitszel  * @repr_id: the representor ID
19*2846fe56SPrzemek Kitszel  * @sfnum: the subfunction ID
20*2846fe56SPrzemek Kitszel  * @sf_dev: pointer to the subfunction device
21*2846fe56SPrzemek Kitszel  *
22*2846fe56SPrzemek Kitszel  * An instance of a dynamically added devlink port. Each port flavour
23*2846fe56SPrzemek Kitszel  */
24*2846fe56SPrzemek Kitszel struct ice_dynamic_port {
25*2846fe56SPrzemek Kitszel 	u8 hw_addr[ETH_ALEN];
26*2846fe56SPrzemek Kitszel 	u8 active: 1;
27*2846fe56SPrzemek Kitszel 	u8 attached: 1;
28*2846fe56SPrzemek Kitszel 	struct devlink_port devlink_port;
29*2846fe56SPrzemek Kitszel 	struct ice_pf *pf;
30*2846fe56SPrzemek Kitszel 	struct ice_vsi *vsi;
31*2846fe56SPrzemek Kitszel 	unsigned long repr_id;
32*2846fe56SPrzemek Kitszel 	u32 sfnum;
33*2846fe56SPrzemek Kitszel 	/* Flavour-specific implementation data */
34*2846fe56SPrzemek Kitszel 	union {
35*2846fe56SPrzemek Kitszel 		struct ice_sf_dev *sf_dev;
36*2846fe56SPrzemek Kitszel 	};
37*2846fe56SPrzemek Kitszel };
38*2846fe56SPrzemek Kitszel 
39*2846fe56SPrzemek Kitszel void ice_dealloc_all_dynamic_ports(struct ice_pf *pf);
40*2846fe56SPrzemek Kitszel 
41*2846fe56SPrzemek Kitszel int ice_devlink_create_pf_port(struct ice_pf *pf);
42*2846fe56SPrzemek Kitszel void ice_devlink_destroy_pf_port(struct ice_pf *pf);
43*2846fe56SPrzemek Kitszel int ice_devlink_create_vf_port(struct ice_vf *vf);
44*2846fe56SPrzemek Kitszel void ice_devlink_destroy_vf_port(struct ice_vf *vf);
45*2846fe56SPrzemek Kitszel int ice_devlink_create_sf_port(struct ice_dynamic_port *dyn_port);
46*2846fe56SPrzemek Kitszel void ice_devlink_destroy_sf_port(struct ice_dynamic_port *dyn_port);
47*2846fe56SPrzemek Kitszel int ice_devlink_create_sf_dev_port(struct ice_sf_dev *sf_dev);
48*2846fe56SPrzemek Kitszel void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev);
49*2846fe56SPrzemek Kitszel 
50*2846fe56SPrzemek Kitszel #define ice_devlink_port_to_dyn(port) \
51*2846fe56SPrzemek Kitszel 	container_of(port, struct ice_dynamic_port, devlink_port)
52*2846fe56SPrzemek Kitszel 
53*2846fe56SPrzemek Kitszel int
54*2846fe56SPrzemek Kitszel ice_devlink_port_new(struct devlink *devlink,
55*2846fe56SPrzemek Kitszel 		     const struct devlink_port_new_attrs *new_attr,
56*2846fe56SPrzemek Kitszel 		     struct netlink_ext_ack *extack,
57*2846fe56SPrzemek Kitszel 		     struct devlink_port **devlink_port);
58*2846fe56SPrzemek Kitszel #endif /* _DEVLINK_PORT_H_ */
59