ionic: more driver fixes
Subsystems (3)
cover ionic: more driver fixes
These are a few code cleanup items that appeared first in a separate net patchset,
https://lore.kernel.org/netdev/[email protected]/
but are now aimed for net-next.
Brett Creeley (4):
ionic: Use cached VF attributes
ionic: Don't check null when calling vfree()
ionic: Make the check for Tx HW timestamping more obvious
ionic: Re-arrange ionic_intr_info struct for cache perf
Shannon Nelson (1):
ionic: set ionic ptr before setting up ethtool ops
drivers/net/ethernet/pensando/ionic/ionic.h | 2 - .../net/ethernet/pensando/ionic/ionic_dev.c | 40 ------- .../net/ethernet/pensando/ionic/ionic_dev.h | 7 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 107 +++--------------- .../net/ethernet/pensando/ionic/ionic_lif.h | 5 + .../net/ethernet/pensando/ionic/ionic_main.c | 22 ---- .../net/ethernet/pensando/ionic/ionic_txrx.c | 10 +- 7 files changed, 28 insertions(+), 165 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/5 ionic: Use cached VF attributes
From: Brett Creeley <[email protected]>
Each time a VF attribute is set via iproute a call to get the VF configuration is also made. This is currently problematic because for each VF configuration call there are multiple commands sent to the device. Unfortunately, this doesn't scale well. Fix this by reporting the cached VF attributes.
The original change to query the device for getting the VF attributes
f16f5be31009 ("ionic: Query FW when getting VF info via ndo_get_vf_config")
was made to remain consistent with device set VF attributes. However, after further investigation there is no need to query the device.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 2 - .../net/ethernet/pensando/ionic/ionic_dev.c | 40 -------- .../net/ethernet/pensando/ionic/ionic_dev.h | 3 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 93 ++----------------- .../net/ethernet/pensando/ionic/ionic_main.c | 22 ----- 5 files changed, 11 insertions(+), 149 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +0 -2
@@ -91,6 +91,4 @@ int ionic_port_identify(struct ionic *ionic);int ionic_port_init (struct ionic *ionic);int ionic_port_reset (struct ionic *ionic); -const char *ionic_vf_attr_to_str (enum ionic_vf_attr attr); -#endif /* _IONIC_H_ */
drivers/net/ethernet/pensando/ionic/ionic_dev.c +0 -40
@@ -469,46 +469,6 @@ int ionic_set_vf_config(struct ionic *ionic, int vf,return err; } -int ionic_dev_cmd_vf_getattr (struct ionic *ionic,int vf,u8 attr, -struct ionic_vf_getattr_comp *comp) -{ -union ionic_dev_cmd cmd = { - .vf_getattr.opcode =IONIC_CMD_VF_GETATTR , - .vf_getattr.attr = attr, - .vf_getattr.vf_index =cpu_to_le16 (vf), - }; -int err; - -if (vf >= ionic->num_vfs) -return -EINVAL ; - -switch (attr) { -case IONIC_VF_ATTR_SPOOFCHK : -case IONIC_VF_ATTR_TRUST : -case IONIC_VF_ATTR_LINKSTATE : -case IONIC_VF_ATTR_MAC : -case IONIC_VF_ATTR_VLAN : -case IONIC_VF_ATTR_RATE : -break ; -case IONIC_VF_ATTR_STATSADDR : -default : -return -EINVAL ; - } - -mutex_lock (&ionic->dev_cmd_lock); -ionic_dev_cmd_go (&ionic->idev, &cmd); - err =ionic_dev_cmd_wait_nomsg (ionic,DEVCMD_TIMEOUT ); -memcpy_fromio (comp, &ionic->idev.dev_cmd_regs->comp.vf_getattr, -sizeof (*comp)); -mutex_unlock (&ionic->dev_cmd_lock); - -if (err && comp->status !=IONIC_RC_ENOSUPP ) -ionic_dev_cmd_dev_err_print (ionic, cmd.vf_getattr.opcode, - comp->status, err); - -return err; -} -void ionic_vf_start (struct ionic *ionic) {union ionic_dev_cmd cmd = {
drivers/net/ethernet/pensando/ionic/ionic_dev.h +1 -2
@@ -341,8 +341,7 @@ void ionic_dev_cmd_port_pause(struct ionic_dev *idev, u8 pause_type);int ionic_set_vf_config (struct ionic *ionic,int vf,struct ionic_vf_setattr_cmd *vfc); -int ionic_dev_cmd_vf_getattr (struct ionic *ionic,int vf,u8 attr, -struct ionic_vf_getattr_comp *comp); +void ionic_dev_cmd_queue_identify (struct ionic_dev *idev,u16 lif_type,u8 qtype,u8 qver);void ionic_vf_start (struct ionic *ionic);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +10 -83
110 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_main.c +0 -22
@@ -188,28 +188,6 @@ static const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode) } } -const char *ionic_vf_attr_to_str (enum ionic_vf_attr attr) -{ -switch (attr) { -case IONIC_VF_ATTR_SPOOFCHK : -return "IONIC_VF_ATTR_SPOOFCHK" ; -case IONIC_VF_ATTR_TRUST : -return "IONIC_VF_ATTR_TRUST" ; -case IONIC_VF_ATTR_LINKSTATE : -return "IONIC_VF_ATTR_LINKSTATE" ; -case IONIC_VF_ATTR_MAC : -return "IONIC_VF_ATTR_MAC" ; -case IONIC_VF_ATTR_VLAN : -return "IONIC_VF_ATTR_VLAN" ; -case IONIC_VF_ATTR_RATE : -return "IONIC_VF_ATTR_RATE" ; -case IONIC_VF_ATTR_STATSADDR : -return "IONIC_VF_ATTR_STATSADDR" ; -default : -return "IONIC_VF_ATTR_UNKNOWN" ; - } -} -static void ionic_adminq_flush (struct ionic_lif *lif) {struct ionic_desc_info *desc_info;
Signature · 1 line
2.17.1
PATCH 2/5 ionic: set ionic ptr before setting up ethtool ops
In reply to Shannon NelsonSet the lif->ionic value that is used in some ethtool callbacks before setting ethtool ops. There really shouldn't be any race issues before this change since the netdev hasn't been registered yet, but this seems more correct.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -1
@@ -3054,6 +3054,7 @@ int ionic_lif_alloc(struct ionic *ionic) lif =netdev_priv (netdev); lif->netdev = netdev; ionic->lif = lif; + lif->ionic = ionic; netdev->netdev_ops = &ionic_netdev_ops;ionic_ethtool_set_ops (netdev);
@@ -3076,7 +3077,6 @@ int ionic_lif_alloc(struct ionic *ionic) lif->neqs = ionic->neqs_per_lif; lif->nxqs = ionic->ntxqs_per_lif; - lif->ionic = ionic; lif->index =0 ;if (is_kdump_kernel ()) {
Signature · 1 line
2.17.1
PATCH 3/5 ionic: Don't check null when calling vfree()
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
vfree() checks for null internally, so there's no need to check in the caller. So, always vfree() on variables allocated with valloc(). If the variables are never alloc'd vfree() is still safe.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +4 -8
@@ -424,14 +424,10 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq)ionic_qcq_intr_free (lif, qcq); -if (qcq->cq.info) { -vfree (qcq->cq.info); - qcq->cq.info =NULL ; - } -if (qcq->q.info) { -vfree (qcq->q.info); - qcq->q.info =NULL ; - } +vfree (qcq->cq.info); + qcq->cq.info =NULL ; +vfree (qcq->q.info); + qcq->q.info =NULL ; }void ionic_qcqs_free (struct ionic_lif *lif)
Signature · 1 line
2.17.1
PATCH 4/5 ionic: Make the check for Tx HW timestamping more obvious
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
Currently the checks are:
[1] unlikely(q->features & IONIC_TXQ_F_HWSTAMP)
[2] !unlikely(q->features & IONIC_TXQ_F_HWSTAMP)
[1] is clear enough, but [2] isn't exactly obvious to the reader because !unlikely reads as likely. However, that's not what this means.
[2] means that it's unlikely that the q hasIONIC_TXQ_F_HWSTAMP enabled.
Write an inline helper function to hide the unlikely optimization to make these checks more readable.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.h | 5 +++++ drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.h +5 -0
@@ -312,6 +312,11 @@ static inline u32 ionic_coal_usec_to_hw(struct ionic *ionic, u32 usecs)return (usecs * mult) / div; } +static inline bool ionic_txq_hwstamp_enabled (struct ionic_queue *q) +{ +return unlikely (q->features &IONIC_TXQ_F_HWSTAMP ); +} +void ionic_link_status_check_request (struct ionic_lif *lif,bool can_sleep);void ionic_get_stats64 (struct net_device *netdev,struct rtnl_link_stats64 *ns);
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +5 -5
@@ -803,7 +803,7 @@ static void ionic_tx_clean(struct ionic_queue *q, qi =skb_get_queue_mapping (skb); -if (unlikely (q->features &IONIC_TXQ_F_HWSTAMP )) { +if (ionic_txq_hwstamp_enabled (q)) {if (cq_info) {struct skb_shared_hwtstamps hwts = {};__le64 *cq_desc_hwstamp;
@@ -870,7 +870,7 @@ bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info) desc_info->cb_arg =NULL ; }while (index !=le16_to_cpu (comp->comp_index)); -if (pkts && bytes && !unlikely (q->features &IONIC_TXQ_F_HWSTAMP )) +if (pkts && bytes && !ionic_txq_hwstamp_enabled (q))netdev_tx_completed_queue (q_to_ndq (q), pkts, bytes);return true;
@@ -908,7 +908,7 @@ void ionic_tx_empty(struct ionic_queue *q) desc_info->cb_arg =NULL ; } -if (pkts && bytes && !unlikely (q->features &IONIC_TXQ_F_HWSTAMP )) +if (pkts && bytes && !ionic_txq_hwstamp_enabled (q))netdev_tx_completed_queue (q_to_ndq (q), pkts, bytes); }
@@ -986,7 +986,7 @@ static void ionic_tx_tso_post(struct ionic_queue *q,if (start) {skb_tx_timestamp (skb); -if (!unlikely (q->features &IONIC_TXQ_F_HWSTAMP )) +if (!ionic_txq_hwstamp_enabled (q))netdev_tx_sent_queue (q_to_ndq (q), skb->len);ionic_txq_post (q, false, ionic_tx_clean, skb); }else {
@@ -1233,7 +1233,7 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb) stats->pkts++; stats->bytes += skb->len; -if (!unlikely (q->features &IONIC_TXQ_F_HWSTAMP )) +if (!ionic_txq_hwstamp_enabled (q))netdev_tx_sent_queue (q_to_ndq (q), skb->len);ionic_txq_post (q, !netdev_xmit_more (), ionic_tx_clean, skb);
Signature · 1 line
2.17.1
PATCH 5/5 ionic: Re-arrange ionic_intr_info struct for cache perf
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
dim_coal_hw is accessed in the hotpath along with other values from the first cacheline of ionic_intr_info. So, re-arrange the structure so the hot path variables are on the first cacheline.
Before:
struct ionic_intr_info {
char name[32]; /* 0 32 */ unsigned int index; /* 32 4 */ unsigned int vector; /* 36 4 */ u64 rearm_count; /* 40 8 */ unsigned int cpu; /* 48 4 */
/* XXX 4 bytes hole, try to pack */ cpumask_t affinity_mask; /* 56 1024 */ /* --- cacheline 16 boundary (1024 bytes) was 56 bytes ago --- */ u32 dim_coal_hw; /* 1080 4 */ /* size: 1088, cachelines: 17, members: 7 */ /* sum members: 1080, holes: 1, sum holes: 4 */ /* padding: 4 */ };
After:
struct ionic_intr_info {
char name[32]; /* 0 32 */ u64 rearm_count; /* 32 8 */ unsigned int index; /* 40 4 */ unsigned int vector; /* 44 4 */ unsigned int cpu; /* 48 4 */ u32 dim_coal_hw; /* 52 4 */ cpumask_t affinity_mask; /* 56 1024 */
/* size: 1080, cachelines: 17, members: 7 */ /* last cacheline: 56 bytes */ };
--- drivers/net/ethernet/pensando/ionic/ionic_dev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.h +2 -2
@@ -269,12 +269,12 @@ struct ionic_queue {struct ionic_intr_info {char name[IONIC_INTR_NAME_MAX_SZ ]; +u64 rearm_count;unsigned int index;unsigned int vector; -u64 rearm_count;unsigned int cpu; -cpumask_t affinity_mask;u32 dim_coal_hw; +cpumask_t affinity_mask; };struct ionic_cq {
Signature · 1 line
2.17.1
Quoted 7 lines · On Mon, 04 Dec, 2023 13:09:31 -0800 Shannon Nelson <[email protected]>…
These are a few code cleanup items that appeared first in a separate net patchset,
https://lore.kernel.org/netdev/[email protected]/but are now aimed for net-next.
Brett Creeley (4):
ionic: Use cached VF attributes
Was on the fence about whether this patch should be considered a "fix" or not. I think it makes sense that it is a performance enhancement.
Quoted 7 lines
ionic: Don't check null when calling
vfree()
ionic: Make the check for Tx HW timestamping more obvious
ionic: Re-arrangeionic_intr_infostruct for cache perfShannon Nelson (1):
ionic: set ionic ptr before setting up ethtool ops
Quoted 8 lines
drivers/net/ethernet/pensando/ionic/ionic.h | 2 - .../net/ethernet/pensando/ionic/ionic_dev.c | 40 ------- .../net/ethernet/pensando/ionic/ionic_dev.h | 7 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 107 +++--------------- .../net/ethernet/pensando/ionic/ionic_lif.h | 5 + .../net/ethernet/pensando/ionic/ionic_main.c | 22 ---- .../net/ethernet/pensando/ionic/ionic_txrx.c | 10 +- 7 files changed, 28 insertions(+), 165 deletions(-)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Mon, 4 Dec 2023 13:09:31 -0800 you wrote:
These are a few code cleanup items that appeared first in a separate net patchset,
https://lore.kernel.org/netdev/[email protected]/but are now aimed for net-next.
Quoted 7 lines
Brett Creeley (4):
ionic: Use cached VF attributes
ionic: Don't check null when callingvfree()
ionic: Make the check for Tx HW timestamping more obvious
ionic: Re-arrangeionic_intr_infostruct for cache perf[...]
Here is the summary with links:
- [net-next,1/5] ionic: Use cached VF attributes
https://git.kernel.org/netdev/net-next/c/15e54faa5d5e - [net-next,2/5] ionic: set ionic ptr before setting up ethtool ops https://git.kernel.org/netdev/net-next/c/46ca79d28fd7 - [net-next,3/5] ionic: Don't check null when calling vfree() https://git.kernel.org/netdev/net-next/c/2d0b80c3a550 - [net-next,4/5] ionic: Make the check for Tx HW timestamping more obvious https://git.kernel.org/netdev/net-next/c/ab807e918342 - [net-next,5/5] ionic: Re-arrange ionic_intr_info struct for cache perf https://git.kernel.org/netdev/net-next/c/5858036ca056
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html