From: Paolo Abeni <pabeni@redhat.com>
To: Jinjian Song <songjinjian@hotmail.com>, netdev@vger.kernel.org
Cc: chandrashekar.devegowda@intel.com,
chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com,
m.chetan.kumar@linux.intel.com,
ricardo.martinez@linux.intel.com, loic.poulain@linaro.org,
ryazanov.s.a@gmail.com, johannes@sipsolutions.net,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
linux-kernel@vger.kernel.com, vsankar@lenovo.com,
danielwinkler@google.com, nmarupaka@google.com,
joey.zhao@fibocom.com, liuqf@fibocom.com, felix.yan@fibocom.com,
Jinjian Song <jinjian.song@fibocom.com>
Subject: Re: [net-next v5 4/4] net: wwan: t7xx: Add fastboot WWAN port
Date: Tue, 23 Jan 2024 13:15:19 +0100 [thread overview]
Message-ID: <18cf401f00c953d434a0ef36b0d68df0270dfaa6.camel@redhat.com> (raw)
In-Reply-To: <MEYP282MB26978032980360EBBB1DAFF9BB752@MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM>
On Mon, 2024-01-22 at 17:09 +0800, Jinjian Song wrote:
> From: Jinjian Song <jinjian.song@fibocom.com>
>
> On early detection of wwan device in fastboot mode, driver sets
> up CLDMA0 HW tx/rx queues for raw data transfer and then create
> fastboot port to userspace.
>
> Application can use this port to flash firmware and collect
> core dump by fastboot protocol commands.
>
> Signed-off-by: Jinjian Song <jinjian.song@fibocom.com>
> ---
> v5:
> * no change
> v4:
> * change function prefix to t7xx_port_fastboot
> * change the name 'FASTBOOT' to fastboot in struct t7xx_early_port_conf
> v3:
> * no change
> v2:
> * no change
Minor nit: you could/should omit the 'no change' entries
[...]
> +static int t7xx_port_fastboot_tx(struct wwan_port *port, struct sk_buff *skb)
> +{
> + struct t7xx_port *port_private = wwan_port_get_drvdata(port);
> + struct sk_buff *cur = skb, *cloned;
> + size_t actual, len, offset = 0;
> + int ret;
> + int txq_mtu;
> +
> + if (!port_private->chan_enable)
> + return -EINVAL;
> +
> + txq_mtu = t7xx_get_port_mtu(port_private);
> + if (txq_mtu < 0)
> + return -EINVAL;
> +
> + actual = cur->len;
> + while (actual) {
> + len = min_t(size_t, actual, txq_mtu);
> + cloned = __dev_alloc_skb(len, GFP_KERNEL);
Minor nit: the variable name is misleading, as the skb is not cloned.
> + if (!cloned)
> + return -ENOMEM;
> +
> + skb_put_data(cloned, cur->data + offset, len);
> +
> + ret = t7xx_port_send_raw_skb(port_private, cloned);
> + if (ret) {
> + dev_kfree_skb(cloned);
> + dev_err(port_private->dev, "Write error on fastboot port, %d\n", ret);
> + break;
> + }
> + offset += len;
> + actual -= len;
> + }
> +
> + dev_kfree_skb(skb);
> + return 0;
> +}
>
[...]
> ++static void t7xx_port_fastboot_uninit(struct t7xx_port *port)
> +{
> + if (!port->wwan.wwan_port)
> + return;
> +
> + port->rx_length_th = 0;
> + wwan_remove_port(port->wwan.wwan_port);
> + port->wwan.wwan_port = NULL;
> +}
> +
> +static int t7xx_port_fastboot_recv_skb(struct t7xx_port *port, struct sk_buff *skb)
> +{
> + if (!atomic_read(&port->usage_cnt) || !port->chan_enable) {
> + const struct t7xx_port_conf *port_conf = port->port_conf;
> +
> + dev_kfree_skb_any(skb);
> + dev_err_ratelimited(port->dev, "Port %s is not opened, drop packets\n",
> + port_conf->name);
> + /* Dropping skb, caller should not access skb.*/
> + return 0;
> + }
> +
> + wwan_port_rx(port->wwan.wwan_port, skb);
> +
> + return 0;
> +}
> +
> +static int t7xx_port_fastboot_enable_chl(struct t7xx_port *port)
> +{
> + spin_lock(&port->port_update_lock);
> + port->chan_enable = true;
> + spin_unlock(&port->port_update_lock);
> +
> + return 0;
> +}
> +
> +static int t7xx_port_fastboot_disable_chl(struct t7xx_port *port)
> +{
> + spin_lock(&port->port_update_lock);
> + port->chan_enable = false;
> + spin_unlock(&port->port_update_lock);
> +
> + return 0;
> +}
The above 4 functions implementation are exact copies of
t7xx_port_wwan_*() functions in drivers/net/wwan/t7xx/t7xx_port_wwan.c
Please reorganize the code to avoid such duplication, e.g. renaming the
exiting function to something more generic, making them non static, and
declaring them in some t7xx specific header.
Cheers,
Paolo
next prev parent reply other threads:[~2024-01-23 12:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240122090940.10108-1-songjinjian@hotmail.com>
2024-01-22 9:09 ` [net-next v5 1/4] wwan: core: Add WWAN fastboot port type Jinjian Song
2024-01-22 9:09 ` [net-next v5 2/4] net: wwan: t7xx: Add sysfs attribute for device state machine Jinjian Song
2024-01-23 12:24 ` Paolo Abeni
2024-01-24 16:56 ` Jinjian Song
2024-01-22 9:09 ` [net-next v5 3/4] net: wwan: t7xx: Infrastructure for early port configuration Jinjian Song
2024-01-22 9:09 ` [net-next v5 4/4] net: wwan: t7xx: Add fastboot WWAN port Jinjian Song
2024-01-23 12:15 ` Paolo Abeni [this message]
2024-01-24 16:57 ` Jinjian Song
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=18cf401f00c953d434a0ef36b0d68df0270dfaa6.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=chandrashekar.devegowda@intel.com \
--cc=chiranjeevi.rapolu@linux.intel.com \
--cc=danielwinkler@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=felix.yan@fibocom.com \
--cc=haijun.liu@mediatek.com \
--cc=jinjian.song@fibocom.com \
--cc=joey.zhao@fibocom.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.com \
--cc=liuqf@fibocom.com \
--cc=loic.poulain@linaro.org \
--cc=m.chetan.kumar@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=nmarupaka@google.com \
--cc=ricardo.martinez@linux.intel.com \
--cc=ryazanov.s.a@gmail.com \
--cc=songjinjian@hotmail.com \
--cc=vsankar@lenovo.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).