4444#define DCB_NO_HW_CHG 1 /* DCB configuration did not change */
4545#define DCB_HW_CHG 2 /* DCB configuration changed, no reset */
4646
47- int ixgbe_copy_dcb_cfg (struct ixgbe_dcb_config * src_dcb_cfg ,
48- struct ixgbe_dcb_config * dst_dcb_cfg , int tc_max )
47+ int ixgbe_copy_dcb_cfg (struct ixgbe_dcb_config * scfg ,
48+ struct ixgbe_dcb_config * dcfg , int tc_max )
4949{
50- struct tc_configuration * src_tc_cfg = NULL ;
51- struct tc_configuration * dst_tc_cfg = NULL ;
52- int i ;
50+ struct tc_configuration * src = NULL ;
51+ struct tc_configuration * dst = NULL ;
52+ int i , j ;
53+ int tx = DCB_TX_CONFIG ;
54+ int rx = DCB_RX_CONFIG ;
55+ int changes = 0 ;
5356
54- if (!src_dcb_cfg || !dst_dcb_cfg )
55- return - EINVAL ;
57+ if (!scfg || !dcfg )
58+ return changes ;
5659
5760 for (i = DCB_PG_ATTR_TC_0 ; i < tc_max + DCB_PG_ATTR_TC_0 ; i ++ ) {
58- src_tc_cfg = & src_dcb_cfg -> tc_config [i - DCB_PG_ATTR_TC_0 ];
59- dst_tc_cfg = & dst_dcb_cfg -> tc_config [i - DCB_PG_ATTR_TC_0 ];
61+ src = & scfg -> tc_config [i - DCB_PG_ATTR_TC_0 ];
62+ dst = & dcfg -> tc_config [i - DCB_PG_ATTR_TC_0 ];
6063
61- dst_tc_cfg -> path [DCB_TX_CONFIG ].prio_type =
62- src_tc_cfg -> path [DCB_TX_CONFIG ].prio_type ;
64+ if (dst -> path [tx ].prio_type != src -> path [tx ].prio_type ) {
65+ dst -> path [tx ].prio_type = src -> path [tx ].prio_type ;
66+ changes |= BIT_PG_TX ;
67+ }
6368
64- dst_tc_cfg -> path [DCB_TX_CONFIG ].bwg_id =
65- src_tc_cfg -> path [DCB_TX_CONFIG ].bwg_id ;
69+ if (dst -> path [tx ].bwg_id != src -> path [tx ].bwg_id ) {
70+ dst -> path [tx ].bwg_id = src -> path [tx ].bwg_id ;
71+ changes |= BIT_PG_TX ;
72+ }
6673
67- dst_tc_cfg -> path [DCB_TX_CONFIG ].bwg_percent =
68- src_tc_cfg -> path [DCB_TX_CONFIG ].bwg_percent ;
74+ if (dst -> path [tx ].bwg_percent != src -> path [tx ].bwg_percent ) {
75+ dst -> path [tx ].bwg_percent = src -> path [tx ].bwg_percent ;
76+ changes |= BIT_PG_TX ;
77+ }
6978
70- dst_tc_cfg -> path [DCB_TX_CONFIG ].up_to_tc_bitmap =
71- src_tc_cfg -> path [DCB_TX_CONFIG ].up_to_tc_bitmap ;
79+ if (dst -> path [tx ].up_to_tc_bitmap !=
80+ src -> path [tx ].up_to_tc_bitmap ) {
81+ dst -> path [tx ].up_to_tc_bitmap =
82+ src -> path [tx ].up_to_tc_bitmap ;
83+ changes |= (BIT_PG_TX | BIT_PFC | BIT_APP_UPCHG );
84+ }
7285
73- dst_tc_cfg -> path [DCB_RX_CONFIG ].prio_type =
74- src_tc_cfg -> path [DCB_RX_CONFIG ].prio_type ;
86+ if (dst -> path [rx ].prio_type != src -> path [rx ].prio_type ) {
87+ dst -> path [rx ].prio_type = src -> path [rx ].prio_type ;
88+ changes |= BIT_PG_RX ;
89+ }
7590
76- dst_tc_cfg -> path [DCB_RX_CONFIG ].bwg_id =
77- src_tc_cfg -> path [DCB_RX_CONFIG ].bwg_id ;
91+ if (dst -> path [rx ].bwg_id != src -> path [rx ].bwg_id ) {
92+ dst -> path [rx ].bwg_id = src -> path [rx ].bwg_id ;
93+ changes |= BIT_PG_RX ;
94+ }
7895
79- dst_tc_cfg -> path [DCB_RX_CONFIG ].bwg_percent =
80- src_tc_cfg -> path [DCB_RX_CONFIG ].bwg_percent ;
96+ if (dst -> path [rx ].bwg_percent != src -> path [rx ].bwg_percent ) {
97+ dst -> path [rx ].bwg_percent = src -> path [rx ].bwg_percent ;
98+ changes |= BIT_PG_RX ;
99+ }
81100
82- dst_tc_cfg -> path [DCB_RX_CONFIG ].up_to_tc_bitmap =
83- src_tc_cfg -> path [DCB_RX_CONFIG ].up_to_tc_bitmap ;
101+ if (dst -> path [rx ].up_to_tc_bitmap !=
102+ src -> path [rx ].up_to_tc_bitmap ) {
103+ dst -> path [rx ].up_to_tc_bitmap =
104+ src -> path [rx ].up_to_tc_bitmap ;
105+ changes |= (BIT_PG_RX | BIT_PFC | BIT_APP_UPCHG );
106+ }
84107 }
85108
86109 for (i = DCB_PG_ATTR_BW_ID_0 ; i < DCB_PG_ATTR_BW_ID_MAX ; i ++ ) {
87- dst_dcb_cfg -> bw_percentage [DCB_TX_CONFIG ]
88- [i - DCB_PG_ATTR_BW_ID_0 ] = src_dcb_cfg -> bw_percentage
89- [DCB_TX_CONFIG ][i - DCB_PG_ATTR_BW_ID_0 ];
90- dst_dcb_cfg -> bw_percentage [DCB_RX_CONFIG ]
91- [i - DCB_PG_ATTR_BW_ID_0 ] = src_dcb_cfg -> bw_percentage
92- [DCB_RX_CONFIG ][i - DCB_PG_ATTR_BW_ID_0 ];
110+ j = i - DCB_PG_ATTR_BW_ID_0 ;
111+ if (dcfg -> bw_percentage [tx ][j ] != scfg -> bw_percentage [tx ][j ]) {
112+ dcfg -> bw_percentage [tx ][j ] = scfg -> bw_percentage [tx ][j ];
113+ changes |= BIT_PG_TX ;
114+ }
115+ if (dcfg -> bw_percentage [rx ][j ] != scfg -> bw_percentage [rx ][j ]) {
116+ dcfg -> bw_percentage [rx ][j ] = scfg -> bw_percentage [rx ][j ];
117+ changes |= BIT_PG_RX ;
118+ }
93119 }
94120
95121 for (i = DCB_PFC_UP_ATTR_0 ; i < DCB_PFC_UP_ATTR_MAX ; i ++ ) {
96- dst_dcb_cfg -> tc_config [i - DCB_PFC_UP_ATTR_0 ].dcb_pfc =
97- src_dcb_cfg -> tc_config [i - DCB_PFC_UP_ATTR_0 ].dcb_pfc ;
122+ j = i - DCB_PFC_UP_ATTR_0 ;
123+ if (dcfg -> tc_config [j ].dcb_pfc != scfg -> tc_config [j ].dcb_pfc ) {
124+ dcfg -> tc_config [j ].dcb_pfc = scfg -> tc_config [j ].dcb_pfc ;
125+ changes |= BIT_PFC ;
126+ }
98127 }
99128
100- dst_dcb_cfg -> pfc_mode_enable = src_dcb_cfg -> pfc_mode_enable ;
129+ if (dcfg -> pfc_mode_enable != scfg -> pfc_mode_enable ) {
130+ dcfg -> pfc_mode_enable = scfg -> pfc_mode_enable ;
131+ changes |= BIT_PFC ;
132+ }
101133
102- return 0 ;
134+ return changes ;
103135}
104136
105137static u8 ixgbe_dcbnl_get_state (struct net_device * netdev )
@@ -179,20 +211,6 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_tx(struct net_device *netdev, int tc,
179211 if (up_map != DCB_ATTR_VALUE_UNDEFINED )
180212 adapter -> temp_dcb_cfg .tc_config [tc ].path [0 ].up_to_tc_bitmap =
181213 up_map ;
182-
183- if ((adapter -> temp_dcb_cfg .tc_config [tc ].path [0 ].prio_type !=
184- adapter -> dcb_cfg .tc_config [tc ].path [0 ].prio_type ) ||
185- (adapter -> temp_dcb_cfg .tc_config [tc ].path [0 ].bwg_id !=
186- adapter -> dcb_cfg .tc_config [tc ].path [0 ].bwg_id ) ||
187- (adapter -> temp_dcb_cfg .tc_config [tc ].path [0 ].bwg_percent !=
188- adapter -> dcb_cfg .tc_config [tc ].path [0 ].bwg_percent ) ||
189- (adapter -> temp_dcb_cfg .tc_config [tc ].path [0 ].up_to_tc_bitmap !=
190- adapter -> dcb_cfg .tc_config [tc ].path [0 ].up_to_tc_bitmap ))
191- adapter -> dcb_set_bitmap |= BIT_PG_TX ;
192-
193- if (adapter -> temp_dcb_cfg .tc_config [tc ].path [0 ].up_to_tc_bitmap !=
194- adapter -> dcb_cfg .tc_config [tc ].path [0 ].up_to_tc_bitmap )
195- adapter -> dcb_set_bitmap |= BIT_PFC | BIT_APP_UPCHG ;
196214}
197215
198216static void ixgbe_dcbnl_set_pg_bwg_cfg_tx (struct net_device * netdev , int bwg_id ,
@@ -201,10 +219,6 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_tx(struct net_device *netdev, int bwg_id,
201219 struct ixgbe_adapter * adapter = netdev_priv (netdev );
202220
203221 adapter -> temp_dcb_cfg .bw_percentage [0 ][bwg_id ] = bw_pct ;
204-
205- if (adapter -> temp_dcb_cfg .bw_percentage [0 ][bwg_id ] !=
206- adapter -> dcb_cfg .bw_percentage [0 ][bwg_id ])
207- adapter -> dcb_set_bitmap |= BIT_PG_TX ;
208222}
209223
210224static void ixgbe_dcbnl_set_pg_tc_cfg_rx (struct net_device * netdev , int tc ,
@@ -223,20 +237,6 @@ static void ixgbe_dcbnl_set_pg_tc_cfg_rx(struct net_device *netdev, int tc,
223237 if (up_map != DCB_ATTR_VALUE_UNDEFINED )
224238 adapter -> temp_dcb_cfg .tc_config [tc ].path [1 ].up_to_tc_bitmap =
225239 up_map ;
226-
227- if ((adapter -> temp_dcb_cfg .tc_config [tc ].path [1 ].prio_type !=
228- adapter -> dcb_cfg .tc_config [tc ].path [1 ].prio_type ) ||
229- (adapter -> temp_dcb_cfg .tc_config [tc ].path [1 ].bwg_id !=
230- adapter -> dcb_cfg .tc_config [tc ].path [1 ].bwg_id ) ||
231- (adapter -> temp_dcb_cfg .tc_config [tc ].path [1 ].bwg_percent !=
232- adapter -> dcb_cfg .tc_config [tc ].path [1 ].bwg_percent ) ||
233- (adapter -> temp_dcb_cfg .tc_config [tc ].path [1 ].up_to_tc_bitmap !=
234- adapter -> dcb_cfg .tc_config [tc ].path [1 ].up_to_tc_bitmap ))
235- adapter -> dcb_set_bitmap |= BIT_PG_RX ;
236-
237- if (adapter -> temp_dcb_cfg .tc_config [tc ].path [1 ].up_to_tc_bitmap !=
238- adapter -> dcb_cfg .tc_config [tc ].path [1 ].up_to_tc_bitmap )
239- adapter -> dcb_set_bitmap |= BIT_PFC ;
240240}
241241
242242static void ixgbe_dcbnl_set_pg_bwg_cfg_rx (struct net_device * netdev , int bwg_id ,
@@ -245,10 +245,6 @@ static void ixgbe_dcbnl_set_pg_bwg_cfg_rx(struct net_device *netdev, int bwg_id,
245245 struct ixgbe_adapter * adapter = netdev_priv (netdev );
246246
247247 adapter -> temp_dcb_cfg .bw_percentage [1 ][bwg_id ] = bw_pct ;
248-
249- if (adapter -> temp_dcb_cfg .bw_percentage [1 ][bwg_id ] !=
250- adapter -> dcb_cfg .bw_percentage [1 ][bwg_id ])
251- adapter -> dcb_set_bitmap |= BIT_PG_RX ;
252248}
253249
254250static void ixgbe_dcbnl_get_pg_tc_cfg_tx (struct net_device * netdev , int tc ,
@@ -298,10 +294,8 @@ static void ixgbe_dcbnl_set_pfc_cfg(struct net_device *netdev, int priority,
298294
299295 adapter -> temp_dcb_cfg .tc_config [priority ].dcb_pfc = setting ;
300296 if (adapter -> temp_dcb_cfg .tc_config [priority ].dcb_pfc !=
301- adapter -> dcb_cfg .tc_config [priority ].dcb_pfc ) {
302- adapter -> dcb_set_bitmap |= BIT_PFC ;
297+ adapter -> dcb_cfg .tc_config [priority ].dcb_pfc )
303298 adapter -> temp_dcb_cfg .pfc_mode_enable = true;
304- }
305299}
306300
307301static void ixgbe_dcbnl_get_pfc_cfg (struct net_device * netdev , int priority ,
@@ -336,7 +330,8 @@ static void ixgbe_dcbnl_devreset(struct net_device *dev)
336330static u8 ixgbe_dcbnl_set_all (struct net_device * netdev )
337331{
338332 struct ixgbe_adapter * adapter = netdev_priv (netdev );
339- int ret , i ;
333+ int ret = DCB_NO_HW_CHG ;
334+ int i ;
340335#ifdef IXGBE_FCOE
341336 struct dcb_app app = {
342337 .selector = DCB_APP_IDTYPE_ETHTYPE ,
@@ -355,12 +350,13 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
355350
356351 /* Fail command if not in CEE mode */
357352 if (!(adapter -> dcbx_cap & DCB_CAP_DCBX_VER_CEE ))
358- return 1 ;
353+ return ret ;
359354
360- ret = ixgbe_copy_dcb_cfg (& adapter -> temp_dcb_cfg , & adapter -> dcb_cfg ,
361- MAX_TRAFFIC_CLASS );
362- if (ret )
363- return DCB_NO_HW_CHG ;
355+ adapter -> dcb_set_bitmap |= ixgbe_copy_dcb_cfg (& adapter -> temp_dcb_cfg ,
356+ & adapter -> dcb_cfg ,
357+ MAX_TRAFFIC_CLASS );
358+ if (!adapter -> dcb_set_bitmap )
359+ return ret ;
364360
365361 if (adapter -> dcb_cfg .pfc_mode_enable ) {
366362 switch (adapter -> hw .mac .type ) {
@@ -420,6 +416,8 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
420416
421417 for (i = 0 ; i < IEEE_8021QAZ_MAX_TCS ; i ++ )
422418 netdev_set_prio_tc_map (netdev , i , prio_tc [i ]);
419+
420+ ret = DCB_HW_CHG_RST ;
423421 }
424422
425423 if (adapter -> dcb_set_bitmap & BIT_PFC ) {
@@ -430,7 +428,8 @@ static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)
430428 DCB_TX_CONFIG , prio_tc );
431429 ixgbe_dcb_unpack_pfc (& adapter -> dcb_cfg , & pfc_en );
432430 ixgbe_dcb_hw_pfc_config (& adapter -> hw , pfc_en , prio_tc );
433- ret = DCB_HW_CHG ;
431+ if (ret != DCB_HW_CHG_RST )
432+ ret = DCB_HW_CHG ;
434433 }
435434
436435 if (adapter -> dcb_cfg .pfc_mode_enable )
@@ -531,9 +530,6 @@ static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
531530 struct ixgbe_adapter * adapter = netdev_priv (netdev );
532531
533532 adapter -> temp_dcb_cfg .pfc_mode_enable = state ;
534- if (adapter -> temp_dcb_cfg .pfc_mode_enable !=
535- adapter -> dcb_cfg .pfc_mode_enable )
536- adapter -> dcb_set_bitmap |= BIT_PFC ;
537533}
538534
539535/**
0 commit comments