xref: /linux/drivers/net/ethernet/intel/ice/devlink/port.h (revision 8be4d31cb8aaeea27bde4b7ddb26e28a89062ebf)
12846fe56SPrzemek Kitszel /* SPDX-License-Identifier: GPL-2.0 */
22846fe56SPrzemek Kitszel /* Copyright (c) 2024, Intel Corporation. */
32846fe56SPrzemek Kitszel 
42846fe56SPrzemek Kitszel #ifndef _DEVLINK_PORT_H_
52846fe56SPrzemek Kitszel #define _DEVLINK_PORT_H_
62846fe56SPrzemek Kitszel 
72846fe56SPrzemek Kitszel #include "../ice.h"
82846fe56SPrzemek Kitszel #include "../ice_sf_eth.h"
92846fe56SPrzemek Kitszel 
102846fe56SPrzemek Kitszel /**
112846fe56SPrzemek Kitszel  * struct ice_dynamic_port - Track dynamically added devlink port instance
122846fe56SPrzemek Kitszel  * @hw_addr: the HW address for this port
132846fe56SPrzemek Kitszel  * @active: true if the port has been activated
14*fe09560fSBjorn Helgaas  * @attached: true if the prot is attached
152846fe56SPrzemek Kitszel  * @devlink_port: the associated devlink port structure
162846fe56SPrzemek Kitszel  * @pf: pointer to the PF private structure
172846fe56SPrzemek Kitszel  * @vsi: the VSI associated with this port
182846fe56SPrzemek Kitszel  * @repr_id: the representor ID
192846fe56SPrzemek Kitszel  * @sfnum: the subfunction ID
202846fe56SPrzemek Kitszel  * @sf_dev: pointer to the subfunction device
212846fe56SPrzemek Kitszel  *
222846fe56SPrzemek Kitszel  * An instance of a dynamically added devlink port. Each port flavour
232846fe56SPrzemek Kitszel  */
242846fe56SPrzemek Kitszel struct ice_dynamic_port {
252846fe56SPrzemek Kitszel 	u8 hw_addr[ETH_ALEN];
262846fe56SPrzemek Kitszel 	u8 active: 1;
272846fe56SPrzemek Kitszel 	u8 attached: 1;
282846fe56SPrzemek Kitszel 	struct devlink_port devlink_port;
292846fe56SPrzemek Kitszel 	struct ice_pf *pf;
302846fe56SPrzemek Kitszel 	struct ice_vsi *vsi;
312846fe56SPrzemek Kitszel 	unsigned long repr_id;
322846fe56SPrzemek Kitszel 	u32 sfnum;
332846fe56SPrzemek Kitszel 	/* Flavour-specific implementation data */
342846fe56SPrzemek Kitszel 	union {
352846fe56SPrzemek Kitszel 		struct ice_sf_dev *sf_dev;
362846fe56SPrzemek Kitszel 	};
372846fe56SPrzemek Kitszel };
382846fe56SPrzemek Kitszel 
392846fe56SPrzemek Kitszel void ice_dealloc_all_dynamic_ports(struct ice_pf *pf);
402846fe56SPrzemek Kitszel 
412846fe56SPrzemek Kitszel int ice_devlink_create_pf_port(struct ice_pf *pf);
422846fe56SPrzemek Kitszel void ice_devlink_destroy_pf_port(struct ice_pf *pf);
432846fe56SPrzemek Kitszel int ice_devlink_create_vf_port(struct ice_vf *vf);
442846fe56SPrzemek Kitszel void ice_devlink_destroy_vf_port(struct ice_vf *vf);
452846fe56SPrzemek Kitszel int ice_devlink_create_sf_port(struct ice_dynamic_port *dyn_port);
462846fe56SPrzemek Kitszel void ice_devlink_destroy_sf_port(struct ice_dynamic_port *dyn_port);
472846fe56SPrzemek Kitszel int ice_devlink_create_sf_dev_port(struct ice_sf_dev *sf_dev);
482846fe56SPrzemek Kitszel void ice_devlink_destroy_sf_dev_port(struct ice_sf_dev *sf_dev);
492846fe56SPrzemek Kitszel 
502846fe56SPrzemek Kitszel #define ice_devlink_port_to_dyn(port) \
512846fe56SPrzemek Kitszel 	container_of(port, struct ice_dynamic_port, devlink_port)
522846fe56SPrzemek Kitszel 
532846fe56SPrzemek Kitszel int
542846fe56SPrzemek Kitszel ice_devlink_port_new(struct devlink *devlink,
552846fe56SPrzemek Kitszel 		     const struct devlink_port_new_attrs *new_attr,
562846fe56SPrzemek Kitszel 		     struct netlink_ext_ack *extack,
572846fe56SPrzemek Kitszel 		     struct devlink_port **devlink_port);
582846fe56SPrzemek Kitszel #endif /* _DEVLINK_PORT_H_ */
59