Commit 021b0c95 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'ionic-more-driver-fixes'

Shannon Nelson says:

====================
ionic: more driver fixes

These are a few code cleanup items that appeared first in a
separate net patchset,
    https://lore.kernel.org/netdev/20231201000519.13363-1-shannon.nelson@amd.com/
but are now aimed for net-next.
====================

Link: https://lore.kernel.org/r/20231204210936.16587-1-shannon.nelson@amd.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 2f57dd94 5858036c
...@@ -91,6 +91,4 @@ int ionic_port_identify(struct ionic *ionic); ...@@ -91,6 +91,4 @@ int ionic_port_identify(struct ionic *ionic);
int ionic_port_init(struct ionic *ionic); int ionic_port_init(struct ionic *ionic);
int ionic_port_reset(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_ */ #endif /* _IONIC_H_ */
...@@ -469,46 +469,6 @@ int ionic_set_vf_config(struct ionic *ionic, int vf, ...@@ -469,46 +469,6 @@ int ionic_set_vf_config(struct ionic *ionic, int vf,
return err; 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) void ionic_vf_start(struct ionic *ionic)
{ {
union ionic_dev_cmd cmd = { union ionic_dev_cmd cmd = {
......
...@@ -269,12 +269,12 @@ struct ionic_queue { ...@@ -269,12 +269,12 @@ struct ionic_queue {
struct ionic_intr_info { struct ionic_intr_info {
char name[IONIC_INTR_NAME_MAX_SZ]; char name[IONIC_INTR_NAME_MAX_SZ];
u64 rearm_count;
unsigned int index; unsigned int index;
unsigned int vector; unsigned int vector;
u64 rearm_count;
unsigned int cpu; unsigned int cpu;
cpumask_t affinity_mask;
u32 dim_coal_hw; u32 dim_coal_hw;
cpumask_t affinity_mask;
}; };
struct ionic_cq { struct ionic_cq {
...@@ -341,8 +341,7 @@ void ionic_dev_cmd_port_pause(struct ionic_dev *idev, u8 pause_type); ...@@ -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, int ionic_set_vf_config(struct ionic *ionic, int vf,
struct ionic_vf_setattr_cmd *vfc); 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, void ionic_dev_cmd_queue_identify(struct ionic_dev *idev,
u16 lif_type, u8 qtype, u8 qver); u16 lif_type, u8 qtype, u8 qver);
void ionic_vf_start(struct ionic *ionic); void ionic_vf_start(struct ionic *ionic);
......
...@@ -424,14 +424,10 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq) ...@@ -424,14 +424,10 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq)
ionic_qcq_intr_free(lif, qcq); ionic_qcq_intr_free(lif, qcq);
if (qcq->cq.info) {
vfree(qcq->cq.info); vfree(qcq->cq.info);
qcq->cq.info = NULL; qcq->cq.info = NULL;
}
if (qcq->q.info) {
vfree(qcq->q.info); vfree(qcq->q.info);
qcq->q.info = NULL; qcq->q.info = NULL;
}
} }
void ionic_qcqs_free(struct ionic_lif *lif) void ionic_qcqs_free(struct ionic_lif *lif)
...@@ -2332,82 +2328,11 @@ static int ionic_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd ...@@ -2332,82 +2328,11 @@ static int ionic_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd
} }
} }
static int ionic_get_fw_vf_config(struct ionic *ionic, int vf, struct ionic_vf *vfdata)
{
struct ionic_vf_getattr_comp comp = { 0 };
int err;
u8 attr;
attr = IONIC_VF_ATTR_VLAN;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
vfdata->vlanid = comp.vlanid;
attr = IONIC_VF_ATTR_SPOOFCHK;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
vfdata->spoofchk = comp.spoofchk;
attr = IONIC_VF_ATTR_LINKSTATE;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err) {
switch (comp.linkstate) {
case IONIC_VF_LINK_STATUS_UP:
vfdata->linkstate = IFLA_VF_LINK_STATE_ENABLE;
break;
case IONIC_VF_LINK_STATUS_DOWN:
vfdata->linkstate = IFLA_VF_LINK_STATE_DISABLE;
break;
case IONIC_VF_LINK_STATUS_AUTO:
vfdata->linkstate = IFLA_VF_LINK_STATE_AUTO;
break;
default:
dev_warn(ionic->dev, "Unexpected link state %u\n", comp.linkstate);
break;
}
}
attr = IONIC_VF_ATTR_RATE;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
vfdata->maxrate = comp.maxrate;
attr = IONIC_VF_ATTR_TRUST;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
vfdata->trusted = comp.trust;
attr = IONIC_VF_ATTR_MAC;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
ether_addr_copy(vfdata->macaddr, comp.macaddr);
err_out:
if (err)
dev_err(ionic->dev, "Failed to get %s for VF %d\n",
ionic_vf_attr_to_str(attr), vf);
return err;
}
static int ionic_get_vf_config(struct net_device *netdev, static int ionic_get_vf_config(struct net_device *netdev,
int vf, struct ifla_vf_info *ivf) int vf, struct ifla_vf_info *ivf)
{ {
struct ionic_lif *lif = netdev_priv(netdev); struct ionic_lif *lif = netdev_priv(netdev);
struct ionic *ionic = lif->ionic; struct ionic *ionic = lif->ionic;
struct ionic_vf vfdata = { 0 };
int ret = 0; int ret = 0;
if (!netif_device_present(netdev)) if (!netif_device_present(netdev))
...@@ -2418,18 +2343,16 @@ static int ionic_get_vf_config(struct net_device *netdev, ...@@ -2418,18 +2343,16 @@ static int ionic_get_vf_config(struct net_device *netdev,
if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) { if (vf >= pci_num_vf(ionic->pdev) || !ionic->vfs) {
ret = -EINVAL; ret = -EINVAL;
} else { } else {
struct ionic_vf *vfdata = &ionic->vfs[vf];
ivf->vf = vf; ivf->vf = vf;
ivf->qos = 0; ivf->qos = 0;
ivf->vlan = le16_to_cpu(vfdata->vlanid);
ret = ionic_get_fw_vf_config(ionic, vf, &vfdata); ivf->spoofchk = vfdata->spoofchk;
if (!ret) { ivf->linkstate = vfdata->linkstate;
ivf->vlan = le16_to_cpu(vfdata.vlanid); ivf->max_tx_rate = le32_to_cpu(vfdata->maxrate);
ivf->spoofchk = vfdata.spoofchk; ivf->trusted = vfdata->trusted;
ivf->linkstate = vfdata.linkstate; ether_addr_copy(ivf->mac, vfdata->macaddr);
ivf->max_tx_rate = le32_to_cpu(vfdata.maxrate);
ivf->trusted = vfdata.trusted;
ether_addr_copy(ivf->mac, vfdata.macaddr);
}
} }
up_read(&ionic->vf_op_lock); up_read(&ionic->vf_op_lock);
...@@ -3127,6 +3050,7 @@ int ionic_lif_alloc(struct ionic *ionic) ...@@ -3127,6 +3050,7 @@ int ionic_lif_alloc(struct ionic *ionic)
lif = netdev_priv(netdev); lif = netdev_priv(netdev);
lif->netdev = netdev; lif->netdev = netdev;
ionic->lif = lif; ionic->lif = lif;
lif->ionic = ionic;
netdev->netdev_ops = &ionic_netdev_ops; netdev->netdev_ops = &ionic_netdev_ops;
ionic_ethtool_set_ops(netdev); ionic_ethtool_set_ops(netdev);
...@@ -3149,7 +3073,6 @@ int ionic_lif_alloc(struct ionic *ionic) ...@@ -3149,7 +3073,6 @@ int ionic_lif_alloc(struct ionic *ionic)
lif->neqs = ionic->neqs_per_lif; lif->neqs = ionic->neqs_per_lif;
lif->nxqs = ionic->ntxqs_per_lif; lif->nxqs = ionic->ntxqs_per_lif;
lif->ionic = ionic;
lif->index = 0; lif->index = 0;
if (is_kdump_kernel()) { if (is_kdump_kernel()) {
......
...@@ -312,6 +312,11 @@ static inline u32 ionic_coal_usec_to_hw(struct ionic *ionic, u32 usecs) ...@@ -312,6 +312,11 @@ static inline u32 ionic_coal_usec_to_hw(struct ionic *ionic, u32 usecs)
return (usecs * mult) / div; 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_link_status_check_request(struct ionic_lif *lif, bool can_sleep);
void ionic_get_stats64(struct net_device *netdev, void ionic_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *ns); struct rtnl_link_stats64 *ns);
......
...@@ -188,28 +188,6 @@ static const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode) ...@@ -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) static void ionic_adminq_flush(struct ionic_lif *lif)
{ {
struct ionic_desc_info *desc_info; struct ionic_desc_info *desc_info;
......
...@@ -803,7 +803,7 @@ static void ionic_tx_clean(struct ionic_queue *q, ...@@ -803,7 +803,7 @@ static void ionic_tx_clean(struct ionic_queue *q,
qi = skb_get_queue_mapping(skb); qi = skb_get_queue_mapping(skb);
if (unlikely(q->features & IONIC_TXQ_F_HWSTAMP)) { if (ionic_txq_hwstamp_enabled(q)) {
if (cq_info) { if (cq_info) {
struct skb_shared_hwtstamps hwts = {}; struct skb_shared_hwtstamps hwts = {};
__le64 *cq_desc_hwstamp; __le64 *cq_desc_hwstamp;
...@@ -870,7 +870,7 @@ bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info) ...@@ -870,7 +870,7 @@ bool ionic_tx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
desc_info->cb_arg = NULL; desc_info->cb_arg = NULL;
} while (index != le16_to_cpu(comp->comp_index)); } 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); netdev_tx_completed_queue(q_to_ndq(q), pkts, bytes);
return true; return true;
...@@ -908,7 +908,7 @@ void ionic_tx_empty(struct ionic_queue *q) ...@@ -908,7 +908,7 @@ void ionic_tx_empty(struct ionic_queue *q)
desc_info->cb_arg = NULL; 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); netdev_tx_completed_queue(q_to_ndq(q), pkts, bytes);
} }
...@@ -986,7 +986,7 @@ static void ionic_tx_tso_post(struct ionic_queue *q, ...@@ -986,7 +986,7 @@ static void ionic_tx_tso_post(struct ionic_queue *q,
if (start) { if (start) {
skb_tx_timestamp(skb); 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); netdev_tx_sent_queue(q_to_ndq(q), skb->len);
ionic_txq_post(q, false, ionic_tx_clean, skb); ionic_txq_post(q, false, ionic_tx_clean, skb);
} else { } else {
...@@ -1233,7 +1233,7 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb) ...@@ -1233,7 +1233,7 @@ static int ionic_tx(struct ionic_queue *q, struct sk_buff *skb)
stats->pkts++; stats->pkts++;
stats->bytes += skb->len; 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); netdev_tx_sent_queue(q_to_ndq(q), skb->len);
ionic_txq_post(q, !netdev_xmit_more(), ionic_tx_clean, skb); ionic_txq_post(q, !netdev_xmit_more(), ionic_tx_clean, skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment