netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Roger Quadros <rogerq@kernel.org>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, s-vadapalli@ti.com, r-gunasekaran@ti.com,
	vigneshr@ti.com, srk@ti.com, horms@kernel.org, p-varis@ti.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: Re: [PATCH v6 net-next 5/7] net: ethernet: ti: am65-cpsw: add mqprio qdisc offload in channel mode
Date: Tue, 21 Nov 2023 01:03:14 +0200	[thread overview]
Message-ID: <20231120230314.tqozomqbd6jiqbf7@skbuf> (raw)
In-Reply-To: <20231120140147.78726-6-rogerq@kernel.org>

On Mon, Nov 20, 2023 at 04:01:45PM +0200, Roger Quadros wrote:
> +static int am65_cpsw_setup_mqprio(struct net_device *ndev, void *type_data)
> +{
> +	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
> +	struct am65_cpsw_mqprio *p_mqprio = &port->qos.mqprio;
> +	struct tc_mqprio_qopt_offload *mqprio = type_data;
> +	struct am65_cpsw_common *common = port->common;
> +	struct tc_mqprio_qopt *qopt = &mqprio->qopt;
> +	int i, tc, offset, count, prio, ret;
> +	u8 num_tc = qopt->num_tc;
> +	u32 tx_prio_map = 0;
> +
> +	memcpy(&p_mqprio->mqprio_hw, mqprio, sizeof(*mqprio));
> +
> +	ret = pm_runtime_get_sync(common->dev);
> +	if (ret < 0) {
> +		pm_runtime_put_noidle(common->dev);
> +		return ret;
> +	}
> +
> +	if (!num_tc) {
> +		am65_cpsw_reset_tc_mqprio(ndev);
> +		ret = -EINVAL;

num_tc == 0 is what signals the deletion of the mqprio qdisc.
Why return -EINVAL?

> +		goto exit_put;
> +	}
> +
> +	ret = am65_cpsw_mqprio_verify_shaper(port, mqprio);
> +	if (ret)
> +		goto exit_put;
> +
> +	netdev_set_num_tc(ndev, num_tc);
> +
> +	/* Multiple Linux priorities can map to a Traffic Class
> +	 * A Traffic Class can have multiple contiguous Queues,
> +	 * Queues get mapped to Channels (thread_id),
> +	 *	if not VLAN tagged, thread_id is used as packet_priority
> +	 *	if VLAN tagged. VLAN priority is used as packet_priority
> +	 * packet_priority gets mapped to header_priority in p0_rx_pri_map,
> +	 * header_priority gets mapped to switch_priority in pn_tx_pri_map.
> +	 * As p0_rx_pri_map is left at defaults (0x76543210), we can
> +	 * assume that Queue_n gets mapped to header_priority_n. We can then
> +	 * set the switch priority in pn_tx_pri_map.
> +	 */
> +
> +	for (tc = 0; tc < num_tc; tc++) {
> +		prio = tc;
> +
> +		/* For simplicity we assign the same priority (TCn) to
> +		 * all queues of a Traffic Class.
> +		 */
> +		for (i = qopt->offset[tc]; i < qopt->offset[tc] + qopt->count[tc]; i++)
> +			tx_prio_map |= prio << (4 * i);
> +
> +		count = qopt->count[tc];
> +		offset = qopt->offset[tc];
> +		netdev_set_tc_queue(ndev, tc, count, offset);
> +	}
> +
> +	writel(tx_prio_map, port->port_base + AM65_CPSW_PN_REG_TX_PRI_MAP);
> +
> +	am65_cpsw_tx_pn_shaper_apply(port);
> +
> +exit_put:
> +	pm_runtime_put(common->dev);
> +
> +	return ret;
> +}
> +
>  static int am65_cpsw_port_est_enabled(struct am65_cpsw_port *port)
>  {
>  	return port->qos.est_oper || port->qos.est_admin;
> @@ -737,16 +989,6 @@ static int am65_cpsw_qos_setup_tc_block(struct net_device *ndev, struct flow_blo
>  					  port, port, true);
>  }
>  
> -static u32
> -am65_cpsw_qos_tx_rate_calc(u32 rate_mbps, unsigned long bus_freq)
> -{
> -	u32 ir;
> -
> -	bus_freq /= 1000000;
> -	ir = DIV_ROUND_UP(((u64)rate_mbps * 32768),  bus_freq);
> -	return ir;
> -}
> -

Insufficient code movement in the previous patch?

  reply	other threads:[~2023-11-20 23:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 14:01 [PATCH v6 net-next 0/7] net: ethernet: am65-cpsw: Add mqprio, frame pre-emption & coalescing Roger Quadros
2023-11-20 14:01 ` [PATCH v6 net-next 1/7] net: ethernet: am65-cpsw: Build am65-cpsw-qos only if required Roger Quadros
2023-11-20 14:01 ` [PATCH v6 net-next 2/7] net: ethernet: am65-cpsw: cleanup TAPRIO handling Roger Quadros
2023-11-20 22:56   ` Vladimir Oltean
2023-11-21  9:23     ` Roger Quadros
2023-11-21 11:11       ` Roger Quadros
2023-11-20 14:01 ` [PATCH v6 net-next 3/7] net: ethernet: ti: am65-cpsw: Move code to avoid forward declaration Roger Quadros
2023-11-20 14:01 ` [PATCH v6 net-next 4/7] net: ethernet: am65-cpsw: Move register definitions to header file Roger Quadros
2023-11-20 14:01 ` [PATCH v6 net-next 5/7] net: ethernet: ti: am65-cpsw: add mqprio qdisc offload in channel mode Roger Quadros
2023-11-20 23:03   ` Vladimir Oltean [this message]
2023-11-21  9:25     ` Roger Quadros
2023-11-20 14:01 ` [PATCH v6 net-next 6/7] net: ethernet: ti: am65-cpsw-qos: Add Frame Preemption MAC Merge support Roger Quadros
2023-11-20 23:26   ` Vladimir Oltean
2023-11-21 11:02     ` Roger Quadros
2023-11-21 11:53       ` Vladimir Oltean
2023-11-30 11:49         ` Roger Quadros
2023-11-30 13:22           ` Vladimir Oltean
2023-11-30 14:23             ` Roger Quadros
2023-11-30 21:19               ` Vladimir Oltean
2023-11-21 11:48     ` Roger Quadros
2023-11-20 14:01 ` [PATCH v6 net-next 7/7] net: ethernet: ti: am65-cpsw: add sw tx/rx irq coalescing based on hrtimers Roger Quadros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231120230314.tqozomqbd6jiqbf7@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=grygorii.strashko@ti.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=p-varis@ti.com \
    --cc=pabeni@redhat.com \
    --cc=r-gunasekaran@ti.com \
    --cc=rogerq@kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).