mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 04:34:11 +08:00
be2net: add ethtool "-m" option support
This patch adds support for the dump-module-eeprom and module-info ethtool options. Signed-off-by: Mark Leonard <mark.leonard@emulex.com> Signed-off-by: Suresh Reddy <Suresh.Reddy@emulex.com> Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b29812c135
commit
e36edd9d26
@ -2176,6 +2176,53 @@ err:
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Uses sync mcc */
|
||||
int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
|
||||
u8 page_num, u8 *data)
|
||||
{
|
||||
struct be_dma_mem cmd;
|
||||
struct be_mcc_wrb *wrb;
|
||||
struct be_cmd_req_port_type *req;
|
||||
int status;
|
||||
|
||||
if (page_num > TR_PAGE_A2)
|
||||
return -EINVAL;
|
||||
|
||||
cmd.size = sizeof(struct be_cmd_resp_port_type);
|
||||
cmd.va = pci_alloc_consistent(adapter->pdev, cmd.size, &cmd.dma);
|
||||
if (!cmd.va) {
|
||||
dev_err(&adapter->pdev->dev, "Memory allocation failed\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset(cmd.va, 0, cmd.size);
|
||||
|
||||
spin_lock_bh(&adapter->mcc_lock);
|
||||
|
||||
wrb = wrb_from_mccq(adapter);
|
||||
if (!wrb) {
|
||||
status = -EBUSY;
|
||||
goto err;
|
||||
}
|
||||
req = cmd.va;
|
||||
|
||||
be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
|
||||
OPCODE_COMMON_READ_TRANSRECV_DATA,
|
||||
cmd.size, wrb, &cmd);
|
||||
|
||||
req->port = cpu_to_le32(adapter->hba_port_num);
|
||||
req->page_num = cpu_to_le32(page_num);
|
||||
status = be_mcc_notify_wait(adapter);
|
||||
if (!status) {
|
||||
struct be_cmd_resp_port_type *resp = cmd.va;
|
||||
|
||||
memcpy(data, resp->page_data, PAGE_DATA_LEN);
|
||||
}
|
||||
err:
|
||||
spin_unlock_bh(&adapter->mcc_lock);
|
||||
pci_free_consistent(adapter->pdev, cmd.size, cmd.va, cmd.dma);
|
||||
return status;
|
||||
}
|
||||
|
||||
int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
|
||||
u32 data_size, u32 data_offset,
|
||||
const char *obj_name, u32 *data_written,
|
||||
|
@ -1014,28 +1014,15 @@ enum {
|
||||
TR_PAGE_A2 = 0xa2
|
||||
};
|
||||
|
||||
/* From SFF-8472 spec */
|
||||
#define SFP_PLUS_SFF_8472_COMP 0x5E
|
||||
|
||||
#define PAGE_DATA_LEN 256
|
||||
struct be_cmd_resp_port_type {
|
||||
struct be_cmd_resp_hdr hdr;
|
||||
u32 page_num;
|
||||
u32 port;
|
||||
struct data {
|
||||
u8 identifier;
|
||||
u8 identifier_ext;
|
||||
u8 connector;
|
||||
u8 transceiver[8];
|
||||
u8 rsvd0[3];
|
||||
u8 length_km;
|
||||
u8 length_hm;
|
||||
u8 length_om1;
|
||||
u8 length_om2;
|
||||
u8 length_cu;
|
||||
u8 length_cu_m;
|
||||
u8 vendor_name[16];
|
||||
u8 rsvd;
|
||||
u8 vendor_oui[3];
|
||||
u8 vendor_pn[16];
|
||||
u8 vendor_rev[4];
|
||||
} data;
|
||||
u8 page_data[PAGE_DATA_LEN];
|
||||
};
|
||||
|
||||
/******************** Get FW Version *******************/
|
||||
@ -2067,6 +2054,8 @@ int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, u8 beacon,
|
||||
u8 status, u8 state);
|
||||
int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num,
|
||||
u32 *state);
|
||||
int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
|
||||
u8 page_num, u8 *data);
|
||||
int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
|
||||
u32 flash_oper, u32 flash_opcode, u32 buf_size);
|
||||
int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
|
||||
|
@ -1189,6 +1189,58 @@ static int be_set_rxfh(struct net_device *netdev, const u32 *indir,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int be_get_module_info(struct net_device *netdev,
|
||||
struct ethtool_modinfo *modinfo)
|
||||
{
|
||||
struct be_adapter *adapter = netdev_priv(netdev);
|
||||
u8 page_data[PAGE_DATA_LEN];
|
||||
int status;
|
||||
|
||||
if (!check_privilege(adapter, MAX_PRIVILEGES))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
|
||||
page_data);
|
||||
if (!status) {
|
||||
if (!page_data[SFP_PLUS_SFF_8472_COMP]) {
|
||||
modinfo->type = ETH_MODULE_SFF_8079;
|
||||
modinfo->eeprom_len = PAGE_DATA_LEN;
|
||||
} else {
|
||||
modinfo->type = ETH_MODULE_SFF_8472;
|
||||
modinfo->eeprom_len = 2 * PAGE_DATA_LEN;
|
||||
}
|
||||
}
|
||||
return be_cmd_status(status);
|
||||
}
|
||||
|
||||
static int be_get_module_eeprom(struct net_device *netdev,
|
||||
struct ethtool_eeprom *eeprom, u8 *data)
|
||||
{
|
||||
struct be_adapter *adapter = netdev_priv(netdev);
|
||||
int status;
|
||||
|
||||
if (!check_privilege(adapter, MAX_PRIVILEGES))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0,
|
||||
data);
|
||||
if (status)
|
||||
goto err;
|
||||
|
||||
if (eeprom->offset + eeprom->len > PAGE_DATA_LEN) {
|
||||
status = be_cmd_read_port_transceiver_data(adapter,
|
||||
TR_PAGE_A2,
|
||||
data +
|
||||
PAGE_DATA_LEN);
|
||||
if (status)
|
||||
goto err;
|
||||
}
|
||||
if (eeprom->offset)
|
||||
memcpy(data, data + eeprom->offset, eeprom->len);
|
||||
err:
|
||||
return be_cmd_status(status);
|
||||
}
|
||||
|
||||
const struct ethtool_ops be_ethtool_ops = {
|
||||
.get_settings = be_get_settings,
|
||||
.get_drvinfo = be_get_drvinfo,
|
||||
@ -1220,5 +1272,7 @@ const struct ethtool_ops be_ethtool_ops = {
|
||||
.get_rxfh = be_get_rxfh,
|
||||
.set_rxfh = be_set_rxfh,
|
||||
.get_channels = be_get_channels,
|
||||
.set_channels = be_set_channels
|
||||
.set_channels = be_set_channels,
|
||||
.get_module_info = be_get_module_info,
|
||||
.get_module_eeprom = be_get_module_eeprom
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user