Skip to content

Commit

Permalink
cxgb4: add support to flash PHY image
Browse files Browse the repository at this point in the history
Update set_flash to flash PHY image to flash region

Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vishal Kulkarni authored and David S. Miller committed Jun 19, 2020
1 parent 3893c90 commit 4ee339e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ enum cc_fec {

enum {
CXGB4_ETHTOOL_FLASH_FW = 1,
CXGB4_ETHTOOL_FLASH_PHY = 2,
};

struct port_stats {
Expand Down
39 changes: 39 additions & 0 deletions drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static void set_msglevel(struct net_device *dev, u32 val)
static const char * const flash_region_strings[] = {
"All",
"Firmware",
"PHY Firmware",
};

static const char stats_strings[][ETH_GSTRING_LEN] = {
Expand Down Expand Up @@ -1240,6 +1241,39 @@ static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
return err;
}

#define CXGB4_PHY_SIG 0x130000ea

static int cxgb4_validate_phy_image(const u8 *data, u32 *size)
{
struct cxgb4_fw_data *header;

header = (struct cxgb4_fw_data *)data;
if (be32_to_cpu(header->signature) != CXGB4_PHY_SIG)
return -EINVAL;

return 0;
}

static int cxgb4_ethtool_flash_phy(struct net_device *netdev,
const u8 *data, u32 size)
{
struct adapter *adap = netdev2adap(netdev);
int ret;

ret = cxgb4_validate_phy_image(data, NULL);
if (ret) {
dev_err(adap->pdev_dev, "PHY signature mismatch\n");
return ret;
}

ret = t4_load_phy_fw(adap, MEMWIN_NIC, &adap->win0_lock,
NULL, data, size);
if (ret)
dev_err(adap->pdev_dev, "Failed to load PHY FW\n");

return ret;
}

static int cxgb4_ethtool_flash_fw(struct net_device *netdev,
const u8 *data, u32 size)
{
Expand Down Expand Up @@ -1273,6 +1307,9 @@ static int cxgb4_ethtool_flash_region(struct net_device *netdev,
case CXGB4_ETHTOOL_FLASH_FW:
ret = cxgb4_ethtool_flash_fw(netdev, data, size);
break;
case CXGB4_ETHTOOL_FLASH_PHY:
ret = cxgb4_ethtool_flash_phy(netdev, data, size);
break;
default:
ret = -EOPNOTSUPP;
break;
Expand Down Expand Up @@ -1306,6 +1343,8 @@ static int cxgb4_ethtool_get_flash_region(const u8 *data, u32 *size)
{
if (!cxgb4_validate_fw_image(data, size))
return CXGB4_ETHTOOL_FLASH_FW;
if (!cxgb4_validate_phy_image(data, size))
return CXGB4_ETHTOOL_FLASH_PHY;

return -EOPNOTSUPP;
}
Expand Down

0 comments on commit 4ee339e

Please sign in to comment.