aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/ice/ice_lib.c
diff options
context:
space:
mode:
authorBruce Allan <bruce.w.allan@intel.com>2019-02-08 15:50:32 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2019-02-25 11:56:01 -0500
commit198a666a4543be1a6e48f4b701dd3bd9387d37c3 (patch)
tree6a73814a797af37f389e0c8576553a2be4e81341 /drivers/net/ethernet/intel/ice/ice_lib.c
parentc6dfd690f1c333475db1833ef3b5a4f4d6ba7365 (diff)
ice: fix stack hogs from struct ice_vsi_ctx structures
struct ice_vsi_ctx has gotten large enough that function local declarations of it on the stack are causing stack hogs. Fix that by allocating the structs on heap. Cleanup some formatting issues in the code around these changes and fix incorrect data type uses of returned functions in a couple places. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_lib.c')
-rw-r--r--drivers/net/ethernet/intel/ice/ice_lib.c98
1 files changed, 62 insertions, 36 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 82aae530d6c5..d93a0d5a783c 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -348,19 +348,25 @@ static int ice_get_free_slot(void *array, int size, int curr)
348void ice_vsi_delete(struct ice_vsi *vsi) 348void ice_vsi_delete(struct ice_vsi *vsi)
349{ 349{
350 struct ice_pf *pf = vsi->back; 350 struct ice_pf *pf = vsi->back;
351 struct ice_vsi_ctx ctxt; 351 struct ice_vsi_ctx *ctxt;
352 enum ice_status status; 352 enum ice_status status;
353 353
354 ctxt = devm_kzalloc(&pf->pdev->dev, sizeof(*ctxt), GFP_KERNEL);
355 if (!ctxt)
356 return;
357
354 if (vsi->type == ICE_VSI_VF) 358 if (vsi->type == ICE_VSI_VF)
355 ctxt.vf_num = vsi->vf_id; 359 ctxt->vf_num = vsi->vf_id;
356 ctxt.vsi_num = vsi->vsi_num; 360 ctxt->vsi_num = vsi->vsi_num;
357 361
358 memcpy(&ctxt.info, &vsi->info, sizeof(ctxt.info)); 362 memcpy(&ctxt->info, &vsi->info, sizeof(ctxt->info));
359 363
360 status = ice_free_vsi(&pf->hw, vsi->idx, &ctxt, false, NULL); 364 status = ice_free_vsi(&pf->hw, vsi->idx, ctxt, false, NULL);
361 if (status) 365 if (status)
362 dev_err(&pf->pdev->dev, "Failed to delete VSI %i in FW\n", 366 dev_err(&pf->pdev->dev, "Failed to delete VSI %i in FW\n",
363 vsi->vsi_num); 367 vsi->vsi_num);
368
369 devm_kfree(&pf->pdev->dev, ctxt);
364} 370}
365 371
366/** 372/**
@@ -908,37 +914,41 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
908 */ 914 */
909static int ice_vsi_init(struct ice_vsi *vsi) 915static int ice_vsi_init(struct ice_vsi *vsi)
910{ 916{
911 struct ice_vsi_ctx ctxt = { 0 };
912 struct ice_pf *pf = vsi->back; 917 struct ice_pf *pf = vsi->back;
913 struct ice_hw *hw = &pf->hw; 918 struct ice_hw *hw = &pf->hw;
919 struct ice_vsi_ctx *ctxt;
914 int ret = 0; 920 int ret = 0;
915 921
922 ctxt = devm_kzalloc(&pf->pdev->dev, sizeof(*ctxt), GFP_KERNEL);
923 if (!ctxt)
924 return -ENOMEM;
925
916 switch (vsi->type) { 926 switch (vsi->type) {
917 case ICE_VSI_PF: 927 case ICE_VSI_PF:
918 ctxt.flags = ICE_AQ_VSI_TYPE_PF; 928 ctxt->flags = ICE_AQ_VSI_TYPE_PF;
919 break; 929 break;
920 case ICE_VSI_VF: 930 case ICE_VSI_VF:
921 ctxt.flags = ICE_AQ_VSI_TYPE_VF; 931 ctxt->flags = ICE_AQ_VSI_TYPE_VF;
922 /* VF number here is the absolute VF number (0-255) */ 932 /* VF number here is the absolute VF number (0-255) */
923 ctxt.vf_num = vsi->vf_id + hw->func_caps.vf_base_id; 933 ctxt->vf_num = vsi->vf_id + hw->func_caps.vf_base_id;
924 break; 934 break;
925 default: 935 default:
926 return -ENODEV; 936 return -ENODEV;
927 } 937 }
928 938
929 ice_set_dflt_vsi_ctx(&ctxt); 939 ice_set_dflt_vsi_ctx(ctxt);
930 /* if the switch is in VEB mode, allow VSI loopback */ 940 /* if the switch is in VEB mode, allow VSI loopback */
931 if (vsi->vsw->bridge_mode == BRIDGE_MODE_VEB) 941 if (vsi->vsw->bridge_mode == BRIDGE_MODE_VEB)
932 ctxt.info.sw_flags |= ICE_AQ_VSI_SW_FLAG_ALLOW_LB; 942 ctxt->info.sw_flags |= ICE_AQ_VSI_SW_FLAG_ALLOW_LB;
933 943
934 /* Set LUT type and HASH type if RSS is enabled */ 944 /* Set LUT type and HASH type if RSS is enabled */
935 if (test_bit(ICE_FLAG_RSS_ENA, pf->flags)) 945 if (test_bit(ICE_FLAG_RSS_ENA, pf->flags))
936 ice_set_rss_vsi_ctx(&ctxt, vsi); 946 ice_set_rss_vsi_ctx(ctxt, vsi);
937 947
938 ctxt.info.sw_id = vsi->port_info->sw_id; 948 ctxt->info.sw_id = vsi->port_info->sw_id;
939 ice_vsi_setup_q_map(vsi, &ctxt); 949 ice_vsi_setup_q_map(vsi, ctxt);
940 950
941 ret = ice_add_vsi(hw, vsi->idx, &ctxt, NULL); 951 ret = ice_add_vsi(hw, vsi->idx, ctxt, NULL);
942 if (ret) { 952 if (ret) {
943 dev_err(&pf->pdev->dev, 953 dev_err(&pf->pdev->dev,
944 "Add VSI failed, err %d\n", ret); 954 "Add VSI failed, err %d\n", ret);
@@ -946,11 +956,12 @@ static int ice_vsi_init(struct ice_vsi *vsi)
946 } 956 }
947 957
948 /* keep context for update VSI operations */ 958 /* keep context for update VSI operations */
949 vsi->info = ctxt.info; 959 vsi->info = ctxt->info;
950 960
951 /* record VSI number returned */ 961 /* record VSI number returned */
952 vsi->vsi_num = ctxt.vsi_num; 962 vsi->vsi_num = ctxt->vsi_num;
953 963
964 devm_kfree(&pf->pdev->dev, ctxt);
954 return ret; 965 return ret;
955} 966}
956 967
@@ -1823,26 +1834,34 @@ int ice_vsi_manage_vlan_insertion(struct ice_vsi *vsi)
1823{ 1834{
1824 struct device *dev = &vsi->back->pdev->dev; 1835 struct device *dev = &vsi->back->pdev->dev;
1825 struct ice_hw *hw = &vsi->back->hw; 1836 struct ice_hw *hw = &vsi->back->hw;
1826 struct ice_vsi_ctx ctxt = { 0 }; 1837 struct ice_vsi_ctx *ctxt;
1827 enum ice_status status; 1838 enum ice_status status;
1839 int ret = 0;
1840
1841 ctxt = devm_kzalloc(dev, sizeof(*ctxt), GFP_KERNEL);
1842 if (!ctxt)
1843 return -ENOMEM;
1828 1844
1829 /* Here we are configuring the VSI to let the driver add VLAN tags by 1845 /* Here we are configuring the VSI to let the driver add VLAN tags by
1830 * setting vlan_flags to ICE_AQ_VSI_VLAN_MODE_ALL. The actual VLAN tag 1846 * setting vlan_flags to ICE_AQ_VSI_VLAN_MODE_ALL. The actual VLAN tag
1831 * insertion happens in the Tx hot path, in ice_tx_map. 1847 * insertion happens in the Tx hot path, in ice_tx_map.
1832 */ 1848 */
1833 ctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_MODE_ALL; 1849 ctxt->info.vlan_flags = ICE_AQ_VSI_VLAN_MODE_ALL;
1834 1850
1835 ctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID); 1851 ctxt->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);
1836 1852
1837 status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL); 1853 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL);
1838 if (status) { 1854 if (status) {
1839 dev_err(dev, "update VSI for VLAN insert failed, err %d aq_err %d\n", 1855 dev_err(dev, "update VSI for VLAN insert failed, err %d aq_err %d\n",
1840 status, hw->adminq.sq_last_status); 1856 status, hw->adminq.sq_last_status);
1841 return -EIO; 1857 ret = -EIO;
1858 goto out;
1842 } 1859 }
1843 1860
1844 vsi->info.vlan_flags = ctxt.info.vlan_flags; 1861 vsi->info.vlan_flags = ctxt->info.vlan_flags;
1845 return 0; 1862out:
1863 devm_kfree(dev, ctxt);
1864 return ret;
1846} 1865}
1847 1866
1848/** 1867/**
@@ -1854,35 +1873,42 @@ int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena)
1854{ 1873{
1855 struct device *dev = &vsi->back->pdev->dev; 1874 struct device *dev = &vsi->back->pdev->dev;
1856 struct ice_hw *hw = &vsi->back->hw; 1875 struct ice_hw *hw = &vsi->back->hw;
1857 struct ice_vsi_ctx ctxt = { 0 }; 1876 struct ice_vsi_ctx *ctxt;
1858 enum ice_status status; 1877 enum ice_status status;
1878 int ret = 0;
1879
1880 ctxt = devm_kzalloc(dev, sizeof(*ctxt), GFP_KERNEL);
1881 if (!ctxt)
1882 return -ENOMEM;
1859 1883
1860 /* Here we are configuring what the VSI should do with the VLAN tag in 1884 /* Here we are configuring what the VSI should do with the VLAN tag in
1861 * the Rx packet. We can either leave the tag in the packet or put it in 1885 * the Rx packet. We can either leave the tag in the packet or put it in
1862 * the Rx descriptor. 1886 * the Rx descriptor.
1863 */ 1887 */
1864 if (ena) { 1888 if (ena)
1865 /* Strip VLAN tag from Rx packet and put it in the desc */ 1889 /* Strip VLAN tag from Rx packet and put it in the desc */
1866 ctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_STR_BOTH; 1890 ctxt->info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_STR_BOTH;
1867 } else { 1891 else
1868 /* Disable stripping. Leave tag in packet */ 1892 /* Disable stripping. Leave tag in packet */
1869 ctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_NOTHING; 1893 ctxt->info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_NOTHING;
1870 }
1871 1894
1872 /* Allow all packets untagged/tagged */ 1895 /* Allow all packets untagged/tagged */
1873 ctxt.info.vlan_flags |= ICE_AQ_VSI_VLAN_MODE_ALL; 1896 ctxt->info.vlan_flags |= ICE_AQ_VSI_VLAN_MODE_ALL;
1874 1897
1875 ctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID); 1898 ctxt->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);
1876 1899
1877 status = ice_update_vsi(hw, vsi->idx, &ctxt, NULL); 1900 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL);
1878 if (status) { 1901 if (status) {
1879 dev_err(dev, "update VSI for VLAN strip failed, ena = %d err %d aq_err %d\n", 1902 dev_err(dev, "update VSI for VLAN strip failed, ena = %d err %d aq_err %d\n",
1880 ena, status, hw->adminq.sq_last_status); 1903 ena, status, hw->adminq.sq_last_status);
1881 return -EIO; 1904 ret = -EIO;
1905 goto out;
1882 } 1906 }
1883 1907
1884 vsi->info.vlan_flags = ctxt.info.vlan_flags; 1908 vsi->info.vlan_flags = ctxt->info.vlan_flags;
1885 return 0; 1909out:
1910 devm_kfree(dev, ctxt);
1911 return ret;
1886} 1912}
1887 1913
1888/** 1914/**