// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2013 - 2021 Intel Corporation. */ #ifdef CONFIG_I40E_DCB #include <net/dcbnl.h> #include "i40e.h" #define I40E_DCBNL_STATUS_SUCCESS … #define I40E_DCBNL_STATUS_ERROR … static bool i40e_dcbnl_find_app(struct i40e_dcbx_config *cfg, struct i40e_dcb_app_priority_table *app); /** * i40e_get_pfc_delay - retrieve PFC Link Delay * @hw: pointer to hardware struct * @delay: holds the PFC Link delay value * * Returns PFC Link Delay from the PRTDCB_GENC.PFCLDA **/ static void i40e_get_pfc_delay(struct i40e_hw *hw, u16 *delay) { … } /** * i40e_dcbnl_ieee_getets - retrieve local IEEE ETS configuration * @dev: the corresponding netdev * @ets: structure to hold the ETS information * * Returns local IEEE ETS configuration **/ static int i40e_dcbnl_ieee_getets(struct net_device *dev, struct ieee_ets *ets) { … } /** * i40e_dcbnl_ieee_getpfc - retrieve local IEEE PFC configuration * @dev: the corresponding netdev * @pfc: structure to hold the PFC information * * Returns local IEEE PFC configuration **/ static int i40e_dcbnl_ieee_getpfc(struct net_device *dev, struct ieee_pfc *pfc) { … } /** * i40e_dcbnl_ieee_setets - set IEEE ETS configuration * @netdev: the corresponding netdev * @ets: structure to hold the ETS information * * Set IEEE ETS configuration **/ static int i40e_dcbnl_ieee_setets(struct net_device *netdev, struct ieee_ets *ets) { … } /** * i40e_dcbnl_ieee_setpfc - set local IEEE PFC configuration * @netdev: the corresponding netdev * @pfc: structure to hold the PFC information * * Sets local IEEE PFC configuration **/ static int i40e_dcbnl_ieee_setpfc(struct net_device *netdev, struct ieee_pfc *pfc) { … } /** * i40e_dcbnl_ieee_setapp - set local IEEE App configuration * @netdev: the corresponding netdev * @app: structure to hold the Application information * * Sets local IEEE App configuration **/ static int i40e_dcbnl_ieee_setapp(struct net_device *netdev, struct dcb_app *app) { … } /** * i40e_dcbnl_ieee_delapp - delete local IEEE App configuration * @netdev: the corresponding netdev * @app: structure to hold the Application information * * Deletes local IEEE App configuration other than the first application * required by firmware **/ static int i40e_dcbnl_ieee_delapp(struct net_device *netdev, struct dcb_app *app) { … } /** * i40e_dcbnl_getstate - Get DCB enabled state * @netdev: the corresponding netdev * * Get the current DCB enabled state **/ static u8 i40e_dcbnl_getstate(struct net_device *netdev) { … } /** * i40e_dcbnl_setstate - Set DCB state * @netdev: the corresponding netdev * @state: enable or disable * * Set the DCB state **/ static u8 i40e_dcbnl_setstate(struct net_device *netdev, u8 state) { … } /** * i40e_dcbnl_set_pg_tc_cfg_tx - Set CEE PG Tx config * @netdev: the corresponding netdev * @tc: the corresponding traffic class * @prio_type: the traffic priority type * @bwg_id: the BW group id the traffic class belongs to * @bw_pct: the BW percentage for the corresponding BWG * @up_map: prio mapped to corresponding tc * * Set Tx PG settings for CEE mode **/ static void i40e_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc, u8 prio_type, u8 bwg_id, u8 bw_pct, u8 up_map) { … } /** * i40e_dcbnl_set_pg_bwg_cfg_tx - Set CEE PG Tx BW config * @netdev: the corresponding netdev * @pgid: the corresponding traffic class * @bw_pct: the BW percentage for the specified traffic class * * Set Tx BW settings for CEE mode **/ static void i40e_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int pgid, u8 bw_pct) { … } /** * i40e_dcbnl_set_pg_tc_cfg_rx - Set CEE PG Rx config * @netdev: the corresponding netdev * @prio: the corresponding traffic class * @prio_type: the traffic priority type * @pgid: the BW group id the traffic class belongs to * @bw_pct: the BW percentage for the corresponding BWG * @up_map: prio mapped to corresponding tc * * Set Rx BW settings for CEE mode. The hardware does not support this * so we won't allow setting of this parameter. **/ static void i40e_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int __always_unused prio, u8 __always_unused prio_type, u8 __always_unused pgid, u8 __always_unused bw_pct, u8 __always_unused up_map) { … } /** * i40e_dcbnl_set_pg_bwg_cfg_rx - Set CEE PG Rx config * @netdev: the corresponding netdev * @pgid: the corresponding traffic class * @bw_pct: the BW percentage for the specified traffic class * * Set Rx BW settings for CEE mode. The hardware does not support this * so we won't allow setting of this parameter. **/ static void i40e_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int pgid, u8 bw_pct) { … } /** * i40e_dcbnl_get_pg_tc_cfg_tx - Get CEE PG Tx config * @netdev: the corresponding netdev * @prio: the corresponding user priority * @prio_type: traffic priority type * @pgid: the BW group ID the traffic class belongs to * @bw_pct: BW percentage for the corresponding BWG * @up_map: prio mapped to corresponding TC * * Get Tx PG settings for CEE mode **/ static void i40e_dcbnl_get_pg_tc_cfg_tx(struct net_device *netdev, int prio, u8 __always_unused *prio_type, u8 *pgid, u8 __always_unused *bw_pct, u8 __always_unused *up_map) { … } /** * i40e_dcbnl_get_pg_bwg_cfg_tx - Get CEE PG BW config * @netdev: the corresponding netdev * @pgid: the corresponding traffic class * @bw_pct: the BW percentage for the corresponding TC * * Get Tx BW settings for given TC in CEE mode **/ static void i40e_dcbnl_get_pg_bwg_cfg_tx(struct net_device *netdev, int pgid, u8 *bw_pct) { … } /** * i40e_dcbnl_get_pg_tc_cfg_rx - Get CEE PG Rx config * @netdev: the corresponding netdev * @prio: the corresponding user priority * @prio_type: the traffic priority type * @pgid: the PG ID * @bw_pct: the BW percentage for the corresponding BWG * @up_map: prio mapped to corresponding TC * * Get Rx PG settings for CEE mode. The UP2TC map is applied in same * manner for Tx and Rx (symmetrical) so return the TC information for * given priority accordingly. **/ static void i40e_dcbnl_get_pg_tc_cfg_rx(struct net_device *netdev, int prio, u8 *prio_type, u8 *pgid, u8 *bw_pct, u8 *up_map) { … } /** * i40e_dcbnl_get_pg_bwg_cfg_rx - Get CEE PG BW Rx config * @netdev: the corresponding netdev * @pgid: the corresponding traffic class * @bw_pct: the BW percentage for the corresponding TC * * Get Rx BW settings for given TC in CEE mode * The adapter doesn't support Rx ETS and runs in strict priority * mode in Rx path and hence just return 0. **/ static void i40e_dcbnl_get_pg_bwg_cfg_rx(struct net_device *netdev, int pgid, u8 *bw_pct) { … } /** * i40e_dcbnl_set_pfc_cfg - Set CEE PFC configuration * @netdev: the corresponding netdev * @prio: the corresponding user priority * @setting: the PFC setting for given priority * * Set the PFC enabled/disabled setting for given user priority **/ static void i40e_dcbnl_set_pfc_cfg(struct net_device *netdev, int prio, u8 setting) { … } /** * i40e_dcbnl_get_pfc_cfg - Get CEE PFC configuration * @netdev: the corresponding netdev * @prio: the corresponding user priority * @setting: the PFC setting for given priority * * Get the PFC enabled/disabled setting for given user priority **/ static void i40e_dcbnl_get_pfc_cfg(struct net_device *netdev, int prio, u8 *setting) { … } /** * i40e_dcbnl_cee_set_all - Commit CEE DCB settings to hardware * @netdev: the corresponding netdev * * Commit the current DCB configuration to hardware **/ static u8 i40e_dcbnl_cee_set_all(struct net_device *netdev) { … } /** * i40e_dcbnl_get_cap - Get DCBX capabilities of adapter * @netdev: the corresponding netdev * @capid: the capability type * @cap: the capability value * * Return the capability value for a given capability type **/ static u8 i40e_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap) { … } /** * i40e_dcbnl_getnumtcs - Get max number of traffic classes supported * @netdev: the corresponding netdev * @tcid: the TC id * @num: total number of TCs supported by the device * * Return the total number of TCs supported by the adapter **/ static int i40e_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num) { … } /** * i40e_dcbnl_setnumtcs - Set CEE number of traffic classes * @netdev: the corresponding netdev * @tcid: the TC id * @num: total number of TCs * * Set the total number of TCs (Unsupported) **/ static int i40e_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num) { … } /** * i40e_dcbnl_getpfcstate - Get CEE PFC mode * @netdev: the corresponding netdev * * Get the current PFC enabled state **/ static u8 i40e_dcbnl_getpfcstate(struct net_device *netdev) { … } /** * i40e_dcbnl_setpfcstate - Set CEE PFC mode * @netdev: the corresponding netdev * @state: required state * * The PFC state to be set; this is enabled/disabled based on the PFC * priority settings and not via this call for i40e driver **/ static void i40e_dcbnl_setpfcstate(struct net_device *netdev, u8 state) { … } /** * i40e_dcbnl_getapp - Get CEE APP * @netdev: the corresponding netdev * @idtype: the App selector * @id: the App ethtype or port number * * Return the CEE mode app for the given idtype and id **/ static int i40e_dcbnl_getapp(struct net_device *netdev, u8 idtype, u16 id) { … } /** * i40e_dcbnl_setdcbx - set required DCBx capability * @netdev: the corresponding netdev * @mode: new DCB mode managed or CEE+IEEE * * Set DCBx capability features **/ static u8 i40e_dcbnl_setdcbx(struct net_device *netdev, u8 mode) { … } /** * i40e_dcbnl_getdcbx - retrieve current DCBx capability * @dev: the corresponding netdev * * Returns DCBx capability features **/ static u8 i40e_dcbnl_getdcbx(struct net_device *dev) { … } /** * i40e_dcbnl_get_perm_hw_addr - MAC address used by DCBx * @dev: the corresponding netdev * @perm_addr: buffer to store the MAC address * * Returns the SAN MAC address used for LLDP exchange **/ static void i40e_dcbnl_get_perm_hw_addr(struct net_device *dev, u8 *perm_addr) { … } static const struct dcbnl_rtnl_ops dcbnl_ops = …; /** * i40e_dcbnl_set_all - set all the apps and ieee data from DCBx config * @vsi: the corresponding vsi * * Set up all the IEEE APPs in the DCBNL App Table and generate event for * other settings **/ void i40e_dcbnl_set_all(struct i40e_vsi *vsi) { … } /** * i40e_dcbnl_vsi_del_app - Delete APP for given VSI * @vsi: the corresponding vsi * @app: APP to delete * * Delete given APP from the DCBNL APP table for given * VSI **/ static int i40e_dcbnl_vsi_del_app(struct i40e_vsi *vsi, struct i40e_dcb_app_priority_table *app) { … } /** * i40e_dcbnl_del_app - Delete APP on all VSIs * @pf: the corresponding PF * @app: APP to delete * * Delete given APP from all the VSIs for given PF **/ static void i40e_dcbnl_del_app(struct i40e_pf *pf, struct i40e_dcb_app_priority_table *app) { … } /** * i40e_dcbnl_find_app - Search APP in given DCB config * @cfg: DCBX configuration data * @app: APP to search for * * Find given APP in the DCB configuration **/ static bool i40e_dcbnl_find_app(struct i40e_dcbx_config *cfg, struct i40e_dcb_app_priority_table *app) { … } /** * i40e_dcbnl_flush_apps - Delete all removed APPs * @pf: the corresponding PF * @old_cfg: old DCBX configuration data * @new_cfg: new DCBX configuration data * * Find and delete all APPs that are not present in the passed * DCB configuration **/ void i40e_dcbnl_flush_apps(struct i40e_pf *pf, struct i40e_dcbx_config *old_cfg, struct i40e_dcbx_config *new_cfg) { … } /** * i40e_dcbnl_setup - DCBNL setup * @vsi: the corresponding vsi * * Set up DCBNL ops and initial APP TLVs **/ void i40e_dcbnl_setup(struct i40e_vsi *vsi) { … } #endif /* CONFIG_I40E_DCB */