Skip to content

Commit f03c8a1

Browse files
Dimitris Michailidiskuba-moo
authored andcommitted
net/funeth: Support for ethtool -m
Add the FW command for reading port module memory pages and implement ethtool's get_module_eeprom_by_page operation. Signed-off-by: Dimitris Michailidis <dmichail@fungible.com> Link: https://lore.kernel.org/r/20220627182000.8198-1-dmichail@fungible.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 849d5aa commit f03c8a1

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

drivers/net/ethernet/fungible/funcore/fun_hci.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ enum fun_port_lane_attr {
442442
};
443443

444444
enum fun_admin_port_subop {
445+
FUN_ADMIN_PORT_SUBOP_XCVR_READ = 0x23,
445446
FUN_ADMIN_PORT_SUBOP_INETADDR_EVENT = 0x24,
446447
};
447448

@@ -595,6 +596,19 @@ struct fun_admin_port_req {
595596

596597
struct fun_admin_read48_req read48[];
597598
} read;
599+
struct fun_admin_port_xcvr_read_req {
600+
u8 subop;
601+
u8 rsvd0;
602+
__be16 flags;
603+
__be32 id;
604+
605+
u8 bank;
606+
u8 page;
607+
u8 offset;
608+
u8 length;
609+
u8 dev_addr;
610+
u8 rsvd1[3];
611+
} xcvr_read;
598612
struct fun_admin_port_inetaddr_event_req {
599613
__u8 subop;
600614
__u8 rsvd0;
@@ -625,6 +639,15 @@ struct fun_admin_port_req {
625639
.id = cpu_to_be32(_id), \
626640
}
627641

642+
#define FUN_ADMIN_PORT_XCVR_READ_REQ_INIT(_flags, _id, _bank, _page, \
643+
_offset, _length, _dev_addr) \
644+
((struct fun_admin_port_xcvr_read_req) { \
645+
.subop = FUN_ADMIN_PORT_SUBOP_XCVR_READ, \
646+
.flags = cpu_to_be16(_flags), .id = cpu_to_be32(_id), \
647+
.bank = (_bank), .page = (_page), .offset = (_offset), \
648+
.length = (_length), .dev_addr = (_dev_addr), \
649+
})
650+
628651
struct fun_admin_port_rsp {
629652
struct fun_admin_rsp_common common;
630653

@@ -659,6 +682,23 @@ struct fun_admin_port_rsp {
659682
} u;
660683
};
661684

685+
struct fun_admin_port_xcvr_read_rsp {
686+
struct fun_admin_rsp_common common;
687+
688+
u8 subop;
689+
u8 rsvd0[3];
690+
__be32 id;
691+
692+
u8 bank;
693+
u8 page;
694+
u8 offset;
695+
u8 length;
696+
u8 dev_addr;
697+
u8 rsvd1[3];
698+
699+
u8 data[128];
700+
};
701+
662702
enum fun_xcvr_type {
663703
FUN_XCVR_BASET = 0x0,
664704
FUN_XCVR_CU = 0x1,

drivers/net/ethernet/fungible/funeth/funeth_ethtool.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,39 @@ static int fun_set_fecparam(struct net_device *netdev,
11181118
return fun_port_write_cmd(fp, FUN_ADMIN_PORT_KEY_FEC, fec_mode);
11191119
}
11201120

1121+
static int fun_get_port_module_page(struct net_device *netdev,
1122+
const struct ethtool_module_eeprom *req,
1123+
struct netlink_ext_ack *extack)
1124+
{
1125+
union {
1126+
struct fun_admin_port_req req;
1127+
struct fun_admin_port_xcvr_read_rsp rsp;
1128+
} cmd;
1129+
struct funeth_priv *fp = netdev_priv(netdev);
1130+
int rc;
1131+
1132+
if (fp->port_caps & FUN_PORT_CAP_VPORT) {
1133+
NL_SET_ERR_MSG_MOD(extack,
1134+
"Specified port is virtual, only physical ports have modules");
1135+
return -EOPNOTSUPP;
1136+
}
1137+
1138+
cmd.req.common = FUN_ADMIN_REQ_COMMON_INIT2(FUN_ADMIN_OP_PORT,
1139+
sizeof(cmd.req));
1140+
cmd.req.u.xcvr_read =
1141+
FUN_ADMIN_PORT_XCVR_READ_REQ_INIT(0, netdev->dev_port,
1142+
req->bank, req->page,
1143+
req->offset, req->length,
1144+
req->i2c_address);
1145+
rc = fun_submit_admin_sync_cmd(fp->fdev, &cmd.req.common, &cmd.rsp,
1146+
sizeof(cmd.rsp), 0);
1147+
if (rc)
1148+
return rc;
1149+
1150+
memcpy(req->data, cmd.rsp.data, req->length);
1151+
return req->length;
1152+
}
1153+
11211154
static const struct ethtool_ops fun_ethtool_ops = {
11221155
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
11231156
ETHTOOL_COALESCE_MAX_FRAMES,
@@ -1156,6 +1189,7 @@ static const struct ethtool_ops fun_ethtool_ops = {
11561189
.get_eth_mac_stats = fun_get_802_3_stats,
11571190
.get_eth_ctrl_stats = fun_get_802_3_ctrl_stats,
11581191
.get_rmon_stats = fun_get_rmon_stats,
1192+
.get_module_eeprom_by_page = fun_get_port_module_page,
11591193
};
11601194

11611195
void fun_set_ethtool_ops(struct net_device *netdev)

0 commit comments

Comments
 (0)