* [PATCH 2.6.11 1/8] tg3: add 5705_plus flag
@ 2005-03-21 7:14 Michael Chan
2005-03-22 20:52 ` Jeff Garzik
2005-03-23 19:03 ` David S. Miller
0 siblings, 2 replies; 4+ messages in thread
From: Michael Chan @ 2005-03-21 7:14 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 232 bytes --]
Add a 5705_plus flag to indicate the device is 5705, 5750, or future chips
that all share the same basic architecture. This makes it easier to add
support for future devices.
Signed-off-by: Michael Chan <mchan@broadcom.com>
[-- Attachment #2: tg3-1.patch --]
[-- Type: application/octet-stream, Size: 8885 bytes --]
diff -Nru 1/drivers/net/tg3.c 2/drivers/net/tg3.c
--- 1/drivers/net/tg3.c 2005-03-14 22:11:22.000000000 -0800
+++ 2/drivers/net/tg3.c 2005-03-14 22:09:51.000000000 -0800
@@ -103,9 +103,7 @@
* replace things like '% foo' with '& (foo - 1)'.
*/
#define TG3_RX_RCB_RING_SIZE(tp) \
- ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 || \
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) ? \
- 512 : 1024)
+ ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ? 512 : 1024)
#define TG3_TX_RING_SIZE 512
#define TG3_DEF_TX_RING_PENDING (TG3_TX_RING_SIZE - 1)
@@ -468,8 +466,7 @@
0x1f);
tp->pci_clock_ctrl = clock_ctrl;
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) {
tw32_f(TG3PCI_CLOCK_CTRL,
clock_ctrl | CLOCK_CTRL_625_CORE);
@@ -1093,8 +1090,7 @@
CLOCK_CTRL_TXCLK_DISABLE |
CLOCK_CTRL_ALTCLK);
newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
- } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
+ } else if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
newbits1 = CLOCK_CTRL_625_CORE;
newbits2 = newbits1 | CLOCK_CTRL_ALTCLK;
} else {
@@ -1108,8 +1104,7 @@
tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2);
udelay(40);
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
u32 newbits3;
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
@@ -2448,8 +2443,7 @@
(6 << TX_LENGTHS_IPG_SHIFT) |
(32 << TX_LENGTHS_SLOT_TIME_SHIFT)));
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
if (netif_carrier_ok(tp->dev)) {
tw32(HOSTCC_STAT_COAL_TICKS,
DEFAULT_STAT_COAL_TICKS);
@@ -3568,8 +3562,7 @@
unsigned int i;
u32 val;
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
switch (ofs) {
case RCVLSC_MODE:
case DMAC_MODE:
@@ -3811,8 +3804,7 @@
}
}
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
tw32(GRC_MISC_CFG, val);
@@ -4127,7 +4119,7 @@
int i;
if (offset == TX_CPU_BASE &&
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
+ (tp->tg3_flags2 & TG3_FLG2_5705_PLUS))
BUG();
if (offset == RX_CPU_BASE) {
@@ -4181,14 +4173,14 @@
void (*write_op)(struct tg3 *, u32, u32);
if (cpu_base == TX_CPU_BASE &&
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
+ (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
printk(KERN_ERR PFX "tg3_load_firmware_cpu: Trying to load "
"TX cpu firmware on %s which is 5705.\n",
tp->dev->name);
return -EINVAL;
}
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
write_op = tg3_write_mem;
else
write_op = tg3_write_indirect_reg32;
@@ -4928,8 +4920,7 @@
(bdinfo_addr + TG3_BDINFO_MAXLEN_FLAGS),
maxlen_flags);
- if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) &&
- (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750))
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS))
tg3_write_mem(tp,
(bdinfo_addr + TG3_BDINFO_NIC_ADDR),
nic_addr);
@@ -5107,8 +5098,7 @@
/* Don't even try to program the JUMBO/MINI buffer descriptor
* configs on 5705.
*/
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
RX_STD_MAX_SIZE_5705 << BDINFO_FLAGS_MAXLEN_SHIFT);
} else {
@@ -5140,8 +5130,7 @@
/* There is only one send ring on 5705/5750, no need to explicitly
* disable the others.
*/
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
/* Clear out send RCB ring in SRAM. */
for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
@@ -5162,8 +5151,7 @@
/* There is only one receive return ring on 5705/5750, no need
* to explicitly disable the others.
*/
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK;
i += TG3_BDINFO_SIZE) {
tg3_write_mem(tp, i + TG3_BDINFO_MAXLEN_FLAGS,
@@ -5262,8 +5250,7 @@
tw32(HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS);
tw32(HOSTCC_RXMAX_FRAMES, 1);
tw32(HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES);
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
tw32(HOSTCC_RXCOAL_TICK_INT, 0);
tw32(HOSTCC_TXCOAL_TICK_INT, 0);
}
@@ -5276,8 +5263,7 @@
tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
((u64) tp->status_mapping & 0xffffffff));
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
/* Status/statistics block address. See tg3_timer,
* the tg3_periodic_fetch_stats call there, and
* tg3_get_stats to see how this works for 5705/5750 chips.
@@ -5296,8 +5282,7 @@
tw32(RCVCC_MODE, RCVCC_MODE_ENABLE | RCVCC_MODE_ATTN_ENABLE);
tw32(RCVLPC_MODE, RCVLPC_MODE_ENABLE);
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750)
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS))
tw32(RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE);
/* Clear statistics/status block in chip, and status block in ram. */
@@ -5324,8 +5309,7 @@
tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
tr32(MAILBOX_INTERRUPT_0);
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
tw32_f(DMAC_MODE, DMAC_MODE_ENABLE);
udelay(40);
}
@@ -5372,8 +5356,7 @@
udelay(40);
tw32(RCVDCC_MODE, RCVDCC_MODE_ENABLE | RCVDCC_MODE_ATTN_ENABLE);
- if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
- GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750)
+ if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS))
tw32(MBFREE_MODE, MBFREE_MODE_ENABLE);
tw32(SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
tw32(SNDBDC_MODE, SNDBDC_MODE_ENABLE | SNDBDC_MODE_ATTN_ENABLE);
@@ -5477,8 +5460,7 @@
tw32(MAC_RCV_RULE_1, 0x86000004 & RCV_RULE_DISABLE_MASK);
tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK);
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
limit = 8;
else
limit = 16;
@@ -5622,8 +5604,7 @@
return;
}
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
tg3_periodic_fetch_stats(tp);
/* This part only runs once per second. */
@@ -7908,6 +7889,10 @@
tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff;
tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff;
+ if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) ||
+ (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750))
+ tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
+
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
tp->tg3_flags2 |= TG3_FLG2_HW_TSO;
@@ -8795,8 +8780,7 @@
goto err_out_iounmap;
}
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
tp->bufmgr_config.mbuf_read_dma_low_water =
DEFAULT_MB_RDMA_LOW_WATER_5705;
tp->bufmgr_config.mbuf_mac_rx_low_water =
diff -Nru 1/drivers/net/tg3.h 2/drivers/net/tg3.h
--- 1/drivers/net/tg3.h 2005-03-14 22:11:29.000000000 -0800
+++ 2/drivers/net/tg3.h 2005-03-14 22:09:55.000000000 -0800
@@ -2096,6 +2096,7 @@
#define TG3_FLG2_FLASH 0x00008000
#define TG3_FLG2_HW_TSO 0x00010000
#define TG3_FLG2_SERDES_PREEMPHASIS 0x00020000
+#define TG3_FLG2_5705_PLUS 0x00040000
u32 split_mode_max_reqs;
#define SPLIT_MODE_5704_MAX_REQ 3
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 2.6.11 1/8] tg3: add 5705_plus flag
2005-03-21 7:14 [PATCH 2.6.11 1/8] tg3: add 5705_plus flag Michael Chan
@ 2005-03-22 20:52 ` Jeff Garzik
2005-03-24 1:51 ` Matt Mackall
2005-03-23 19:03 ` David S. Miller
1 sibling, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2005-03-22 20:52 UTC (permalink / raw)
To: Michael Chan, David S. Miller; +Cc: netdev
Michael Chan wrote:
> Add a 5705_plus flag to indicate the device is 5705, 5750, or future chips
> that all share the same basic architecture. This makes it easier to add
> support for future devices.
>
>
> Signed-off-by: Michael Chan <mchan@broadcom.com
ACK, and two comments:
1) In general, I encourage changes like this, for both tg3 and other net
drivers. It is -much- better to define a feature flag, and test the
feature flag in the source code, than to define a list of affected
[chips | arches]. Changes like this
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
- GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
+ if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
can be an example to others for future changes.
2) [administrivia] Your patches are encoded as base64, which makes
reviewing and applying your patches difficult. You are violating clause
#3, rules one and two:
http://linux.yyz.us/patch-format.html
For sending patches, I highly recommend using a text file template, and
/usr/sbin/sendmail (sendmail/postfix/exim mail servers provide this). See
http://lkml.org/lkml/2005/2/24/3
for more info.
If you don't want to bother with Unix, I -think- Mozilla Thunderbird for
Windows will correctly attach patches in a way that is useable.
http://www.mozilla.org/products/thunderbird/
Regards,
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 2.6.11 1/8] tg3: add 5705_plus flag
2005-03-22 20:52 ` Jeff Garzik
@ 2005-03-24 1:51 ` Matt Mackall
0 siblings, 0 replies; 4+ messages in thread
From: Matt Mackall @ 2005-03-24 1:51 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Michael Chan, David S. Miller, netdev
On Tue, Mar 22, 2005 at 03:52:27PM -0500, Jeff Garzik wrote:
> Michael Chan wrote:
> >Add a 5705_plus flag to indicate the device is 5705, 5750, or future chips
> >that all share the same basic architecture. This makes it easier to add
> >support for future devices.
> >
> >
> >Signed-off-by: Michael Chan <mchan@broadcom.com
>
> ACK, and two comments:
>
> 1) In general, I encourage changes like this, for both tg3 and other net
> drivers. It is -much- better to define a feature flag, and test the
> feature flag in the source code, than to define a list of affected
> [chips | arches]. Changes like this
>
> - if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ||
> - GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
> + if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
>
> can be an example to others for future changes.
Except this isn't really a feature flag, per se. That would be
something like TG3_HAS_FOO, in other words "what particular feature
this if statement actually cares about". What is currently 5705_PLUS
would then be a bunch of flags HAS_SENSIBLE_X | HAS_FAST_Y | HAS_WORKING_Z.
The "family flag" approach is fine until you run into something that
has X and Y but not Z.
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2.6.11 1/8] tg3: add 5705_plus flag
2005-03-21 7:14 [PATCH 2.6.11 1/8] tg3: add 5705_plus flag Michael Chan
2005-03-22 20:52 ` Jeff Garzik
@ 2005-03-23 19:03 ` David S. Miller
1 sibling, 0 replies; 4+ messages in thread
From: David S. Miller @ 2005-03-23 19:03 UTC (permalink / raw)
To: Michael Chan; +Cc: netdev
On Sun, 20 Mar 2005 23:14:42 -0800
"Michael Chan" <mchan@broadcom.com> wrote:
> Add a 5705_plus flag to indicate the device is 5705, 5750, or future chips
> that all share the same basic architecture. This makes it easier to add
> support for future devices.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
Patch applied, thanks Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-03-24 1:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-21 7:14 [PATCH 2.6.11 1/8] tg3: add 5705_plus flag Michael Chan
2005-03-22 20:52 ` Jeff Garzik
2005-03-24 1:51 ` Matt Mackall
2005-03-23 19:03 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).