* [PATCH 2.6.7-rc3-mm2 1/5] via-velocity: PCI ID move
@ 2004-06-18 20:10 Francois Romieu
2004-06-18 20:11 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Francois Romieu
[not found] ` <40D4AA3C.4090606@pobox.com>
0 siblings, 2 replies; 9+ messages in thread
From: Francois Romieu @ 2004-06-18 20:10 UTC (permalink / raw)
To: netdev; +Cc: alan, akpm, jgarzik
(Note: this serie requires a -mm based kernel as the via-velocity patches
are not included in Jeff's -netdev patches).
PCI ID moved from the driver to the kernel database. A change for the
pci.ids file project at souceforge has been submitted as well.
diff -puN drivers/net/via-velocity.c~via-velocity-20 drivers/net/via-velocity.c
--- linux-2.6.7-rc3/drivers/net/via-velocity.c~via-velocity-20 2004-06-18 21:24:53.000000000 +0200
+++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.c 2004-06-18 21:32:01.000000000 +0200
@@ -290,8 +290,9 @@ static struct velocity_info_tbl chip_inf
*/
static struct pci_device_id velocity_id_table[] __devinitdata = {
- {0x1106, 0x3119, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) &chip_info_table[0]},
- {0,}
+ {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) chip_info_table},
+ {0, }
};
MODULE_DEVICE_TABLE(pci, velocity_id_table);
diff -puN include/linux/pci_ids.h~via-velocity-20 include/linux/pci_ids.h
--- linux-2.6.7-rc3/include/linux/pci_ids.h~via-velocity-20 2004-06-18 21:24:53.000000000 +0200
+++ linux-2.6.7-rc3-fr/include/linux/pci_ids.h 2004-06-18 21:24:53.000000000 +0200
@@ -1214,6 +1214,7 @@
#define PCI_DEVICE_ID_VIA_8233C_0 0x3109
#define PCI_DEVICE_ID_VIA_8361 0x3112
#define PCI_DEVICE_ID_VIA_XM266 0x3116
+#define PCI_DEVICE_ID_VIA_612X 0x3119
#define PCI_DEVICE_ID_VIA_862X_0 0x3123
#define PCI_DEVICE_ID_VIA_8753_0 0x3128
#define PCI_DEVICE_ID_VIA_8233A 0x3147
diff -puN drivers/net/via-velocity.h~via-velocity-20 drivers/net/via-velocity.h
--- linux-2.6.7-rc3/drivers/net/via-velocity.h~via-velocity-20 2004-06-18 21:24:53.000000000 +0200
+++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.h 2004-06-18 21:32:00.000000000 +0200
@@ -37,7 +37,6 @@
#define OPTION_DEFAULT { [0 ... MAX_UNITS-1] = -1}
#define REV_ID_VT6110 (0)
-#define DEVICE_ID (0x3119)
#define BYTE_REG_BITS_ON(x,p) do { writeb(readb((p))|(x),(p));} while (0)
#define WORD_REG_BITS_ON(x,p) do { writew(readw((p))|(x),(p));} while (0)
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC
2004-06-18 20:10 [PATCH 2.6.7-rc3-mm2 1/5] via-velocity: PCI ID move Francois Romieu
@ 2004-06-18 20:11 ` Francois Romieu
2004-06-18 20:13 ` [PATCH 2.6.7-rc3-mm2 3/5] via-velocity: velocity_receive_frame diets Francois Romieu
2004-06-18 21:02 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Jeff Garzik
[not found] ` <40D4AA3C.4090606@pobox.com>
1 sibling, 2 replies; 9+ messages in thread
From: Francois Romieu @ 2004-06-18 20:11 UTC (permalink / raw)
To: netdev; +Cc: alan, akpm, jgarzik
Introduce velocity_give_rx_desc() to uniformize the use of OWNED_BY_NIC
through the driver.
diff -puN drivers/net/via-velocity.c~via-velocity-30 drivers/net/via-velocity.c
--- linux-2.6.7-rc3/drivers/net/via-velocity.c~via-velocity-30 2004-06-18 21:34:14.000000000 +0200
+++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.c 2004-06-18 21:34:14.000000000 +0200
@@ -465,6 +465,12 @@ static void velocity_init_cam_filter(str
}
}
+static inline void velocity_give_rx_desc(struct rx_desc *rd)
+{
+ *(u32 *)&rd->rdesc0 = 0;
+ rd->rdesc0.owner = cpu_to_le32(OWNED_BY_NIC);
+}
+
/**
* velocity_rx_reset - handle a receive reset
* @vptr: velocity we are resetting
@@ -485,7 +491,7 @@ static void velocity_rx_reset(struct vel
* Init state, all RD entries belong to the NIC
*/
for (i = 0; i < vptr->options.numrx; ++i)
- vptr->rd_ring[i].rdesc0.owner = cpu_to_le32(OWNED_BY_NIC);
+ velocity_give_rx_desc(vptr->rd_ring + i);
writew(vptr->options.numrx, ®s->RBRDU);
writel(vptr->rd_pool_dma, ®s->RDBaseLo);
@@ -1008,7 +1014,7 @@ static int velocity_init_rd_ring(struct
velocity_free_rd_ring(vptr);
goto out;
}
- rd->rdesc0.owner = OWNED_BY_NIC;
+ velocity_give_rx_desc(rd);
}
vptr->rd_used = vptr->rd_curr = 0;
out:
@@ -1205,8 +1211,7 @@ static int velocity_rx_srv(struct veloci
if (--rd_prev < 0)
rd_prev = vptr->options.numrx - 1;
- rd = &(vptr->rd_ring[rd_prev]);
- rd->rdesc0.owner = OWNED_BY_NIC;
+ velocity_give_rx_desc(vptr->rd_ring + rd_prev);
}
writew(4, &(regs->RBRDU));
vptr->rd_used -= 4;
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.7-rc3-mm2 3/5] via-velocity: velocity_receive_frame diets
2004-06-18 20:11 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Francois Romieu
@ 2004-06-18 20:13 ` Francois Romieu
2004-06-18 20:14 ` [PATCH 2.6.7-rc3-mm2 4/5] via-velocity: Rx buffers allocation rework Francois Romieu
2004-06-18 21:02 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Jeff Garzik
1 sibling, 1 reply; 9+ messages in thread
From: Francois Romieu @ 2004-06-18 20:13 UTC (permalink / raw)
To: netdev; +Cc: alan, akpm, jgarzik
Weight loss in velocity_receive_frame():
- isolate the ip header alignment tsk from velocity_receive_frame();
- following p.30 of the datasheet, rdesc0.len includes the CRC length:
the amount of data copied during the ip alignment can be shortened.
diff -puN drivers/net/via-velocity.c~via-velocity-40 drivers/net/via-velocity.c
--- linux-2.6.7-rc3/drivers/net/via-velocity.c~via-velocity-40 2004-06-18 21:38:59.000000000 +0200
+++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.c 2004-06-18 21:58:58.000000000 +0200
@@ -1255,6 +1255,28 @@ static inline void velocity_rx_csum(stru
}
/**
+ * velocity_iph_realign - IP header alignment
+ * @vptr: velocity we are handling
+ * @skb: network layer packet buffer
+ * @pkt_size: received data size
+ *
+ * Align IP header on a 2 bytes boundary. This behavior can be
+ * configured by the user.
+ */
+static inline void velocity_iph_realign(struct velocity_info *vptr,
+ struct sk_buff *skb, int pkt_size)
+{
+ /* FIXME - memmove ? */
+ if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
+ int i;
+
+ for (i = pkt_size; i >= 0; i--)
+ *(skb->data + i + 2) = *(skb->data + i);
+ skb_reserve(skb, 2);
+ }
+}
+
+/**
* velocity_receive_frame - received packet processor
* @vptr: velocity we are handling
* @idx: ring index
@@ -1268,6 +1290,7 @@ static int velocity_receive_frame(struct
struct net_device_stats *stats = &vptr->stats;
struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
struct rx_desc *rd = &(vptr->rd_ring[idx]);
+ int pkt_len = rd->rdesc0.len;
struct sk_buff *skb;
if (rd->rdesc0.RSR & (RSR_STP | RSR_EDP)) {
@@ -1287,16 +1310,9 @@ static int velocity_receive_frame(struct
rd_info->skb_dma = (dma_addr_t) NULL;
rd_info->skb = NULL;
- /* FIXME - memmove ? */
- if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN) {
- int i;
- for (i = rd->rdesc0.len + 4; i >= 0; i--)
- *(skb->data + i + 2) = *(skb->data + i);
- skb->data += 2;
- skb->tail += 2;
- }
+ velocity_iph_realign(vptr, skb, pkt_len);
- skb_put(skb, (rd->rdesc0.len - 4));
+ skb_put(skb, pkt_len - 4);
skb->protocol = eth_type_trans(skb, skb->dev);
/*
@@ -1316,7 +1332,7 @@ static int velocity_receive_frame(struct
* FIXME: need rx_copybreak handling
*/
- stats->rx_bytes += skb->len;
+ stats->rx_bytes += pkt_len;
netif_rx(skb);
return 0;
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.7-rc3-mm2 4/5] via-velocity: Rx buffers allocation rework
2004-06-18 20:13 ` [PATCH 2.6.7-rc3-mm2 3/5] via-velocity: velocity_receive_frame diets Francois Romieu
@ 2004-06-18 20:14 ` Francois Romieu
2004-06-18 20:16 ` [PATCH 2.6.7-rc3-mm2 5/5] via-velocity: Rx copybreak Francois Romieu
0 siblings, 1 reply; 9+ messages in thread
From: Francois Romieu @ 2004-06-18 20:14 UTC (permalink / raw)
To: netdev; +Cc: alan, akpm, jgarzik
Rework of the Rx buffers allocation:
- Rx irq handler (velocity_rx_srv): defer the Rx buffer allocation until
the packet processing loop is done;
- a separate index related to the Rx descriptor ("rd_dirty") is introduced
to distinguish the first Rx descriptor whose buffer has to be refilled.
This way the driver does not need to confuse this descriptor with the
most recently netif()ed one. Rationale: batch + rx_copybreak;
- dirty/empty Rx descriptors are identified through the whole driver
via an adequate NULL pointer in the velocity_rd_info[] array (see
velocity_rx_refill() and velocity_receive_frame());
- Rx descriptors need to be grouped by a multiple of 4 before they can
be handed back to the asic (hardware constraint). This task is moved
from the Rx processing loop to the Rx refill function;
- factorization of code in velocity_init_rd_ring().
diff -puN drivers/net/via-velocity.c~via-velocity-50 drivers/net/via-velocity.c
--- linux-2.6.7-rc3/drivers/net/via-velocity.c~via-velocity-50 2004-06-18 21:56:21.000000000 +0200
+++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.c 2004-06-18 21:56:21.000000000 +0200
@@ -485,7 +485,7 @@ static void velocity_rx_reset(struct vel
struct mac_regs * regs = vptr->mac_regs;
int i;
- vptr->rd_used = vptr->rd_curr = 0;
+ vptr->rd_dirty = vptr->rd_filled = vptr->rd_curr = 0;
/*
* Init state, all RD entries belong to the NIC
@@ -980,6 +980,49 @@ static void velocity_free_rings(struct v
pci_free_consistent(vptr->pdev, size, vptr->tx_bufs, vptr->tx_bufs_dma);
}
+static inline void velocity_give_many_rx_descs(struct velocity_info *vptr)
+{
+ struct mac_regs *regs = vptr->mac_regs;
+ int avail, dirty, unusable;
+
+ /*
+ * RD number must be equal to 4X per hardware spec
+ * (programming guide rev 1.20, p.13)
+ */
+ if (vptr->rd_filled < 4)
+ return;
+
+ unusable = vptr->rd_filled | 0x0003;
+ dirty = vptr->rd_dirty - unusable + 1;
+ for (avail = vptr->rd_filled & 0xfffc; avail; avail--) {
+ dirty = (dirty > 0) ? dirty - 1 : vptr->options.numrx - 1;
+ velocity_give_rx_desc(vptr->rd_ring + dirty);
+ }
+
+ writew(vptr->rd_filled & 0xfffc, ®s->RBRDU);
+ vptr->rd_filled = unusable;
+}
+
+static int velocity_rx_refill(struct velocity_info *vptr)
+{
+ int dirty = vptr->rd_dirty, done = 0, ret = 0;
+
+ while (!vptr->rd_info[dirty].skb) {
+ ret = velocity_alloc_rx_buf(vptr, dirty);
+ if (ret < 0)
+ break;
+ done++;
+ dirty = (dirty < vptr->options.numrx - 1) ? dirty + 1 : 0;
+ }
+ if (done) {
+ vptr->rd_dirty = dirty;
+ vptr->rd_filled += done;
+ velocity_give_many_rx_descs(vptr);
+ }
+
+ return ret;
+}
+
/**
* velocity_init_rd_ring - set up receive ring
* @vptr: velocity to configure
@@ -990,9 +1033,7 @@ static void velocity_free_rings(struct v
static int velocity_init_rd_ring(struct velocity_info *vptr)
{
- int i, ret = -ENOMEM;
- struct rx_desc *rd;
- struct velocity_rd_info *rd_info;
+ int ret = -ENOMEM;
unsigned int rsize = sizeof(struct velocity_rd_info) *
vptr->options.numrx;
@@ -1001,22 +1042,14 @@ static int velocity_init_rd_ring(struct
goto out;
memset(vptr->rd_info, 0, rsize);
- /* Init the RD ring entries */
- for (i = 0; i < vptr->options.numrx; i++) {
- rd = &(vptr->rd_ring[i]);
- rd_info = &(vptr->rd_info[i]);
+ vptr->rd_filled = vptr->rd_dirty = vptr->rd_curr = 0;
- ret = velocity_alloc_rx_buf(vptr, i);
- if (ret < 0) {
- VELOCITY_PRT(MSG_LEVEL_ERR, KERN_ERR
- "%s: failed to allocate RX buffer.\n",
- vptr->dev->name);
- velocity_free_rd_ring(vptr);
- goto out;
- }
- velocity_give_rx_desc(rd);
+ ret = velocity_rx_refill(vptr);
+ if (ret < 0) {
+ VELOCITY_PRT(MSG_LEVEL_ERR, KERN_ERR
+ "%s: failed to allocate RX buffer.\n", vptr->dev->name);
+ velocity_free_rd_ring(vptr);
}
- vptr->rd_used = vptr->rd_curr = 0;
out:
return ret;
}
@@ -1160,22 +1193,14 @@ static void velocity_free_td_ring(struct
static int velocity_rx_srv(struct velocity_info *vptr, int status)
{
- struct rx_desc *rd;
struct net_device_stats *stats = &vptr->stats;
- struct mac_regs * regs = vptr->mac_regs;
int rd_curr = vptr->rd_curr;
int works = 0;
while (1) {
+ struct rx_desc *rd = vptr->rd_ring + rd_curr;
- rd = &(vptr->rd_ring[rd_curr]);
-
- if ((vptr->rd_info[rd_curr]).skb == NULL) {
- if (velocity_alloc_rx_buf(vptr, rd_curr) < 0)
- break;
- }
-
- if (works++ > 15)
+ if (!vptr->rd_info[rd_curr].skb || (works++ > 15))
break;
if (rd->rdesc0.owner == OWNED_BY_NIC)
@@ -1186,14 +1211,8 @@ static int velocity_rx_srv(struct veloci
* FIXME: need to handle copybreak
*/
if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) {
- if (velocity_receive_frame(vptr, rd_curr) == 0) {
- if (velocity_alloc_rx_buf(vptr, rd_curr) < 0) {
- VELOCITY_PRT(MSG_LEVEL_ERR, KERN_ERR "%s: can not allocate rx buf\n", vptr->dev->name);
- break;
- }
- } else {
+ if (velocity_receive_frame(vptr, rd_curr) < 0)
stats->rx_dropped++;
- }
} else {
if (rd->rdesc0.RSR & RSR_CRC)
stats->rx_crc_errors++;
@@ -1205,24 +1224,18 @@ static int velocity_rx_srv(struct veloci
rd->inten = 1;
- if (++vptr->rd_used >= 4) {
- int i, rd_prev = rd_curr;
- for (i = 0; i < 4; i++) {
- if (--rd_prev < 0)
- rd_prev = vptr->options.numrx - 1;
-
- velocity_give_rx_desc(vptr->rd_ring + rd_prev);
- }
- writew(4, &(regs->RBRDU));
- vptr->rd_used -= 4;
- }
-
vptr->dev->last_rx = jiffies;
rd_curr++;
if (rd_curr >= vptr->options.numrx)
rd_curr = 0;
}
+
+ if (velocity_rx_refill(vptr) < 0) {
+ VELOCITY_PRT(MSG_LEVEL_ERR, KERN_ERR
+ "%s: rx buf allocation failure\n", vptr->dev->name);
+ }
+
vptr->rd_curr = rd_curr;
VAR_USED(stats);
return works;
diff -puN drivers/net/via-velocity.h~via-velocity-50 drivers/net/via-velocity.h
--- linux-2.6.7-rc3/drivers/net/via-velocity.h~via-velocity-50 2004-06-18 21:56:21.000000000 +0200
+++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.h 2004-06-18 21:56:21.000000000 +0200
@@ -1771,7 +1771,8 @@ struct velocity_info {
struct velocity_td_info *td_infos[TX_QUEUE_NO];
int rd_curr;
- int rd_used;
+ int rd_dirty;
+ u32 rd_filled;
struct rx_desc *rd_ring;
struct velocity_rd_info *rd_info; /* It's an array */
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2.6.7-rc3-mm2 5/5] via-velocity: Rx copybreak
2004-06-18 20:14 ` [PATCH 2.6.7-rc3-mm2 4/5] via-velocity: Rx buffers allocation rework Francois Romieu
@ 2004-06-18 20:16 ` Francois Romieu
2004-06-18 20:34 ` Alan Cox
0 siblings, 1 reply; 9+ messages in thread
From: Francois Romieu @ 2004-06-18 20:16 UTC (permalink / raw)
To: netdev; +Cc: alan, akpm, jgarzik
Handle copybreak.
- velocity_rx_refill() is modified to allow the processing of a Rx desc
ring wherein the empty skb slots are not necessarily contiguous. Given
the preceeding changes, rx_copybreak should not need anything else;
- the driver does not rely on rd_info->skb_dma set to NULL any more;
- a few pci_dma_sync_single_for_{cpu/device} changes;
- more function documentation.
Some inspiration has been taken from similar r8169 code.
diff -puN drivers/net/via-velocity.c~via-velocity-60 drivers/net/via-velocity.c
--- linux-2.6.7-rc3/drivers/net/via-velocity.c~via-velocity-60 2004-06-18 21:58:49.000000000 +0200
+++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.c 2004-06-18 21:58:49.000000000 +0200
@@ -226,6 +226,10 @@ VELOCITY_PARAM(wol_opts, "Wake On Lan op
VELOCITY_PARAM(int_works, "Number of packets per interrupt services");
+static int rx_copybreak = 200;
+MODULE_PARM(rx_copybreak, "i");
+MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames");
+
static int velocity_found1(struct pci_dev *pdev, const struct pci_device_id *ent);
static void velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, struct velocity_info_tbl *info);
static int velocity_get_pci_info(struct velocity_info *, struct pci_dev *pdev);
@@ -1007,13 +1011,22 @@ static int velocity_rx_refill(struct vel
{
int dirty = vptr->rd_dirty, done = 0, ret = 0;
- while (!vptr->rd_info[dirty].skb) {
- ret = velocity_alloc_rx_buf(vptr, dirty);
- if (ret < 0)
+ do {
+ struct rx_desc *rd = vptr->rd_ring + dirty;
+
+ /* Fine for an all zero Rx desc at init time as well */
+ if (rd->rdesc0.owner == cpu_to_le32(OWNED_BY_NIC))
break;
+
+ if (!vptr->rd_info[dirty].skb) {
+ ret = velocity_alloc_rx_buf(vptr, dirty);
+ if (ret < 0)
+ break;
+ }
done++;
dirty = (dirty < vptr->options.numrx - 1) ? dirty + 1 : 0;
- }
+ } while (dirty != vptr->rd_curr);
+
if (done) {
vptr->rd_dirty = dirty;
vptr->rd_filled += done;
@@ -1072,7 +1085,7 @@ static void velocity_free_rd_ring(struct
for (i = 0; i < vptr->options.numrx; i++) {
struct velocity_rd_info *rd_info = &(vptr->rd_info[i]);
- if (!rd_info->skb_dma)
+ if (!rd_info->skb)
continue;
pci_unmap_single(vptr->pdev, rd_info->skb_dma, vptr->rx_buf_sz,
PCI_DMA_FROMDEVICE);
@@ -1208,7 +1221,6 @@ static int velocity_rx_srv(struct veloci
/*
* Don't drop CE or RL error frame although RXOK is off
- * FIXME: need to handle copybreak
*/
if ((rd->rdesc0.RSR & RSR_RXOK) || (!(rd->rdesc0.RSR & RSR_RXOK) && (rd->rdesc0.RSR & (RSR_CE | RSR_RL)))) {
if (velocity_receive_frame(vptr, rd_curr) < 0)
@@ -1268,6 +1280,43 @@ static inline void velocity_rx_csum(stru
}
/**
+ * velocity_rx_copy - in place Rx copy for small packets
+ * @rx_skb: network layer packet buffer candidate
+ * @pkt_size: received data size
+ * @rd: receive packet descriptor
+ * @dev: network device
+ *
+ * Replace the current skb that is scheduled for Rx processing by a
+ * shorter, immediatly allocated skb, if the received packet is small
+ * enough. This function returns a negative value if the received
+ * packet is too big or if memory is exhausted.
+ */
+static inline int velocity_rx_copy(struct sk_buff **rx_skb, int pkt_size,
+ struct velocity_info *vptr)
+{
+ int ret = -1;
+
+ if (pkt_size < rx_copybreak) {
+ struct sk_buff *new_skb;
+
+ new_skb = dev_alloc_skb(pkt_size + 2);
+ if (new_skb) {
+ new_skb->dev = vptr->dev;
+ new_skb->ip_summed = rx_skb[0]->ip_summed;
+
+ if (vptr->flags & VELOCITY_FLAGS_IP_ALIGN)
+ skb_reserve(new_skb, 2);
+
+ memcpy(new_skb->data, rx_skb[0]->tail, pkt_size);
+ *rx_skb = new_skb;
+ ret = 0;
+ }
+
+ }
+ return ret;
+}
+
+/**
* velocity_iph_realign - IP header alignment
* @vptr: velocity we are handling
* @skb: network layer packet buffer
@@ -1300,6 +1349,7 @@ static inline void velocity_iph_realign(
static int velocity_receive_frame(struct velocity_info *vptr, int idx)
{
+ void (*pci_action)(struct pci_dev *, dma_addr_t, size_t, int);
struct net_device_stats *stats = &vptr->stats;
struct velocity_rd_info *rd_info = &(vptr->rd_info[idx]);
struct rx_desc *rd = &(vptr->rd_ring[idx]);
@@ -1318,15 +1368,8 @@ static int velocity_receive_frame(struct
skb = rd_info->skb;
skb->dev = vptr->dev;
- pci_unmap_single(vptr->pdev, rd_info->skb_dma, vptr->rx_buf_sz,
- PCI_DMA_FROMDEVICE);
- rd_info->skb_dma = (dma_addr_t) NULL;
- rd_info->skb = NULL;
-
- velocity_iph_realign(vptr, skb, pkt_len);
-
- skb_put(skb, pkt_len - 4);
- skb->protocol = eth_type_trans(skb, skb->dev);
+ pci_dma_sync_single_for_cpu(vptr->pdev, rd_info->skb_dma,
+ vptr->rx_buf_sz, PCI_DMA_FROMDEVICE);
/*
* Drop frame not meeting IEEE 802.3
@@ -1339,11 +1382,21 @@ static int velocity_receive_frame(struct
}
}
+ pci_action = pci_dma_sync_single_for_device;
+
velocity_rx_csum(rd, skb);
- /*
- * FIXME: need rx_copybreak handling
- */
+ if (velocity_rx_copy(&skb, pkt_len, vptr) < 0) {
+ velocity_iph_realign(vptr, skb, pkt_len);
+ pci_action = pci_unmap_single;
+ rd_info->skb = NULL;
+ }
+
+ pci_action(vptr->pdev, rd_info->skb_dma, vptr->rx_buf_sz,
+ PCI_DMA_FROMDEVICE);
+
+ skb_put(skb, pkt_len - 4);
+ skb->protocol = eth_type_trans(skb, skb->dev);
stats->rx_bytes += pkt_len;
netif_rx(skb);
_
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2.6.7-rc3-mm2 5/5] via-velocity: Rx copybreak
2004-06-18 20:16 ` [PATCH 2.6.7-rc3-mm2 5/5] via-velocity: Rx copybreak Francois Romieu
@ 2004-06-18 20:34 ` Alan Cox
0 siblings, 0 replies; 9+ messages in thread
From: Alan Cox @ 2004-06-18 20:34 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, alan, akpm, jgarzik
On Fri, Jun 18, 2004 at 10:16:18PM +0200, Francois Romieu wrote:
> Some inspiration has been taken from similar r8169 code.
All 5 look good to me. Jeff please merge when you send to Linus
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC
2004-06-18 20:11 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Francois Romieu
2004-06-18 20:13 ` [PATCH 2.6.7-rc3-mm2 3/5] via-velocity: velocity_receive_frame diets Francois Romieu
@ 2004-06-18 21:02 ` Jeff Garzik
2004-06-18 21:42 ` Francois Romieu
1 sibling, 1 reply; 9+ messages in thread
From: Jeff Garzik @ 2004-06-18 21:02 UTC (permalink / raw)
To: Francois Romieu; +Cc: netdev, alan, akpm
Francois Romieu wrote:
> Introduce velocity_give_rx_desc() to uniformize the use of OWNED_BY_NIC
> through the driver.
>
> diff -puN drivers/net/via-velocity.c~via-velocity-30 drivers/net/via-velocity.c
> --- linux-2.6.7-rc3/drivers/net/via-velocity.c~via-velocity-30 2004-06-18 21:34:14.000000000 +0200
> +++ linux-2.6.7-rc3-fr/drivers/net/via-velocity.c 2004-06-18 21:34:14.000000000 +0200
> @@ -465,6 +465,12 @@ static void velocity_init_cam_filter(str
> }
> }
>
> +static inline void velocity_give_rx_desc(struct rx_desc *rd)
> +{
> + *(u32 *)&rd->rdesc0 = 0;
> + rd->rdesc0.owner = cpu_to_le32(OWNED_BY_NIC);
> +}
The patch itself is OK, and I will merge, but I wonder:
isn't a wmb() needed perhaps?
Jeff
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC
2004-06-18 21:02 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Jeff Garzik
@ 2004-06-18 21:42 ` Francois Romieu
0 siblings, 0 replies; 9+ messages in thread
From: Francois Romieu @ 2004-06-18 21:42 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, alan, akpm
Jeff Garzik <jgarzik@pobox.com> :
> Francois Romieu wrote:
[...]
> > +static inline void velocity_give_rx_desc(struct rx_desc *rd)
> > +{
> > + *(u32 *)&rd->rdesc0 = 0;
> > + rd->rdesc0.owner = cpu_to_le32(OWNED_BY_NIC);
> > +}
>
> The patch itself is OK, and I will merge, but I wonder:
>
> isn't a wmb() needed perhaps?
/me scratches head...
Ok, everything should be fine with a change in velocity_give_many_rx_descs():
[...]
if (vptr->rd_filled < 4)
return;
<insert a wmb() here>
unusable = vptr->rd_filled | 0x0003;
I'll queue that for the next serie.
--
Ueimor
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2.6.7-rc3-mm2 1/5] via-velocity: PCI ID move
[not found] ` <40D4AA3C.4090606@pobox.com>
@ 2004-06-20 8:51 ` Francois Romieu
0 siblings, 0 replies; 9+ messages in thread
From: Francois Romieu @ 2004-06-20 8:51 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, alan, akpm
Jeff Garzik <jgarzik@pobox.com> :
[...]
> Patch 4 was acceptable but patch(1) rejected. Patch 5 didn't either,
> presumeably due to dependencies on patch 4.
I'll rediff once the next -mm is available.
--
Ueimor
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-06-20 8:51 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-18 20:10 [PATCH 2.6.7-rc3-mm2 1/5] via-velocity: PCI ID move Francois Romieu
2004-06-18 20:11 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Francois Romieu
2004-06-18 20:13 ` [PATCH 2.6.7-rc3-mm2 3/5] via-velocity: velocity_receive_frame diets Francois Romieu
2004-06-18 20:14 ` [PATCH 2.6.7-rc3-mm2 4/5] via-velocity: Rx buffers allocation rework Francois Romieu
2004-06-18 20:16 ` [PATCH 2.6.7-rc3-mm2 5/5] via-velocity: Rx copybreak Francois Romieu
2004-06-18 20:34 ` Alan Cox
2004-06-18 21:02 ` [PATCH 2.6.7-rc3-mm2 2/5] via-velocity: uniformize use of OWNED_BY_NIC Jeff Garzik
2004-06-18 21:42 ` Francois Romieu
[not found] ` <40D4AA3C.4090606@pobox.com>
2004-06-20 8:51 ` [PATCH 2.6.7-rc3-mm2 1/5] via-velocity: PCI ID move Francois Romieu
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).