Skip to content

Commit 0718693

Browse files
vburrudavem330
authored andcommitted
octeon_ep: function id in link info and stats mailbox commands
Update control mailbox API to include function id in get stats and link info. Signed-off-by: Veerasenareddy Burru <[email protected]> Signed-off-by: Abhijit Ayarekar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent baa9879 commit 0718693

File tree

4 files changed

+40
-31
lines changed

4 files changed

+40
-31
lines changed

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ static const u32 mtu_sz = sizeof(struct octep_ctrl_net_h2f_req_cmd_mtu);
1919
static const u32 mac_sz = sizeof(struct octep_ctrl_net_h2f_req_cmd_mac);
2020
static const u32 state_sz = sizeof(struct octep_ctrl_net_h2f_req_cmd_state);
2121
static const u32 link_info_sz = sizeof(struct octep_ctrl_net_link_info);
22-
static const u32 get_stats_sz = sizeof(struct octep_ctrl_net_h2f_req_cmd_get_stats);
2322
static atomic_t ctrl_net_msg_id;
2423

2524
static void init_send_req(struct octep_ctrl_mbox_msg *msg, void *buf,
@@ -188,31 +187,29 @@ int octep_ctrl_net_set_mtu(struct octep_device *oct, int vfid, int mtu,
188187
return octep_send_mbox_req(oct, &d, wait_for_response);
189188
}
190189

191-
int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid)
190+
int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,
191+
struct octep_iface_rx_stats *rx_stats,
192+
struct octep_iface_tx_stats *tx_stats)
192193
{
193194
struct octep_ctrl_net_wait_data d = {0};
194195
struct octep_ctrl_net_h2f_req *req = &d.data.req;
195-
void __iomem *iface_rx_stats;
196-
void __iomem *iface_tx_stats;
196+
struct octep_ctrl_net_h2f_resp *resp;
197197
int err;
198198

199-
init_send_req(&d.msg, req, get_stats_sz, vfid);
199+
init_send_req(&d.msg, req, 0, vfid);
200200
req->hdr.s.cmd = OCTEP_CTRL_NET_H2F_CMD_GET_IF_STATS;
201-
req->get_stats.offset = oct->ctrl_mbox_ifstats_offset;
202201
err = octep_send_mbox_req(oct, &d, true);
203202
if (err < 0)
204203
return err;
205204

206-
iface_rx_stats = oct->ctrl_mbox.barmem + oct->ctrl_mbox_ifstats_offset;
207-
iface_tx_stats = oct->ctrl_mbox.barmem + oct->ctrl_mbox_ifstats_offset +
208-
sizeof(struct octep_iface_rx_stats);
209-
memcpy_fromio(&oct->iface_rx_stats, iface_rx_stats, sizeof(struct octep_iface_rx_stats));
210-
memcpy_fromio(&oct->iface_tx_stats, iface_tx_stats, sizeof(struct octep_iface_tx_stats));
211-
205+
resp = &d.data.resp;
206+
memcpy(rx_stats, &resp->if_stats.rx_stats, sizeof(struct octep_iface_rx_stats));
207+
memcpy(tx_stats, &resp->if_stats.tx_stats, sizeof(struct octep_iface_tx_stats));
212208
return 0;
213209
}
214210

215-
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid)
211+
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid,
212+
struct octep_iface_link_info *link_info)
216213
{
217214
struct octep_ctrl_net_wait_data d = {0};
218215
struct octep_ctrl_net_h2f_req *req = &d.data.req;
@@ -227,11 +224,11 @@ int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid)
227224
return err;
228225

229226
resp = &d.data.resp;
230-
oct->link_info.supported_modes = resp->link_info.supported_modes;
231-
oct->link_info.advertised_modes = resp->link_info.advertised_modes;
232-
oct->link_info.autoneg = resp->link_info.autoneg;
233-
oct->link_info.pause = resp->link_info.pause;
234-
oct->link_info.speed = resp->link_info.speed;
227+
link_info->supported_modes = resp->link_info.supported_modes;
228+
link_info->advertised_modes = resp->link_info.advertised_modes;
229+
link_info->autoneg = resp->link_info.autoneg;
230+
link_info->pause = resp->link_info.pause;
231+
link_info->speed = resp->link_info.speed;
235232

236233
return 0;
237234
}

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ struct octep_ctrl_net_h2f_req_cmd_mac {
7777
u8 addr[ETH_ALEN];
7878
};
7979

80-
/* get if_stats, xstats, q_stats request */
81-
struct octep_ctrl_net_h2f_req_cmd_get_stats {
82-
/* offset into barmem where fw should copy over stats */
83-
u32 offset;
84-
};
85-
8680
/* get/set link state, rx state */
8781
struct octep_ctrl_net_h2f_req_cmd_state {
8882
/* enum octep_ctrl_net_cmd */
@@ -119,7 +113,6 @@ struct octep_ctrl_net_h2f_req {
119113
union {
120114
struct octep_ctrl_net_h2f_req_cmd_mtu mtu;
121115
struct octep_ctrl_net_h2f_req_cmd_mac mac;
122-
struct octep_ctrl_net_h2f_req_cmd_get_stats get_stats;
123116
struct octep_ctrl_net_h2f_req_cmd_state link;
124117
struct octep_ctrl_net_h2f_req_cmd_state rx;
125118
struct octep_ctrl_net_h2f_req_cmd_link_info link_info;
@@ -152,6 +145,12 @@ struct octep_ctrl_net_h2f_resp_cmd_mac {
152145
u8 addr[ETH_ALEN];
153146
};
154147

148+
/* get if_stats, xstats, q_stats request */
149+
struct octep_ctrl_net_h2f_resp_cmd_get_stats {
150+
struct octep_iface_rx_stats rx_stats;
151+
struct octep_iface_tx_stats tx_stats;
152+
};
153+
155154
/* get link state, rx state response */
156155
struct octep_ctrl_net_h2f_resp_cmd_state {
157156
/* enum octep_ctrl_net_state */
@@ -164,6 +163,7 @@ struct octep_ctrl_net_h2f_resp {
164163
union {
165164
struct octep_ctrl_net_h2f_resp_cmd_mtu mtu;
166165
struct octep_ctrl_net_h2f_resp_cmd_mac mac;
166+
struct octep_ctrl_net_h2f_resp_cmd_get_stats if_stats;
167167
struct octep_ctrl_net_h2f_resp_cmd_state link;
168168
struct octep_ctrl_net_h2f_resp_cmd_state rx;
169169
struct octep_ctrl_net_link_info link_info;
@@ -286,19 +286,25 @@ int octep_ctrl_net_set_mtu(struct octep_device *oct, int vfid, int mtu,
286286
*
287287
* @param oct: non-null pointer to struct octep_device.
288288
* @param vfid: Index of virtual function.
289+
* @param rx_stats: non-null pointer struct octep_iface_rx_stats.
290+
* @param tx_stats: non-null pointer struct octep_iface_tx_stats.
289291
*
290292
* return value: 0 on success, -errno on failure.
291293
*/
292-
int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid);
294+
int octep_ctrl_net_get_if_stats(struct octep_device *oct, int vfid,
295+
struct octep_iface_rx_stats *rx_stats,
296+
struct octep_iface_tx_stats *tx_stats);
293297

294298
/** Get link info from firmware.
295299
*
296300
* @param oct: non-null pointer to struct octep_device.
297301
* @param vfid: Index of virtual function.
302+
* @param link_info: non-null pointer to struct octep_iface_link_info.
298303
*
299304
* return value: 0 on success, -errno on failure.
300305
*/
301-
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid);
306+
int octep_ctrl_net_get_link_info(struct octep_device *oct, int vfid,
307+
struct octep_iface_link_info *link_info);
302308

303309
/** Set link info in firmware.
304310
*

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,12 @@ octep_get_ethtool_stats(struct net_device *netdev,
150150
rx_packets = 0;
151151
rx_bytes = 0;
152152

153-
octep_ctrl_net_get_if_stats(oct, OCTEP_CTRL_NET_INVALID_VFID);
154153
iface_tx_stats = &oct->iface_tx_stats;
155154
iface_rx_stats = &oct->iface_rx_stats;
155+
octep_ctrl_net_get_if_stats(oct,
156+
OCTEP_CTRL_NET_INVALID_VFID,
157+
iface_rx_stats,
158+
iface_tx_stats);
156159

157160
for (q = 0; q < oct->num_oqs; q++) {
158161
struct octep_iq *iq = oct->iq[q];
@@ -283,11 +286,11 @@ static int octep_get_link_ksettings(struct net_device *netdev,
283286
ethtool_link_ksettings_zero_link_mode(cmd, supported);
284287
ethtool_link_ksettings_zero_link_mode(cmd, advertising);
285288

286-
octep_ctrl_net_get_link_info(oct, OCTEP_CTRL_NET_INVALID_VFID);
289+
link_info = &oct->link_info;
290+
octep_ctrl_net_get_link_info(oct, OCTEP_CTRL_NET_INVALID_VFID, link_info);
287291

288292
advertised_modes = oct->link_info.advertised_modes;
289293
supported_modes = oct->link_info.supported_modes;
290-
link_info = &oct->link_info;
291294

292295
OCTEP_SET_ETHTOOL_LINK_MODES_BITMAP(supported_modes, cmd, supported);
293296
OCTEP_SET_ETHTOOL_LINK_MODES_BITMAP(advertised_modes, cmd, advertising);

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,10 @@ static void octep_get_stats64(struct net_device *netdev,
763763
int q;
764764

765765
if (netif_running(netdev))
766-
octep_ctrl_net_get_if_stats(oct, OCTEP_CTRL_NET_INVALID_VFID);
766+
octep_ctrl_net_get_if_stats(oct,
767+
OCTEP_CTRL_NET_INVALID_VFID,
768+
&oct->iface_rx_stats,
769+
&oct->iface_tx_stats);
767770

768771
tx_packets = 0;
769772
tx_bytes = 0;

0 commit comments

Comments
 (0)