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