Commit df0676d1 authored by Alexander Duyck's avatar Alexander Duyck Committed by Jeff Kirsher
Browse files

ixgbe: Cleanup unpacking code for DCB



This is meant to be a generic clean-up of the remaining functions for
unpacking data from the DCB structures. The only real changes are:
replaced the variable i with tc for functions that were looping through the
traffic classes, and added a pointer for tc_class instead of path since
that way we only need to pull the pointer once instead of once per loop.

Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
Tested-by: default avatarRoss Brattain <ross.b.brattain@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 15cbc70e
Loading
Loading
Loading
Loading
+22 −25
Original line number Original line Diff line number Diff line
@@ -180,55 +180,52 @@ s32 ixgbe_dcb_calculate_tc_credits(struct ixgbe_hw *hw,


void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en)
void ixgbe_dcb_unpack_pfc(struct ixgbe_dcb_config *cfg, u8 *pfc_en)
{
{
	int i;
	struct tc_configuration *tc_config = &cfg->tc_config[0];
	int tc;


	*pfc_en = 0;
	for (*pfc_en = 0, tc = 0; tc < MAX_TRAFFIC_CLASS; tc++) {
	for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
		if (tc_config[tc].dcb_pfc != pfc_disabled)
		*pfc_en |= !!(cfg->tc_config[i].dcb_pfc & 0xF) << i;
			*pfc_en |= 1 << tc;
	}
}
}


void ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *cfg, int direction,
void ixgbe_dcb_unpack_refill(struct ixgbe_dcb_config *cfg, int direction,
			     u16 *refill)
			     u16 *refill)
{
{
	struct tc_bw_alloc *p;
	struct tc_configuration *tc_config = &cfg->tc_config[0];
	int i;
	int tc;


	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
		p = &cfg->tc_config[i].path[direction];
		refill[tc] = tc_config[tc].path[direction].data_credits_refill;
		refill[i] = p->data_credits_refill;
	}
}
}


void ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *cfg, u16 *max)
void ixgbe_dcb_unpack_max(struct ixgbe_dcb_config *cfg, u16 *max)
{
{
	int i;
	struct tc_configuration *tc_config = &cfg->tc_config[0];
	int tc;


	for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
		max[i] = cfg->tc_config[i].desc_credits_max;
		max[tc] = tc_config[tc].desc_credits_max;
}
}


void ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *cfg, int direction,
void ixgbe_dcb_unpack_bwgid(struct ixgbe_dcb_config *cfg, int direction,
			    u8 *bwgid)
			    u8 *bwgid)
{
{
	struct tc_bw_alloc *p;
	struct tc_configuration *tc_config = &cfg->tc_config[0];
	int i;
	int tc;


	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
		p = &cfg->tc_config[i].path[direction];
		bwgid[tc] = tc_config[tc].path[direction].bwg_id;
		bwgid[i] = p->bwg_id;
	}
}
}


void ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *cfg, int direction,
void ixgbe_dcb_unpack_prio(struct ixgbe_dcb_config *cfg, int direction,
			    u8 *ptype)
			    u8 *ptype)
{
{
	struct tc_bw_alloc *p;
	struct tc_configuration *tc_config = &cfg->tc_config[0];
	int i;
	int tc;


	for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
	for (tc = 0; tc < MAX_TRAFFIC_CLASS; tc++)
		p = &cfg->tc_config[i].path[direction];
		ptype[tc] = tc_config[tc].path[direction].prio_type;
		ptype[i] = p->prio_type;
	}
}
}


static u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg,
static u8 ixgbe_dcb_get_tc_from_up(struct ixgbe_dcb_config *cfg,