Ramaxel inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4OENF CVE: NA
Driver and firmware properties negotiate optimization. After obtaining the attributes from the firmware. It intersects with the attributes supported by the driver.
Signed-off-by: Yanling Song songyl@ramaxel.com Reviewed-by: Yang Gan yanggan@ramaxel.com --- .../ethernet/ramaxel/spnic/hw/sphw_hwdev.c | 9 +++- .../ethernet/ramaxel/spnic/hw/sphw_hwdev.h | 2 + .../net/ethernet/ramaxel/spnic/spnic_main.c | 16 ++++---- .../ethernet/ramaxel/spnic/spnic_nic_cfg.c | 41 +++++++++++++------ .../ethernet/ramaxel/spnic/spnic_nic_cfg.h | 3 +- .../ethernet/ramaxel/spnic/spnic_nic_dev.h | 2 + 6 files changed, 50 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c index c88799bcda98..fc7d101a7fe3 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.c @@ -699,7 +699,8 @@ static void sphw_unsync_mgmt_func_state(struct sphw_hwdev *hwdev)
static int init_basic_attributes(struct sphw_hwdev *hwdev) { - int err; + u64 drv_feature[COMM_MAX_FEATURE_QWORD] = {SPHW_DRV_FEATURE_QW0}; + int err, i;
err = sphw_get_board_info(hwdev, &hwdev->board_info, SPHW_CHANNEL_COMM); if (err) @@ -711,7 +712,11 @@ static int init_basic_attributes(struct sphw_hwdev *hwdev) return err; }
- sdk_info(hwdev->dev_hdl, "Comm features: 0x%llx\n", hwdev->features[0]); + sdk_info(hwdev->dev_hdl, "Comm hw features: 0x%llx, drv features: 0x%llx\n", + hwdev->features[0], drv_feature[0]); + + for (i = 0; i < COMM_MAX_FEATURE_QWORD; i++) + hwdev->features[i] &= drv_feature[i];
err = sphw_get_global_attr(hwdev, &hwdev->glb_attr); if (err) { diff --git a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h index 451df0306e6c..bf0b93d9a4d2 100644 --- a/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h +++ b/drivers/net/ethernet/ramaxel/spnic/hw/sphw_hwdev.h @@ -90,4 +90,6 @@ struct sphw_hwdev { #define COMM_FEATURE_QW0(hwdev, feature) ((hwdev)->features[0] & COMM_F_##feature) #define COMM_SUPPORT_API_CHAIN(hwdev) COMM_FEATURE_QW0(hwdev, API_CHAIN)
+#define SPHW_DRV_FEATURE_QW0 COMM_F_API_CHAIN + #endif diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_main.c b/drivers/net/ethernet/ramaxel/spnic/spnic_main.c index 3670d92eaf2a..5b9822ebd806 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_main.c +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_main.c @@ -356,9 +356,13 @@ static void spnic_sw_deinit(struct spnic_nic_dev *nic_dev) static int spnic_sw_init(struct spnic_nic_dev *nic_dev) { struct net_device *netdev = nic_dev->netdev; - + u64 nic_feature; int err = 0;
+ nic_feature = spnic_get_feature_cap(nic_dev->hwdev); + nic_feature &= SPNIC_DRV_FEATURE; + spnic_update_nic_feature(nic_dev->hwdev, nic_feature); + sema_init(&nic_dev->port_state_sem, 1);
err = spnic_dcb_init(nic_dev); @@ -652,7 +656,6 @@ static int setup_nic_dev(struct net_device *netdev, struct spnic_lld_dev *lld_de
static int spnic_set_default_hw_feature(struct spnic_nic_dev *nic_dev) { - u64 nic_features; int err;
if (!SPNIC_FUNC_IS_VF(nic_dev->hwdev)) { @@ -663,8 +666,7 @@ static int spnic_set_default_hw_feature(struct spnic_nic_dev *nic_dev) } }
- nic_features = spnic_get_feature_cap(nic_dev->hwdev); - err = spnic_set_nic_feature(nic_dev->hwdev, &nic_features, 1); + err = spnic_set_nic_feature_to_hw(nic_dev->hwdev); if (err) { nic_err(&nic_dev->pdev->dev, "Failed to set nic features\n"); return err; @@ -729,13 +731,13 @@ static int nic_probe(struct spnic_lld_dev *lld_dev, void **uld_dev, char *uld_de goto init_nic_hwdev_err; }
- spnic_assign_netdev_ops(nic_dev); - netdev_feature_init(netdev); - err = spnic_sw_init(nic_dev); if (err) goto sw_init_err;
+ spnic_assign_netdev_ops(nic_dev); + netdev_feature_init(netdev); + err = spnic_set_default_hw_feature(nic_dev); if (err) goto set_features_err; diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.c b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.c index 24e55c087da5..d241f6a7947d 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.c +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.c @@ -795,14 +795,38 @@ static int nic_feature_nego(void *hwdev, u8 opcode, u64 *s_feature, u16 size) return 0; }
-int spnic_get_nic_feature(void *hwdev, u64 *s_feature, u16 size) +static int spnic_get_nic_feature_from_hw(void *hwdev, u64 *s_feature, u16 size) { return nic_feature_nego(hwdev, SPNIC_CMD_OP_GET, s_feature, size); }
-int spnic_set_nic_feature(void *hwdev, u64 *s_feature, u16 size) +int spnic_set_nic_feature_to_hw(void *hwdev) { - return nic_feature_nego(hwdev, SPNIC_CMD_OP_SET, s_feature, size); + struct spnic_nic_cfg *nic_cfg = NULL; + + nic_cfg = sphw_get_service_adapter(hwdev, SERVICE_T_NIC); + + return nic_feature_nego(hwdev, SPNIC_CMD_OP_SET, &nic_cfg->feature_cap, 1); +} + +u64 spnic_get_feature_cap(void *hwdev) +{ + struct spnic_nic_cfg *nic_cfg = NULL; + + nic_cfg = sphw_get_service_adapter(hwdev, SERVICE_T_NIC); + + return nic_cfg->feature_cap; +} + +void spnic_update_nic_feature(void *hwdev, u64 feature) +{ + struct spnic_nic_cfg *nic_cfg = NULL; + + nic_cfg = sphw_get_service_adapter(hwdev, SERVICE_T_NIC); + + nic_cfg->feature_cap = feature; + + nic_info(nic_cfg->dev_hdl, "Update nic feature to 0x%llx\n", nic_cfg->feature_cap); }
static inline int init_nic_hwdev_param_valid(void *hwdev, void *pcidev_hdl, void *dev_hdl) @@ -850,7 +874,7 @@ int spnic_init_nic_hwdev(void *hwdev, void *pcidev_hdl, void *dev_hdl, u16 rx_bu goto init_func_tbl_err; }
- err = spnic_get_nic_feature(hwdev, &nic_cfg->feature_cap, 1); + err = spnic_get_nic_feature_from_hw(hwdev, &nic_cfg->feature_cap, 1); if (err) { nic_err(nic_cfg->dev_hdl, "Failed to get nic features\n"); goto get_feature_err; @@ -1128,15 +1152,6 @@ int spnic_set_vlan_fliter(void *hwdev, u32 vlan_filter_ctrl) return 0; }
-u64 spnic_get_feature_cap(void *hwdev) -{ - struct spnic_nic_cfg *nic_cfg = NULL; - - nic_cfg = sphw_get_service_adapter(hwdev, SERVICE_T_NIC); - - return nic_cfg->feature_cap; -} - int spnic_add_tcam_rule(void *hwdev, struct nic_tcam_cfg_rule *tcam_rule) { u16 out_size = sizeof(struct nic_cmd_fdir_add_rule); diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.h b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.h index 8be8f5334f72..f280b41fe362 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.h +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_cfg.h @@ -703,6 +703,7 @@ int spnic_set_autoneg(void *hwdev, bool enable); int spnic_get_sfp_type(void *hwdev, u8 *sfp_type, u8 *sfp_type_ext); int spnic_get_sfp_eeprom(void *hwdev, u8 *data, u32 len);
-int spnic_set_nic_feature(void *hwdev, u64 *s_feature, u16 size); +int spnic_set_nic_feature_to_hw(void *hwdeve); +void spnic_update_nic_feature(void *hwdev, u64 feature);
#endif diff --git a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_dev.h b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_dev.h index 37068f1b48f2..8a0708fda19a 100644 --- a/drivers/net/ethernet/ramaxel/spnic/spnic_nic_dev.h +++ b/drivers/net/ethernet/ramaxel/spnic/spnic_nic_dev.h @@ -54,6 +54,8 @@ enum spnic_flags { #define VID_LINE(nic_dev, vid) ((vid) / VLAN_BITMAP_BITS_SIZE(nic_dev)) #define VID_COL(nic_dev, vid) ((vid) & (VLAN_BITMAP_BITS_SIZE(nic_dev) - 1))
+#define SPNIC_DRV_FEATURE NIC_F_ALL_MASK + enum spnic_event_work_flags { EVENT_WORK_TX_TIMEOUT, };