Commit 3f9e4634 authored by Daniel Machon's avatar Daniel Machon Committed by Paolo Abeni
Browse files

net: sparx5: use SPX5_CONST for constants which already have a symbol



Now that we have indentified all the chip constants, update the use of
them where a symbol is already defined for the constant.

Reviewed-by: default avatarSteen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: default avatarDaniel Machon <daniel.machon@microchip.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent d5a1eb48
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ static enum sparx5_cal_bw sparx5_get_port_cal_speed(struct sparx5 *sparx5,
{
	struct sparx5_port *port;

	if (portno >= SPX5_PORTS) {
	if (portno >= sparx5->data->consts->n_ports) {
		/* Internal ports */
		if (portno == SPX5_PORT_CPU_0 || portno == SPX5_PORT_CPU_1) {
			/* Equals 1.25G */
@@ -159,6 +159,7 @@ static enum sparx5_cal_bw sparx5_get_port_cal_speed(struct sparx5 *sparx5,
/* Auto configure the QSYS calendar based on port configuration */
int sparx5_config_auto_calendar(struct sparx5 *sparx5)
{
	const struct sparx5_consts *consts = sparx5->data->consts;
	u32 cal[7], value, idx, portno;
	u32 max_core_bw;
	u32 total_bw = 0, used_port_bw = 0;
@@ -174,7 +175,7 @@ int sparx5_config_auto_calendar(struct sparx5 *sparx5)
	}

	/* Setup the calendar with the bandwidth to each port */
	for (portno = 0; portno < SPX5_PORTS_ALL; portno++) {
	for (portno = 0; portno < consts->n_ports_all; portno++) {
		u64 reg, offset, this_bw;

		spd = sparx5_get_port_cal_speed(sparx5, portno);
@@ -182,7 +183,7 @@ int sparx5_config_auto_calendar(struct sparx5 *sparx5)
			continue;

		this_bw = sparx5_cal_speed_to_value(spd);
		if (portno < SPX5_PORTS)
		if (portno < consts->n_ports)
			used_port_bw += this_bw;
		else
			/* Internal ports are granted half the value */
@@ -213,7 +214,7 @@ int sparx5_config_auto_calendar(struct sparx5 *sparx5)
		 sparx5, QSYS_CAL_CTRL);

	/* Assign port bandwidth to auto calendar */
	for (idx = 0; idx < ARRAY_SIZE(cal); idx++)
	for (idx = 0; idx < consts->n_auto_cals; idx++)
		spx5_wr(cal[idx], sparx5, QSYS_CAL_AUTO(idx));

	/* Increase grant rate of all ports to account for
@@ -304,7 +305,7 @@ static int sparx5_dsm_calendar_calc(struct sparx5 *sparx5, u32 taxi,
	for (idx = 0; idx < SPX5_DSM_CAL_MAX_DEVS_PER_TAXI; idx++) {
		u32 portno = data->taxi_ports[idx];

		if (portno < SPX5_TAXI_PORT_MAX) {
		if (portno < sparx5->data->consts->n_ports_all) {
			data->taxi_speeds[idx] = sparx5_cal_speed_to_value
				(sparx5_get_port_cal_speed(sparx5, portno));
		} else {
@@ -573,7 +574,7 @@ int sparx5_config_dsm_calendar(struct sparx5 *sparx5)
	if (!data)
		return -ENOMEM;

	for (taxi = 0; taxi < SPX5_DSM_CAL_TAXIS; ++taxi) {
	for (taxi = 0; taxi < sparx5->data->consts->n_dsm_cal_taxis; ++taxi) {
		err = sparx5_dsm_calendar_calc(sparx5, taxi, data);
		if (err) {
			dev_err(sparx5->dev, "DSM calendar calculation failed\n");
+3 −2
Original line number Diff line number Diff line
@@ -234,10 +234,11 @@ static int sparx5_dcb_ieee_dscp_setdel(struct net_device *dev,
						     struct dcb_app *))
{
	struct sparx5_port *port = netdev_priv(dev);
	struct sparx5 *sparx5 = port->sparx5;
	struct sparx5_port *port_itr;
	int err, i;

	for (i = 0; i < SPX5_PORTS; i++) {
	for (i = 0; i < sparx5->data->consts->n_ports; i++) {
		port_itr = port->sparx5->ports[i];
		if (!port_itr)
			continue;
@@ -386,7 +387,7 @@ int sparx5_dcb_init(struct sparx5 *sparx5)
	struct sparx5_port *port;
	int i;

	for (i = 0; i < SPX5_PORTS; i++) {
	for (i = 0; i < sparx5->data->consts->n_ports; i++) {
		port = sparx5->ports[i];
		if (!port)
			continue;
+5 −3
Original line number Diff line number Diff line
@@ -1122,7 +1122,7 @@ static void sparx5_update_stats(struct sparx5 *sparx5)
{
	int idx;

	for (idx = 0; idx < SPX5_PORTS; idx++)
	for (idx = 0; idx < sparx5->data->consts->n_ports; idx++)
		if (sparx5->ports[idx])
			sparx5_update_port_stats(sparx5, idx);
}
@@ -1228,6 +1228,7 @@ const struct ethtool_ops sparx5_ethtool_ops = {

int sparx_stats_init(struct sparx5 *sparx5)
{
	const struct sparx5_consts *consts = sparx5->data->consts;
	char queue_name[32];
	int portno;

@@ -1235,14 +1236,15 @@ int sparx_stats_init(struct sparx5 *sparx5)
	sparx5->num_stats = spx5_stats_count;
	sparx5->num_ethtool_stats = ARRAY_SIZE(sparx5_stats_layout);
	sparx5->stats = devm_kcalloc(sparx5->dev,
				     SPX5_PORTS_ALL * sparx5->num_stats,
				     consts->n_ports_all *
				     sparx5->num_stats,
				     sizeof(u64), GFP_KERNEL);
	if (!sparx5->stats)
		return -ENOMEM;

	mutex_init(&sparx5->queue_stats_lock);
	sparx5_config_stats(sparx5);
	for (portno = 0; portno < SPX5_PORTS; portno++)
	for (portno = 0; portno < consts->n_ports; portno++)
		if (sparx5->ports[portno])
			sparx5_config_port_stats(sparx5, portno);

+4 −2
Original line number Diff line number Diff line
@@ -156,7 +156,9 @@ static bool sparx5_fdma_rx_get_frame(struct sparx5 *sparx5, struct sparx5_rx *rx
	/* Now do the normal processing of the skb */
	sparx5_ifh_parse((u32 *)skb->data, &fi);
	/* Map to port netdev */
	port = fi.src_port < SPX5_PORTS ?  sparx5->ports[fi.src_port] : NULL;
	port = fi.src_port < sparx5->data->consts->n_ports ?
		       sparx5->ports[fi.src_port] :
		       NULL;
	if (!port || !port->ndev) {
		dev_err(sparx5->dev, "Data on inactive port %d\n", fi.src_port);
		sparx5_xtr_flush(sparx5, XTR_QUEUE);
@@ -296,7 +298,7 @@ static void sparx5_fdma_rx_init(struct sparx5 *sparx5,
	fdma->ops.dataptr_cb = &sparx5_fdma_rx_dataptr_cb;
	fdma->ops.nextptr_cb = &fdma_nextptr_cb;
	/* Fetch a netdev for SKB and NAPI use, any will do */
	for (idx = 0; idx < SPX5_PORTS; ++idx) {
	for (idx = 0; idx < sparx5->data->consts->n_ports; ++idx) {
		struct sparx5_port *port = sparx5->ports[idx];

		if (port && port->ndev) {
+4 −3
Original line number Diff line number Diff line
@@ -80,15 +80,16 @@ static void sparx5_mact_select(struct sparx5 *sparx5,
int sparx5_mact_learn(struct sparx5 *sparx5, int pgid,
		      const unsigned char mac[ETH_ALEN], u16 vid)
{
	const struct sparx5_consts *consts = sparx5->data->consts;
	int addr, type, ret;

	if (pgid < SPX5_PORTS) {
	if (pgid < consts->n_ports) {
		type = MAC_ENTRY_ADDR_TYPE_UPSID_PN;
		addr = pgid % 32;
		addr += (pgid / 32) << 5; /* Add upsid */
	} else {
		type = MAC_ENTRY_ADDR_TYPE_MC_IDX;
		addr = pgid - SPX5_PORTS;
		addr = pgid - consts->n_ports;
	}

	mutex_lock(&sparx5->lock);
@@ -371,7 +372,7 @@ static void sparx5_mact_handle_entry(struct sparx5 *sparx5,
		return;

	port = LRN_MAC_ACCESS_CFG_2_MAC_ENTRY_ADDR_GET(cfg2);
	if (port >= SPX5_PORTS)
	if (port >= sparx5->data->consts->n_ports)
		return;

	if (!test_bit(port, sparx5->bridge_mask))
Loading