From: Jiri Pirko
> Sent: 14 April 2016 17:19
> From: Jiri Pirko <[email protected]>
>
> Structs are in arrays so use array index as pool/tc/prio index. With
> that, there is need to maintain separate arrays for ingress and egress.
...
> +static const u16 mlxsw_sp_pbs[] = {
> + 2 * MLXSW_SP_BYTES_TO_CELLS(ETH_FRAME_LEN),
> + 0,
> + 0,
> + 0,
> + 0,
> + 0,
> + 0,
> + 0,
> + 0, /* Unused */
> + 2 * MLXSW_SP_BYTES_TO_CELLS(MLXSW_PORT_MAX_MTU),
> };
Use designated initialisers.
>
> #define MLXSW_SP_PBS_LEN ARRAY_SIZE(mlxsw_sp_pbs)
> @@ -106,10 +96,9 @@ static int mlxsw_sp_port_pb_init(struct mlxsw_sp_port
> *mlxsw_sp_port)
> mlxsw_reg_pbmc_pack(pbmc_pl, mlxsw_sp_port->local_port,
> 0xffff, 0xffff / 2);
> for (i = 0; i < MLXSW_SP_PBS_LEN; i++) {
I'd rather see an explicit ARRAY_COUNT(mlxsw_sp_pbs) than some 'randon'
constant.
> - const struct mlxsw_sp_pb *pb;
> -
> - pb = &mlxsw_sp_pbs[i];
> - mlxsw_reg_pbmc_lossy_buffer_pack(pbmc_pl, pb->index, pb->size);
> + if (i == 8)
> + continue;
I'm guessing that is the same '8' as the commented 'unused' slot when
mlxsw_sp_pbs[]
is initialised.
Would be better if a named constant.
If this in initialisation code an illegal value (maybe 0xffff) to mark the
unused slot.
> + mlxsw_reg_pbmc_lossy_buffer_pack(pbmc_pl, i, mlxsw_sp_pbs[i]);
David