Skip to content

Commit 5038fba

Browse files
committed
Merge: net/octeon_ep: Driver update
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6226 JIRA: https://issues.redhat.com/browse/RHEL-67691 JIRA: https://issues.redhat.com/browse/RHEL-64635 Update the driver to include critical bug fixes. Signed-off-by: Kamal Heib <kheib@redhat.com> Approved-by: mheib <mheib@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Patrick Talbert <ptalbert@redhat.com>
2 parents 43acc7b + d896951 commit 5038fba

File tree

16 files changed

+203
-128
lines changed

16 files changed

+203
-128
lines changed

drivers/net/ethernet/marvell/octeon_ep/octep_ethtool.c

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,14 @@ octep_get_ethtool_stats(struct net_device *netdev,
157157
iface_rx_stats,
158158
iface_tx_stats);
159159

160-
for (q = 0; q < oct->num_oqs; q++) {
161-
struct octep_iq *iq = oct->iq[q];
162-
struct octep_oq *oq = oct->oq[q];
163-
164-
tx_packets += iq->stats.instr_completed;
165-
tx_bytes += iq->stats.bytes_sent;
166-
tx_busy_errors += iq->stats.tx_busy;
167-
168-
rx_packets += oq->stats.packets;
169-
rx_bytes += oq->stats.bytes;
170-
rx_alloc_errors += oq->stats.alloc_failures;
160+
for (q = 0; q < OCTEP_MAX_QUEUES; q++) {
161+
tx_packets += oct->stats_iq[q].instr_completed;
162+
tx_bytes += oct->stats_iq[q].bytes_sent;
163+
tx_busy_errors += oct->stats_iq[q].tx_busy;
164+
165+
rx_packets += oct->stats_oq[q].packets;
166+
rx_bytes += oct->stats_oq[q].bytes;
167+
rx_alloc_errors += oct->stats_oq[q].alloc_failures;
171168
}
172169
i = 0;
173170
data[i++] = rx_packets;
@@ -205,22 +202,18 @@ octep_get_ethtool_stats(struct net_device *netdev,
205202
data[i++] = iface_rx_stats->err_pkts;
206203

207204
/* Per Tx Queue stats */
208-
for (q = 0; q < oct->num_iqs; q++) {
209-
struct octep_iq *iq = oct->iq[q];
210-
211-
data[i++] = iq->stats.instr_posted;
212-
data[i++] = iq->stats.instr_completed;
213-
data[i++] = iq->stats.bytes_sent;
214-
data[i++] = iq->stats.tx_busy;
205+
for (q = 0; q < OCTEP_MAX_QUEUES; q++) {
206+
data[i++] = oct->stats_iq[q].instr_posted;
207+
data[i++] = oct->stats_iq[q].instr_completed;
208+
data[i++] = oct->stats_iq[q].bytes_sent;
209+
data[i++] = oct->stats_iq[q].tx_busy;
215210
}
216211

217212
/* Per Rx Queue stats */
218-
for (q = 0; q < oct->num_oqs; q++) {
219-
struct octep_oq *oq = oct->oq[q];
220-
221-
data[i++] = oq->stats.packets;
222-
data[i++] = oq->stats.bytes;
223-
data[i++] = oq->stats.alloc_failures;
213+
for (q = 0; q < OCTEP_MAX_QUEUES; q++) {
214+
data[i++] = oct->stats_oq[q].packets;
215+
data[i++] = oct->stats_oq[q].bytes;
216+
data[i++] = oct->stats_oq[q].alloc_failures;
224217
}
225218
}
226219

drivers/net/ethernet/marvell/octeon_ep/octep_main.c

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ static inline int octep_iq_full_check(struct octep_iq *iq)
822822
if (unlikely(IQ_INSTR_SPACE(iq) >
823823
OCTEP_WAKE_QUEUE_THRESHOLD)) {
824824
netif_start_subqueue(iq->netdev, iq->q_no);
825-
iq->stats.restart_cnt++;
825+
iq->stats->restart_cnt++;
826826
return 0;
827827
}
828828

@@ -960,7 +960,7 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb,
960960
wmb();
961961
/* Ring Doorbell to notify the NIC of new packets */
962962
writel(iq->fill_cnt, iq->doorbell_reg);
963-
iq->stats.instr_posted += iq->fill_cnt;
963+
iq->stats->instr_posted += iq->fill_cnt;
964964
iq->fill_cnt = 0;
965965
return NETDEV_TX_OK;
966966

@@ -991,37 +991,24 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb,
991991
static void octep_get_stats64(struct net_device *netdev,
992992
struct rtnl_link_stats64 *stats)
993993
{
994-
u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
995994
struct octep_device *oct = netdev_priv(netdev);
995+
u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
996996
int q;
997997

998-
if (netif_running(netdev))
999-
octep_ctrl_net_get_if_stats(oct,
1000-
OCTEP_CTRL_NET_INVALID_VFID,
1001-
&oct->iface_rx_stats,
1002-
&oct->iface_tx_stats);
1003-
1004998
tx_packets = 0;
1005999
tx_bytes = 0;
10061000
rx_packets = 0;
10071001
rx_bytes = 0;
1008-
for (q = 0; q < oct->num_oqs; q++) {
1009-
struct octep_iq *iq = oct->iq[q];
1010-
struct octep_oq *oq = oct->oq[q];
1011-
1012-
tx_packets += iq->stats.instr_completed;
1013-
tx_bytes += iq->stats.bytes_sent;
1014-
rx_packets += oq->stats.packets;
1015-
rx_bytes += oq->stats.bytes;
1002+
for (q = 0; q < OCTEP_MAX_QUEUES; q++) {
1003+
tx_packets += oct->stats_iq[q].instr_completed;
1004+
tx_bytes += oct->stats_iq[q].bytes_sent;
1005+
rx_packets += oct->stats_oq[q].packets;
1006+
rx_bytes += oct->stats_oq[q].bytes;
10161007
}
10171008
stats->tx_packets = tx_packets;
10181009
stats->tx_bytes = tx_bytes;
10191010
stats->rx_packets = rx_packets;
10201011
stats->rx_bytes = rx_bytes;
1021-
stats->multicast = oct->iface_rx_stats.mcast_pkts;
1022-
stats->rx_errors = oct->iface_rx_stats.err_pkts;
1023-
stats->collisions = oct->iface_tx_stats.xscol;
1024-
stats->tx_fifo_errors = oct->iface_tx_stats.undflw;
10251012
}
10261013

10271014
/**
@@ -1137,6 +1124,43 @@ static int octep_set_features(struct net_device *dev, netdev_features_t features
11371124
return err;
11381125
}
11391126

1127+
static int octep_get_vf_config(struct net_device *dev, int vf,
1128+
struct ifla_vf_info *ivi)
1129+
{
1130+
struct octep_device *oct = netdev_priv(dev);
1131+
1132+
ivi->vf = vf;
1133+
ether_addr_copy(ivi->mac, oct->vf_info[vf].mac_addr);
1134+
ivi->spoofchk = true;
1135+
ivi->linkstate = IFLA_VF_LINK_STATE_ENABLE;
1136+
ivi->trusted = false;
1137+
1138+
return 0;
1139+
}
1140+
1141+
static int octep_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
1142+
{
1143+
struct octep_device *oct = netdev_priv(dev);
1144+
int err;
1145+
1146+
if (!is_valid_ether_addr(mac)) {
1147+
dev_err(&oct->pdev->dev, "Invalid MAC Address %pM\n", mac);
1148+
return -EADDRNOTAVAIL;
1149+
}
1150+
1151+
dev_dbg(&oct->pdev->dev, "set vf-%d mac to %pM\n", vf, mac);
1152+
ether_addr_copy(oct->vf_info[vf].mac_addr, mac);
1153+
oct->vf_info[vf].flags |= OCTEON_PFVF_FLAG_MAC_SET_BY_PF;
1154+
1155+
err = octep_ctrl_net_set_mac_addr(oct, vf, mac, true);
1156+
if (err)
1157+
dev_err(&oct->pdev->dev,
1158+
"Set VF%d MAC address failed via host control Mbox\n",
1159+
vf);
1160+
1161+
return err;
1162+
}
1163+
11401164
static const struct net_device_ops octep_netdev_ops = {
11411165
.ndo_open = octep_open,
11421166
.ndo_stop = octep_stop,
@@ -1146,6 +1170,8 @@ static const struct net_device_ops octep_netdev_ops = {
11461170
.ndo_set_mac_address = octep_set_mac,
11471171
.ndo_change_mtu = octep_change_mtu,
11481172
.ndo_set_features = octep_set_features,
1173+
.ndo_get_vf_config = octep_get_vf_config,
1174+
.ndo_set_vf_mac = octep_set_vf_mac
11491175
};
11501176

11511177
/**

drivers/net/ethernet/marvell/octeon_ep/octep_main.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ struct octep_iface_link_info {
220220
/* The Octeon VF device specific info data structure.*/
221221
struct octep_pfvf_info {
222222
u8 mac_addr[ETH_ALEN];
223+
u32 flags;
223224
u32 mbox_version;
224225
};
225226

@@ -257,11 +258,17 @@ struct octep_device {
257258
/* Pointers to Octeon Tx queues */
258259
struct octep_iq *iq[OCTEP_MAX_IQ];
259260

261+
/* Per iq stats */
262+
struct octep_iq_stats stats_iq[OCTEP_MAX_IQ];
263+
260264
/* Rx queues (OQ: Output Queue) */
261265
u16 num_oqs;
262266
/* Pointers to Octeon Rx queues */
263267
struct octep_oq *oq[OCTEP_MAX_OQ];
264268

269+
/* Per oq stats */
270+
struct octep_oq_stats stats_oq[OCTEP_MAX_OQ];
271+
265272
/* Hardware port number of the PCIe interface */
266273
u16 pcie_port;
267274

drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,23 @@ static void octep_pfvf_set_mac_addr(struct octep_device *oct, u32 vf_id,
155155
{
156156
int err;
157157

158+
if (oct->vf_info[vf_id].flags & OCTEON_PFVF_FLAG_MAC_SET_BY_PF) {
159+
dev_err(&oct->pdev->dev,
160+
"VF%d attempted to override administrative set MAC address\n",
161+
vf_id);
162+
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
163+
return;
164+
}
165+
158166
err = octep_ctrl_net_set_mac_addr(oct, vf_id, cmd.s_set_mac.mac_addr, true);
159167
if (err) {
160168
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
161-
dev_err(&oct->pdev->dev, "Set VF MAC address failed via host control Mbox\n");
169+
dev_err(&oct->pdev->dev, "Set VF%d MAC address failed via host control Mbox\n",
170+
vf_id);
162171
return;
163172
}
173+
174+
ether_addr_copy(oct->vf_info[vf_id].mac_addr, cmd.s_set_mac.mac_addr);
164175
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
165176
}
166177

@@ -170,10 +181,18 @@ static void octep_pfvf_get_mac_addr(struct octep_device *oct, u32 vf_id,
170181
{
171182
int err;
172183

184+
if (oct->vf_info[vf_id].flags & OCTEON_PFVF_FLAG_MAC_SET_BY_PF) {
185+
dev_dbg(&oct->pdev->dev, "VF%d MAC address set by PF\n", vf_id);
186+
ether_addr_copy(rsp->s_set_mac.mac_addr,
187+
oct->vf_info[vf_id].mac_addr);
188+
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
189+
return;
190+
}
173191
err = octep_ctrl_net_get_mac_addr(oct, vf_id, rsp->s_set_mac.mac_addr);
174192
if (err) {
175193
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
176-
dev_err(&oct->pdev->dev, "Get VF MAC address failed via host control Mbox\n");
194+
dev_err(&oct->pdev->dev, "Get VF%d MAC address failed via host control Mbox\n",
195+
vf_id);
177196
return;
178197
}
179198
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;

drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#ifndef _OCTEP_PFVF_MBOX_H_
99
#define _OCTEP_PFVF_MBOX_H_
1010

11-
/* VF flags */
12-
#define OCTEON_PFVF_FLAG_MAC_SET_BY_PF BIT_ULL(0) /* PF has set VF MAC address */
1311
#define OCTEON_SDP_16K_HW_FRS 16380UL
1412
#define OCTEON_SDP_64K_HW_FRS 65531UL
1513

@@ -23,6 +21,10 @@ enum octep_pfvf_mbox_version {
2321

2422
#define OCTEP_PFVF_MBOX_VERSION_CURRENT OCTEP_PFVF_MBOX_VERSION_V2
2523

24+
/* VF flags */
25+
/* PF has set VF MAC address */
26+
#define OCTEON_PFVF_FLAG_MAC_SET_BY_PF BIT(0)
27+
2628
enum octep_pfvf_mbox_opcode {
2729
OCTEP_PFVF_MBOX_CMD_VERSION,
2830
OCTEP_PFVF_MBOX_CMD_SET_MTU,

0 commit comments

Comments
 (0)