Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 64671
b: refs/heads/master
c: 4733007
h: refs/heads/master
i:
  64669: 9ee5354
  64667: a962dd2
  64663: ab5facb
  64655: fe75b4b
  64639: 5ce0438
v: v3
  • Loading branch information
Divy Le Ray authored and Jeff Garzik committed Aug 31, 2007
1 parent ff7b5f9 commit d9d0e65
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 53 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5fbf816fe7d72bfdbf22bfec05b4ec3aa6849f72
refs/heads/master: 47330077650a25d417155848516b2cba97999602
3 changes: 2 additions & 1 deletion trunk/drivers/net/cxgb3/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ const struct adapter_info *t3_get_adapter_info(unsigned int board_id);
int t3_seeprom_read(struct adapter *adapter, u32 addr, u32 *data);
int t3_seeprom_write(struct adapter *adapter, u32 addr, u32 data);
int t3_seeprom_wp(struct adapter *adapter, int enable);
int t3_check_tpsram_version(struct adapter *adapter);
int t3_get_tp_version(struct adapter *adapter, u32 *vers);
int t3_check_tpsram_version(struct adapter *adapter, int *must_load);
int t3_check_tpsram(struct adapter *adapter, u8 *tp_ram, unsigned int size);
int t3_set_proto_sram(struct adapter *adap, u8 *data);
int t3_read_flash(struct adapter *adapter, unsigned int addr,
Expand Down
126 changes: 81 additions & 45 deletions trunk/drivers/net/cxgb3/cxgb3_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ static void bind_qsets(struct adapter *adap)
}

#define FW_FNAME "t3fw-%d.%d.%d.bin"
#define TPSRAM_NAME "t3%c_protocol_sram-%d.%d.%d.bin"

static int upgrade_fw(struct adapter *adap)
{
Expand All @@ -747,6 +748,71 @@ static int upgrade_fw(struct adapter *adap)
}
ret = t3_load_fw(adap, fw->data, fw->size);
release_firmware(fw);

if (ret == 0)
dev_info(dev, "successful upgrade to firmware %d.%d.%d\n",
FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_MICRO);
else
dev_err(dev, "failed to upgrade to firmware %d.%d.%d\n",
FW_VERSION_MAJOR, FW_VERSION_MINOR, FW_VERSION_MICRO);

return ret;
}

static inline char t3rev2char(struct adapter *adapter)
{
char rev = 0;

switch(adapter->params.rev) {
case T3_REV_B:
case T3_REV_B2:
rev = 'b';
break;
}
return rev;
}

int update_tpsram(struct adapter *adap)
{
const struct firmware *tpsram;
char buf[64];
struct device *dev = &adap->pdev->dev;
int ret;
char rev;

rev = t3rev2char(adap);
if (!rev)
return 0;

snprintf(buf, sizeof(buf), TPSRAM_NAME, rev,
TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);

ret = request_firmware(&tpsram, buf, dev);
if (ret < 0) {
dev_err(dev, "could not load TP SRAM: unable to load %s\n",
buf);
return ret;
}

ret = t3_check_tpsram(adap, tpsram->data, tpsram->size);
if (ret)
goto release_tpsram;

ret = t3_set_proto_sram(adap, tpsram->data);
if (ret == 0)
dev_info(dev,
"successful update of protocol engine "
"to %d.%d.%d\n",
TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);
else
dev_err(dev, "failed to update of protocol engine %d.%d.%d\n",
TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);
if (ret)
dev_err(dev, "loading protocol SRAM failed\n");

release_tpsram:
release_firmware(tpsram);

return ret;
}

Expand All @@ -763,6 +829,7 @@ static int upgrade_fw(struct adapter *adap)
static int cxgb_up(struct adapter *adap)
{
int err = 0;
int must_load;

if (!(adap->flags & FULL_INIT_DONE)) {
err = t3_check_fw_version(adap);
Expand All @@ -771,6 +838,13 @@ static int cxgb_up(struct adapter *adap)
if (err)
goto out;

err = t3_check_tpsram_version(adap, &must_load);
if (err == -EINVAL) {
err = update_tpsram(adap);
if (err && must_load)
goto out;
}

err = init_dummy_netdevs(adap);
if (err)
goto out;
Expand Down Expand Up @@ -1110,8 +1184,10 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
u32 fw_vers = 0;
u32 tp_vers = 0;

t3_get_fw_version(adapter, &fw_vers);
t3_get_tp_version(adapter, &tp_vers);

strcpy(info->driver, DRV_NAME);
strcpy(info->version, DRV_VERSION);
Expand All @@ -1120,11 +1196,14 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
strcpy(info->fw_version, "N/A");
else {
snprintf(info->fw_version, sizeof(info->fw_version),
"%s %u.%u.%u",
"%s %u.%u.%u TP %u.%u.%u",
G_FW_VERSION_TYPE(fw_vers) ? "T" : "N",
G_FW_VERSION_MAJOR(fw_vers),
G_FW_VERSION_MINOR(fw_vers),
G_FW_VERSION_MICRO(fw_vers));
G_FW_VERSION_MICRO(fw_vers),
G_TP_VERSION_MAJOR(tp_vers),
G_TP_VERSION_MINOR(tp_vers),
G_TP_VERSION_MICRO(tp_vers));
}
}

Expand Down Expand Up @@ -2107,42 +2186,6 @@ static void cxgb_netpoll(struct net_device *dev)
}
#endif

#define TPSRAM_NAME "t3%c_protocol_sram-%d.%d.%d.bin"
int update_tpsram(struct adapter *adap)
{
const struct firmware *tpsram;
char buf[64];
struct device *dev = &adap->pdev->dev;
int ret;
char rev;

rev = adap->params.rev == T3_REV_B2 ? 'b' : 'a';

snprintf(buf, sizeof(buf), TPSRAM_NAME, rev,
TP_VERSION_MAJOR, TP_VERSION_MINOR, TP_VERSION_MICRO);

ret = request_firmware(&tpsram, buf, dev);
if (ret < 0) {
dev_err(dev, "could not load TP SRAM: unable to load %s\n",
buf);
return ret;
}

ret = t3_check_tpsram(adap, tpsram->data, tpsram->size);
if (ret)
goto release_tpsram;

ret = t3_set_proto_sram(adap, tpsram->data);
if (ret)
dev_err(dev, "loading protocol SRAM failed\n");

release_tpsram:
release_firmware(tpsram);

return ret;
}


/*
* Periodic accumulation of MAC statistics.
*/
Expand Down Expand Up @@ -2491,13 +2534,6 @@ static int __devinit init_one(struct pci_dev *pdev,
err = -ENODEV;
goto out_free_dev;
}

err = t3_check_tpsram_version(adapter);
if (err == -EINVAL)
err = update_tpsram(adapter);

if (err)
goto out_free_dev;

/*
* The card is now ready to go. If any errors occur during device
Expand Down
46 changes: 40 additions & 6 deletions trunk/drivers/net/cxgb3/t3_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,16 +848,15 @@ static int t3_write_flash(struct adapter *adapter, unsigned int addr,
}

/**
* t3_check_tpsram_version - read the tp sram version
* t3_get_tp_version - read the tp sram version
* @adapter: the adapter
* @vers: where to place the version
*
* Reads the protocol sram version from serial eeprom.
* Reads the protocol sram version from sram.
*/
int t3_check_tpsram_version(struct adapter *adapter)
int t3_get_tp_version(struct adapter *adapter, u32 *vers)
{
int ret;
u32 vers;
unsigned int major, minor;

/* Get version loaded in SRAM */
t3_write_reg(adapter, A_TP_EMBED_OP_FIELD0, 0);
Expand All @@ -866,14 +865,49 @@ int t3_check_tpsram_version(struct adapter *adapter)
if (ret)
return ret;

vers = t3_read_reg(adapter, A_TP_EMBED_OP_FIELD1);
*vers = t3_read_reg(adapter, A_TP_EMBED_OP_FIELD1);

return 0;
}

/**
* t3_check_tpsram_version - read the tp sram version
* @adapter: the adapter
* @must_load: set to 1 if loading a new microcode image is required
*
* Reads the protocol sram version from flash.
*/
int t3_check_tpsram_version(struct adapter *adapter, int *must_load)
{
int ret;
u32 vers;
unsigned int major, minor;

if (adapter->params.rev == T3_REV_A)
return 0;

*must_load = 1;

ret = t3_get_tp_version(adapter, &vers);
if (ret)
return ret;

major = G_TP_VERSION_MAJOR(vers);
minor = G_TP_VERSION_MINOR(vers);

if (major == TP_VERSION_MAJOR && minor == TP_VERSION_MINOR)
return 0;

if (major != TP_VERSION_MAJOR)
CH_ERR(adapter, "found wrong TP version (%u.%u), "
"driver needs version %d.%d\n", major, minor,
TP_VERSION_MAJOR, TP_VERSION_MINOR);
else {
*must_load = 0;
CH_ERR(adapter, "found wrong TP version (%u.%u), "
"driver compiled for version %d.%d\n", major, minor,
TP_VERSION_MAJOR, TP_VERSION_MINOR);
}
return -EINVAL;
}

Expand Down

0 comments on commit d9d0e65

Please sign in to comment.