Skip to content

Commit 3e71f6d

Browse files
Ron MercerJeff Garzik
authored andcommitted
qla3xxx: bugfix: Fixed jumbo frame handling for 3032 chip.
The scatter/gather lists were not being build correctly. When large frames spanned several buffers the chip would panic. Signed-off-by: Ron Mercer <ron.mercer@qlogic.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
1 parent 9791633 commit 3e71f6d

File tree

2 files changed

+64
-36
lines changed

2 files changed

+64
-36
lines changed

drivers/net/qla3xxx.c

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,63 +2122,43 @@ static void ql_hw_csum_setup(struct sk_buff *skb,
21222122

21232123
if (ip) {
21242124
if (ip->protocol == IPPROTO_TCP) {
2125-
mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_TC;
2125+
mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_TC |
2126+
OB_3032MAC_IOCB_REQ_IC;
21262127
mac_iocb_ptr->ip_hdr_off = offset;
21272128
mac_iocb_ptr->ip_hdr_len = ip->ihl;
21282129
} else if (ip->protocol == IPPROTO_UDP) {
2129-
mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_UC;
2130+
mac_iocb_ptr->flags1 |= OB_3032MAC_IOCB_REQ_UC |
2131+
OB_3032MAC_IOCB_REQ_IC;
21302132
mac_iocb_ptr->ip_hdr_off = offset;
21312133
mac_iocb_ptr->ip_hdr_len = ip->ihl;
21322134
}
21332135
}
21342136
}
21352137

21362138
/*
2137-
* The difference between 3022 and 3032 sends:
2138-
* 3022 only supports a simple single segment transmission.
2139-
* 3032 supports checksumming and scatter/gather lists (fragments).
2140-
* The 3032 supports sglists by using the 3 addr/len pairs (ALP)
2141-
* in the IOCB plus a chain of outbound address lists (OAL) that
2142-
* each contain 5 ALPs. The last ALP of the IOCB (3rd) or OAL (5th)
2143-
* will used to point to an OAL when more ALP entries are required.
2144-
* The IOCB is always the top of the chain followed by one or more
2145-
* OALs (when necessary).
2139+
* Map the buffers for this transmit. This will return
2140+
* NETDEV_TX_BUSY or NETDEV_TX_OK based on success.
21462141
*/
2147-
static int ql3xxx_send(struct sk_buff *skb, struct net_device *ndev)
2142+
static int ql_send_map(struct ql3_adapter *qdev,
2143+
struct ob_mac_iocb_req *mac_iocb_ptr,
2144+
struct ql_tx_buf_cb *tx_cb,
2145+
struct sk_buff *skb)
21482146
{
2149-
struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev);
2150-
struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
2151-
struct ql_tx_buf_cb *tx_cb;
2152-
u32 tot_len = skb->len;
21532147
struct oal *oal;
21542148
struct oal_entry *oal_entry;
2155-
int len;
2156-
struct ob_mac_iocb_req *mac_iocb_ptr;
2149+
int len = skb_headlen(skb);
21572150
u64 map;
21582151
int seg_cnt, seg = 0;
21592152
int frag_cnt = (int)skb_shinfo(skb)->nr_frags;
21602153

2161-
if (unlikely(atomic_read(&qdev->tx_count) < 2)) {
2162-
if (!netif_queue_stopped(ndev))
2163-
netif_stop_queue(ndev);
2164-
return NETDEV_TX_BUSY;
2165-
}
2166-
tx_cb = &qdev->tx_buf[qdev->req_producer_index] ;
21672154
seg_cnt = tx_cb->seg_count = ql_get_seg_count((skb_shinfo(skb)->nr_frags));
21682155
if(seg_cnt == -1) {
21692156
printk(KERN_ERR PFX"%s: invalid segment count!\n",__func__);
2170-
return NETDEV_TX_OK;
2171-
2157+
return NETDEV_TX_BUSY;
21722158
}
2173-
mac_iocb_ptr = tx_cb->queue_entry;
2174-
mac_iocb_ptr->opcode = qdev->mac_ob_opcode;
2175-
mac_iocb_ptr->flags |= qdev->mb_bit_mask;
2176-
mac_iocb_ptr->transaction_id = qdev->req_producer_index;
2177-
mac_iocb_ptr->data_len = cpu_to_le16((u16) tot_len);
2178-
tx_cb->skb = skb;
2179-
if (skb->ip_summed == CHECKSUM_PARTIAL)
2180-
ql_hw_csum_setup(skb, mac_iocb_ptr);
2181-
len = skb_headlen(skb);
2159+
/*
2160+
* Map the skb buffer first.
2161+
*/
21822162
map = pci_map_single(qdev->pdev, skb->data, len, PCI_DMA_TODEVICE);
21832163
oal_entry = (struct oal_entry *)&mac_iocb_ptr->buf_addr0_low;
21842164
oal_entry->dma_lo = cpu_to_le32(LS_64BITS(map));
@@ -2235,6 +2215,55 @@ static int ql3xxx_send(struct sk_buff *skb, struct net_device *ndev)
22352215
oal_entry->len =
22362216
cpu_to_le32(le32_to_cpu(oal_entry->len) | OAL_LAST_ENTRY);
22372217
}
2218+
return NETDEV_TX_OK;
2219+
}
2220+
2221+
/*
2222+
* The difference between 3022 and 3032 sends:
2223+
* 3022 only supports a simple single segment transmission.
2224+
* 3032 supports checksumming and scatter/gather lists (fragments).
2225+
* The 3032 supports sglists by using the 3 addr/len pairs (ALP)
2226+
* in the IOCB plus a chain of outbound address lists (OAL) that
2227+
* each contain 5 ALPs. The last ALP of the IOCB (3rd) or OAL (5th)
2228+
* will used to point to an OAL when more ALP entries are required.
2229+
* The IOCB is always the top of the chain followed by one or more
2230+
* OALs (when necessary).
2231+
*/
2232+
static int ql3xxx_send(struct sk_buff *skb, struct net_device *ndev)
2233+
{
2234+
struct ql3_adapter *qdev = (struct ql3_adapter *)netdev_priv(ndev);
2235+
struct ql3xxx_port_registers __iomem *port_regs = qdev->mem_map_registers;
2236+
struct ql_tx_buf_cb *tx_cb;
2237+
u32 tot_len = skb->len;
2238+
struct ob_mac_iocb_req *mac_iocb_ptr;
2239+
2240+
if (unlikely(atomic_read(&qdev->tx_count) < 2)) {
2241+
if (!netif_queue_stopped(ndev))
2242+
netif_stop_queue(ndev);
2243+
return NETDEV_TX_BUSY;
2244+
}
2245+
2246+
tx_cb = &qdev->tx_buf[qdev->req_producer_index] ;
2247+
if((tx_cb->seg_count = ql_get_seg_count((skb_shinfo(skb)->nr_frags))) == -1) {
2248+
printk(KERN_ERR PFX"%s: invalid segment count!\n",__func__);
2249+
return NETDEV_TX_OK;
2250+
}
2251+
2252+
mac_iocb_ptr = tx_cb->queue_entry;
2253+
mac_iocb_ptr->opcode = qdev->mac_ob_opcode;
2254+
mac_iocb_ptr->flags = OB_MAC_IOCB_REQ_X;
2255+
mac_iocb_ptr->flags |= qdev->mb_bit_mask;
2256+
mac_iocb_ptr->transaction_id = qdev->req_producer_index;
2257+
mac_iocb_ptr->data_len = cpu_to_le16((u16) tot_len);
2258+
tx_cb->skb = skb;
2259+
if (skb->ip_summed == CHECKSUM_PARTIAL)
2260+
ql_hw_csum_setup(skb, mac_iocb_ptr);
2261+
2262+
if(ql_send_map(qdev,mac_iocb_ptr,tx_cb,skb) != NETDEV_TX_OK) {
2263+
printk(KERN_ERR PFX"%s: Could not map the segments!\n",__func__);
2264+
return NETDEV_TX_BUSY;
2265+
}
2266+
22382267
wmb();
22392268
qdev->req_producer_index++;
22402269
if (qdev->req_producer_index == NUM_REQ_Q_ENTRIES)

drivers/net/qla3xxx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,6 @@ struct oal_entry {
10941094
u32 len;
10951095
#define OAL_LAST_ENTRY 0x80000000 /* Last valid buffer in list. */
10961096
#define OAL_CONT_ENTRY 0x40000000 /* points to an OAL. (continuation) */
1097-
u32 reserved;
10981097
};
10991098

11001099
struct oal {

0 commit comments

Comments
 (0)