Skip to content

Commit dec8daa

Browse files
committed
Merge: net/octeon_ep: Driver update
MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-10/-/merge_requests/314 JIRA: https://issues.redhat.com/browse/RHEL-90058 Update the driver to include critical bug fixes. Omitted-fix: af82e85 ("octeon_ep: Validate the VF ID") - [mschmidt] The main purpose of this MR is to not have an older driver in 10.1 than in 9.7. We don't need that commit to meet that requirement. The fix is not that important and it can be backported in z-stream if needed. Signed-off-by: Kamal Heib <kheib@redhat.com> Approved-by: Michal Schmidt <mschmidt@redhat.com> Approved-by: Ivan Vecera <ivecera@redhat.com> Approved-by: Jakub Ramaseuski <jramaseu@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 6f681d2 + 35c15a1 commit dec8daa

File tree

16 files changed

+172
-145
lines changed

16 files changed

+172
-145
lines changed

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

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static const char octep_gstrings_global_stats[][ETH_GSTRING_LEN] = {
4747
"rx_err_pkts",
4848
};
4949

50-
#define OCTEP_GLOBAL_STATS_CNT (sizeof(octep_gstrings_global_stats) / ETH_GSTRING_LEN)
50+
#define OCTEP_GLOBAL_STATS_CNT ARRAY_SIZE(octep_gstrings_global_stats)
5151

5252
static const char octep_gstrings_tx_q_stats[][ETH_GSTRING_LEN] = {
5353
"tx_packets_posted[Q-%u]",
@@ -56,15 +56,15 @@ static const char octep_gstrings_tx_q_stats[][ETH_GSTRING_LEN] = {
5656
"tx_busy[Q-%u]",
5757
};
5858

59-
#define OCTEP_TX_Q_STATS_CNT (sizeof(octep_gstrings_tx_q_stats) / ETH_GSTRING_LEN)
59+
#define OCTEP_TX_Q_STATS_CNT ARRAY_SIZE(octep_gstrings_tx_q_stats)
6060

6161
static const char octep_gstrings_rx_q_stats[][ETH_GSTRING_LEN] = {
6262
"rx_packets[Q-%u]",
6363
"rx_bytes[Q-%u]",
6464
"rx_alloc_errors[Q-%u]",
6565
};
6666

67-
#define OCTEP_RX_Q_STATS_CNT (sizeof(octep_gstrings_rx_q_stats) / ETH_GSTRING_LEN)
67+
#define OCTEP_RX_Q_STATS_CNT ARRAY_SIZE(octep_gstrings_rx_q_stats)
6868

6969
static void octep_get_drvinfo(struct net_device *netdev,
7070
struct ethtool_drvinfo *info)
@@ -80,32 +80,25 @@ static void octep_get_strings(struct net_device *netdev,
8080
{
8181
struct octep_device *oct = netdev_priv(netdev);
8282
u16 num_queues = CFG_GET_PORTS_ACTIVE_IO_RINGS(oct->conf);
83-
char *strings = (char *)data;
83+
const char *str;
8484
int i, j;
8585

8686
switch (stringset) {
8787
case ETH_SS_STATS:
88-
for (i = 0; i < OCTEP_GLOBAL_STATS_CNT; i++) {
89-
snprintf(strings, ETH_GSTRING_LEN,
90-
octep_gstrings_global_stats[i]);
91-
strings += ETH_GSTRING_LEN;
92-
}
88+
for (i = 0; i < OCTEP_GLOBAL_STATS_CNT; i++)
89+
ethtool_puts(&data, octep_gstrings_global_stats[i]);
9390

94-
for (i = 0; i < num_queues; i++) {
91+
for (i = 0; i < num_queues; i++)
9592
for (j = 0; j < OCTEP_TX_Q_STATS_CNT; j++) {
96-
snprintf(strings, ETH_GSTRING_LEN,
97-
octep_gstrings_tx_q_stats[j], i);
98-
strings += ETH_GSTRING_LEN;
93+
str = octep_gstrings_tx_q_stats[j];
94+
ethtool_sprintf(&data, str, i);
9995
}
100-
}
10196

102-
for (i = 0; i < num_queues; i++) {
97+
for (i = 0; i < num_queues; i++)
10398
for (j = 0; j < OCTEP_RX_Q_STATS_CNT; j++) {
104-
snprintf(strings, ETH_GSTRING_LEN,
105-
octep_gstrings_rx_q_stats[j], i);
106-
strings += ETH_GSTRING_LEN;
99+
str = octep_gstrings_rx_q_stats[j];
100+
ethtool_sprintf(&data, str, i);
107101
}
108-
}
109102
break;
110103
default:
111104
break;
@@ -157,17 +150,14 @@ octep_get_ethtool_stats(struct net_device *netdev,
157150
iface_rx_stats,
158151
iface_tx_stats);
159152

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];
153+
for (q = 0; q < OCTEP_MAX_QUEUES; q++) {
154+
tx_packets += oct->stats_iq[q].instr_completed;
155+
tx_bytes += oct->stats_iq[q].bytes_sent;
156+
tx_busy_errors += oct->stats_iq[q].tx_busy;
163157

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;
158+
rx_packets += oct->stats_oq[q].packets;
159+
rx_bytes += oct->stats_oq[q].bytes;
160+
rx_alloc_errors += oct->stats_oq[q].alloc_failures;
171161
}
172162
i = 0;
173163
data[i++] = rx_packets;
@@ -205,22 +195,18 @@ octep_get_ethtool_stats(struct net_device *netdev,
205195
data[i++] = iface_rx_stats->err_pkts;
206196

207197
/* 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;
198+
for (q = 0; q < OCTEP_MAX_QUEUES; q++) {
199+
data[i++] = oct->stats_iq[q].instr_posted;
200+
data[i++] = oct->stats_iq[q].instr_completed;
201+
data[i++] = oct->stats_iq[q].bytes_sent;
202+
data[i++] = oct->stats_iq[q].tx_busy;
215203
}
216204

217205
/* 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;
206+
for (q = 0; q < OCTEP_MAX_QUEUES; q++) {
207+
data[i++] = oct->stats_oq[q].packets;
208+
data[i++] = oct->stats_oq[q].bytes;
209+
data[i++] = oct->stats_oq[q].alloc_failures;
224210
}
225211
}
226212

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

Lines changed: 48 additions & 22 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
/**
@@ -1197,7 +1223,7 @@ static void octep_hb_timeout_task(struct work_struct *work)
11971223
miss_cnt);
11981224
rtnl_lock();
11991225
if (netif_running(oct->netdev))
1200-
octep_stop(oct->netdev);
1226+
dev_close(oct->netdev);
12011227
rtnl_unlock();
12021228
}
12031229

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
@@ -156,12 +156,23 @@ static void octep_pfvf_set_mac_addr(struct octep_device *oct, u32 vf_id,
156156
{
157157
int err;
158158

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

@@ -171,10 +182,18 @@ static void octep_pfvf_get_mac_addr(struct octep_device *oct, u32 vf_id,
171182
{
172183
int err;
173184

185+
if (oct->vf_info[vf_id].flags & OCTEON_PFVF_FLAG_MAC_SET_BY_PF) {
186+
dev_dbg(&oct->pdev->dev, "VF%d MAC address set by PF\n", vf_id);
187+
ether_addr_copy(rsp->s_set_mac.mac_addr,
188+
oct->vf_info[vf_id].mac_addr);
189+
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
190+
return;
191+
}
174192
err = octep_ctrl_net_get_mac_addr(oct, vf_id, rsp->s_set_mac.mac_addr);
175193
if (err) {
176194
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
177-
dev_err(&oct->pdev->dev, "Get VF MAC address failed via host control Mbox\n");
195+
dev_err(&oct->pdev->dev, "Get VF%d MAC address failed via host control Mbox\n",
196+
vf_id);
178197
return;
179198
}
180199
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,

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int octep_oq_refill(struct octep_device *oct, struct octep_oq *oq)
8787
page = dev_alloc_page();
8888
if (unlikely(!page)) {
8989
dev_err(oq->dev, "refill: rx buffer alloc failed\n");
90-
oq->stats.alloc_failures++;
90+
oq->stats->alloc_failures++;
9191
break;
9292
}
9393

@@ -98,7 +98,7 @@ static int octep_oq_refill(struct octep_device *oct, struct octep_oq *oq)
9898
"OQ-%d buffer refill: DMA mapping error!\n",
9999
oq->q_no);
100100
put_page(page);
101-
oq->stats.alloc_failures++;
101+
oq->stats->alloc_failures++;
102102
break;
103103
}
104104
oq->buff_info[refill_idx].page = page;
@@ -134,6 +134,7 @@ static int octep_setup_oq(struct octep_device *oct, int q_no)
134134
oq->netdev = oct->netdev;
135135
oq->dev = &oct->pdev->dev;
136136
oq->q_no = q_no;
137+
oq->stats = &oct->stats_oq[q_no];
137138
oq->max_count = CFG_GET_OQ_NUM_DESC(oct->conf);
138139
oq->ring_size_mask = oq->max_count - 1;
139140
oq->buffer_size = CFG_GET_OQ_BUF_SIZE(oct->conf);
@@ -443,7 +444,7 @@ static int __octep_oq_process_rx(struct octep_device *oct,
443444
if (!skb) {
444445
octep_oq_drop_rx(oq, buff_info,
445446
&read_idx, &desc_used);
446-
oq->stats.alloc_failures++;
447+
oq->stats->alloc_failures++;
447448
continue;
448449
}
449450
skb_reserve(skb, data_offset);
@@ -494,8 +495,8 @@ static int __octep_oq_process_rx(struct octep_device *oct,
494495

495496
oq->host_read_idx = read_idx;
496497
oq->refill_count += desc_used;
497-
oq->stats.packets += pkt;
498-
oq->stats.bytes += rx_bytes;
498+
oq->stats->packets += pkt;
499+
oq->stats->bytes += rx_bytes;
499500

500501
return pkt;
501502
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ struct octep_oq {
186186
*/
187187
u8 __iomem *pkts_sent_reg;
188188

189-
/* Statistics for this OQ. */
190-
struct octep_oq_stats stats;
189+
/* Pointer to statistics for this OQ. */
190+
struct octep_oq_stats *stats;
191191

192192
/* Packets pending to be processed */
193193
u32 pkts_pending;

0 commit comments

Comments
 (0)