src/dpdk/drivers/net/ixgbe/base/ixgbe_dcb.c
s32 ixgbe_dcb_check_config_cee(struct ixgbe_dcb_config *dcb_config)
{
	struct ixgbe_dcb_tc_path *p;
	s32 ret_val = IXGBE_SUCCESS;
	u8 i, j, bw = 0, bw_id;
	u8 bw_sum[2][IXGBE_DCB_MAX_BW_GROUP];
	bool link_strict[2][IXGBE_DCB_MAX_BW_GROUP];

	memset(bw_sum, 0, sizeof(bw_sum));
	memset(link_strict, 0, sizeof(link_strict));

	/* First Tx, then Rx */
	for (i = 0; i < 2; i++) {
		/* Check each traffic class for rule violation */
		for (j = 0; j < IXGBE_DCB_MAX_TRAFFIC_CLASS; j++) {
			p = &dcb_config->tc_config[j].path[i];

			bw = p->bwg_percent;
			bw_id = p->bwg_id;

			if (bw_id >= IXGBE_DCB_MAX_BW_GROUP) {
				ret_val = IXGBE_ERR_CONFIG;
				goto err_config;
			}
			if (p->tsa == ixgbe_dcb_tsa_strict) {
				link_strict[i][bw_id] = true;
				/* Link strict should have zero bandwidth */
				if (bw) {
					ret_val = IXGBE_ERR_CONFIG;
					goto err_config;
				}
			} else if (!bw) {
				/*
				 * Traffic classes without link strict
				 * should have non-zero bandwidth.
				 */
				ret_val = IXGBE_ERR_CONFIG;
				goto err_config;
			}
			bw_sum[i][bw_id] += bw;
		}

		bw = 0;

		/* Check each bandwidth group for rule violation */
		for (j = 0; j < IXGBE_DCB_MAX_BW_GROUP; j++) {
			bw += dcb_config->bw_percentage[i][j];
			/*
			 * Sum of bandwidth percentages of all traffic classes
			 * within a Bandwidth Group must total 100 except for
			 * link strict group (zero bandwidth).
			 */
			if (link_strict[i][j]) {
				if (bw_sum[i][j]) {
					/*
					 * Link strict group should have zero
					 * bandwidth.
					 */
					ret_val = IXGBE_ERR_CONFIG;
					goto err_config;
				}
			} else if (bw_sum[i][j] != IXGBE_DCB_BW_PERCENT &&
				   bw_sum[i][j] != 0) {
				ret_val = IXGBE_ERR_CONFIG;
				goto err_config;
			}
		}

		if (bw != IXGBE_DCB_BW_PERCENT) {
			ret_val = IXGBE_ERR_CONFIG;
			goto err_config;
		}
	}

err_config:

	return ret_val;
}
/**
 * ixgbe_dcb_config - Struct containing DCB settings.
 * @dcb_config: Pointer to DCB config structure
 *
 * This function checks DCB rules for DCB settings.
 * The following rules are checked:
 * 1. The sum of bandwidth percentages of all Bandwidth Groups must total 100%.
 * 2. The sum of bandwidth percentages of all Traffic Classes within a Bandwidth
 *   Group must total 100.
 * 3. A Traffic Class should not be set to both Link Strict Priority
 *   and Group Strict Priority.
 * 4. Link strict Bandwidth Groups can only have link strict traffic classes
 *   with zero bandwidth.
 */
Struct containing DCB settings.
@dcb_config: Pointer to DCB config structure

This function checks DCB rules for DCB settings.
The following rules are checked:
1. The sum of bandwidth percentages of all Bandwidth Groups must total 100%.
2. The sum of bandwidth percentages of all Traffic Classes within a Bandwidth
Group must total 100.
3. A Traffic Class should not be set to both Link Strict Priority
and Group Strict Priority.
4. Link strict Bandwidth Groups can only have link strict traffic classes
with zero bandwidth.
Struct containing DCB settings . @dcb_config : Pointer to DCB config structure This function checks DCB rules for DCB settings . The following rules are checked : 1 . The sum of bandwidth percentages of all Bandwidth Groups must total 100% . 2 . The sum of bandwidth percentages of all Traffic Classes within a Bandwidth Group must total 100 . 3 . A Traffic Class should not be set to both Link Strict Priority and Group Strict Priority . 4 . Link strict Bandwidth Groups can only have link strict traffic classes with zero bandwidth .
s32 ixgbe_dcb_check_config_cee(struct ixgbe_dcb_config *dcb_config)
{
	struct ixgbe_dcb_tc_path *p;
	s32 ret_val = IXGBE_SUCCESS;
	u8 i, j, bw = 0, bw_id;
	u8 bw_sum[2][IXGBE_DCB_MAX_BW_GROUP];
	bool link_strict[2][IXGBE_DCB_MAX_BW_GROUP];
	memset(bw_sum, 0, sizeof(bw_sum));
	memset(link_strict, 0, sizeof(link_strict));
	for (i = 0; i < 2; i++) {
		for (j = 0; j < IXGBE_DCB_MAX_TRAFFIC_CLASS; j++) {
			p = &dcb_config->tc_config[j].path[i];
			bw = p->bwg_percent;
			bw_id = p->bwg_id;
			if (bw_id >= IXGBE_DCB_MAX_BW_GROUP) {
				ret_val = IXGBE_ERR_CONFIG;
				goto err_config;
			}
			if (p->tsa == ixgbe_dcb_tsa_strict) {
				link_strict[i][bw_id] = true;
				if (bw) {
					ret_val = IXGBE_ERR_CONFIG;
					goto err_config;
				}
			} else if (!bw) {
				ret_val = IXGBE_ERR_CONFIG;
				goto err_config;
			}
			bw_sum[i][bw_id] += bw;
		}
		bw = 0;
		for (j = 0; j < IXGBE_DCB_MAX_BW_GROUP; j++) {
			bw += dcb_config->bw_percentage[i][j];
			if (link_strict[i][j]) {
				if (bw_sum[i][j]) {
					ret_val = IXGBE_ERR_CONFIG;
					goto err_config;
				}
			} else if (bw_sum[i][j] != IXGBE_DCB_BW_PERCENT &&
				   bw_sum[i][j] != 0) {
				ret_val = IXGBE_ERR_CONFIG;
				goto err_config;
			}
		}
		if (bw != IXGBE_DCB_BW_PERCENT) {
			ret_val = IXGBE_ERR_CONFIG;
			goto err_config;
		}
	}
err_config:
	return ret_val;
}
s32 ixgbe_dcb_check_config_cee ( struct ixgbe_dcb_config * dcb_config ) { struct ixgbe_dcb_tc_path * p ; s32 ret_val = IXGBE_SUCCESS ; u8 i , j , bw = 0 , bw_id ; u8 bw_sum [ 2 ] [ IXGBE_DCB_MAX_BW_GROUP ] ; bool link_strict [ 2 ] [ IXGBE_DCB_MAX_BW_GROUP ] ; memset ( bw_sum , 0 , sizeof ( bw_sum ) ) ; memset ( link_strict , 0 , sizeof ( link_strict ) ) ; for ( i = 0 ; i < 2 ; i ++ ) { for ( j = 0 ; j < IXGBE_DCB_MAX_TRAFFIC_CLASS ; j ++ ) { p = & dcb_config -> tc_config [ j ] . path [ i ] ; bw = p -> bwg_percent ; bw_id = p -> bwg_id ; if ( bw_id >= IXGBE_DCB_MAX_BW_GROUP ) { ret_val = IXGBE_ERR_CONFIG ; goto err_config ; } if ( p -> tsa == ixgbe_dcb_tsa_strict ) { link_strict [ i ] [ bw_id ] = true ; if ( bw ) { ret_val = IXGBE_ERR_CONFIG ; goto err_config ; } } else if ( ! bw ) { ret_val = IXGBE_ERR_CONFIG ; goto err_config ; } bw_sum [ i ] [ bw_id ] += bw ; } bw = 0 ; for ( j = 0 ; j < IXGBE_DCB_MAX_BW_GROUP ; j ++ ) { bw += dcb_config -> bw_percentage [ i ] [ j ] ; if ( link_strict [ i ] [ j ] ) { if ( bw_sum [ i ] [ j ] ) { ret_val = IXGBE_ERR_CONFIG ; goto err_config ; } } else if ( bw_sum [ i ] [ j ] != IXGBE_DCB_BW_PERCENT && bw_sum [ i ] [ j ] != 0 ) { ret_val = IXGBE_ERR_CONFIG ; goto err_config ; } } if ( bw != IXGBE_DCB_BW_PERCENT ) { ret_val = IXGBE_ERR_CONFIG ; goto err_config ; } } err_config : return ret_val ; }
ixgbe_dcb_config - Struct containing DCB settings.
ixgbe_dcb_config - Struct containing DCB settings .
/* First Tx, then Rx */ /* Check each traffic class for rule violation */ /* Link strict should have zero bandwidth */ /*
				 * Traffic classes without link strict
				 * should have non-zero bandwidth.
				 */ /* Check each bandwidth group for rule violation */ /*
			 * Sum of bandwidth percentages of all traffic classes
			 * within a Bandwidth Group must total 100 except for
			 * link strict group (zero bandwidth).
			 */ /*
					 * Link strict group should have zero
					 * bandwidth.
					 */