mirror of
https://github.com/corundum/corundum.git
synced 2025-01-30 08:32:52 +08:00
Use little endian types in hardware structs
This commit is contained in:
parent
9ceacea0e0
commit
220511f661
@ -182,31 +182,31 @@ void mqnic_process_eq(struct net_device *ndev, struct mqnic_eq_ring *eq_ring)
|
||||
if (event->type == MQNIC_EVENT_TYPE_TX_CPL)
|
||||
{
|
||||
// transmit completion event
|
||||
if (unlikely(event->source > priv->tx_cpl_queue_count))
|
||||
if (unlikely(le16_to_cpu(event->source) > priv->tx_cpl_queue_count))
|
||||
{
|
||||
dev_err(priv->dev, "mqnic_process_eq on port %d: unknown event source %d (index %d, type %d)", priv->port, event->source, eq_index, event->type);
|
||||
dev_err(priv->dev, "mqnic_process_eq on port %d: unknown event source %d (index %d, type %d)", priv->port, le16_to_cpu(event->source), eq_index, le16_to_cpu(event->type));
|
||||
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1, event, MQNIC_EVENT_SIZE, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct mqnic_cq_ring *cq_ring = priv->tx_cpl_ring[event->source];
|
||||
struct mqnic_cq_ring *cq_ring = priv->tx_cpl_ring[le16_to_cpu(event->source)];
|
||||
if (likely(cq_ring && cq_ring->handler))
|
||||
{
|
||||
cq_ring->handler(cq_ring);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event->type == MQNIC_EVENT_TYPE_RX_CPL)
|
||||
else if (le16_to_cpu(event->type) == MQNIC_EVENT_TYPE_RX_CPL)
|
||||
{
|
||||
// receive completion event
|
||||
if (unlikely(event->source > priv->rx_cpl_queue_count))
|
||||
if (unlikely(le16_to_cpu(event->source) > priv->rx_cpl_queue_count))
|
||||
{
|
||||
dev_err(priv->dev, "mqnic_process_eq on port %d: unknown event source %d (index %d, type %d)", priv->port, event->source, eq_index, event->type);
|
||||
dev_err(priv->dev, "mqnic_process_eq on port %d: unknown event source %d (index %d, type %d)", priv->port, le16_to_cpu(event->source), eq_index, le16_to_cpu(event->type));
|
||||
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1, event, MQNIC_EVENT_SIZE, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct mqnic_cq_ring *cq_ring = priv->rx_cpl_ring[event->source];
|
||||
struct mqnic_cq_ring *cq_ring = priv->rx_cpl_ring[le16_to_cpu(event->source)];
|
||||
if (likely(cq_ring && cq_ring->handler))
|
||||
{
|
||||
cq_ring->handler(cq_ring);
|
||||
@ -215,7 +215,7 @@ void mqnic_process_eq(struct net_device *ndev, struct mqnic_eq_ring *eq_ring)
|
||||
}
|
||||
else
|
||||
{
|
||||
dev_err(priv->dev, "mqnic_process_eq on port %d: unknown event type %d (index %d, source %d)", priv->port, event->type, eq_index, event->source);
|
||||
dev_err(priv->dev, "mqnic_process_eq on port %d: unknown event type %d (index %d, source %d)", priv->port, le16_to_cpu(event->type), eq_index, le16_to_cpu(event->source));
|
||||
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1, event, MQNIC_EVENT_SIZE, true);
|
||||
}
|
||||
|
||||
|
@ -259,32 +259,32 @@ either expressed or implied, of The Regents of the University of California.
|
||||
#define MQNIC_EVENT_SIZE 32
|
||||
|
||||
struct mqnic_desc {
|
||||
__u16 rsvd0;
|
||||
__u16 tx_csum_cmd;
|
||||
__u32 len;
|
||||
__u64 addr;
|
||||
__le16 rsvd0;
|
||||
__le16 tx_csum_cmd;
|
||||
__le32 len;
|
||||
__le64 addr;
|
||||
};
|
||||
|
||||
struct mqnic_cpl {
|
||||
__u16 queue;
|
||||
__u16 index;
|
||||
__u16 len;
|
||||
__u16 rsvd0;
|
||||
__u32 ts_ns;
|
||||
__u16 ts_s;
|
||||
__u16 rx_csum;
|
||||
__u32 rx_hash;
|
||||
__le16 queue;
|
||||
__le16 index;
|
||||
__le16 len;
|
||||
__le16 rsvd0;
|
||||
__le32 ts_ns;
|
||||
__le16 ts_s;
|
||||
__le16 rx_csum;
|
||||
__le32 rx_hash;
|
||||
__u8 rx_hash_type;
|
||||
__u8 rsvd1;
|
||||
__u8 rsvd2;
|
||||
__u8 rsvd3;
|
||||
__u32 rsvd4;
|
||||
__u32 rsvd5;
|
||||
__le32 rsvd4;
|
||||
__le32 rsvd5;
|
||||
};
|
||||
|
||||
struct mqnic_event {
|
||||
__u16 type;
|
||||
__u16 source;
|
||||
__le16 type;
|
||||
__le16 source;
|
||||
};
|
||||
|
||||
#endif /* MQNIC_HW_H */
|
||||
|
@ -36,8 +36,8 @@ either expressed or implied, of The Regents of the University of California.
|
||||
|
||||
ktime_t mqnic_read_cpl_ts(struct mqnic_dev *mdev, struct mqnic_ring *ring, const struct mqnic_cpl *cpl)
|
||||
{
|
||||
u64 ts_s = cpl->ts_s;
|
||||
u32 ts_ns = cpl->ts_ns;
|
||||
u64 ts_s = le16_to_cpu(cpl->ts_s);
|
||||
u32 ts_ns = le32_to_cpu(cpl->ts_ns);
|
||||
|
||||
if (unlikely(!ring->ts_valid || (ring->ts_s ^ ts_s) & 0xff00))
|
||||
{
|
||||
|
@ -231,8 +231,8 @@ int mqnic_prepare_rx_desc(struct mqnic_priv *priv, struct mqnic_ring *ring, int
|
||||
}
|
||||
|
||||
// write descriptor
|
||||
rx_desc->len = len;
|
||||
rx_desc->addr = dma_addr;
|
||||
rx_desc->len = cpu_to_le32(len);
|
||||
rx_desc->addr = cpu_to_le64(dma_addr);
|
||||
|
||||
// update rx_info
|
||||
rx_info->page = page;
|
||||
@ -296,7 +296,7 @@ int mqnic_process_rx_cq(struct net_device *ndev, struct mqnic_cq_ring *cq_ring,
|
||||
while (cq_ring->head_ptr != cq_tail_ptr && done < budget)
|
||||
{
|
||||
cpl = (struct mqnic_cpl *)(cq_ring->buf + cq_index*cq_ring->stride);
|
||||
ring_index = cpl->index & ring->size_mask;
|
||||
ring_index = le16_to_cpu(cpl->index) & ring->size_mask;
|
||||
rx_info = &ring->rx_info[ring_index];
|
||||
page = rx_info->page;
|
||||
|
||||
@ -325,7 +325,7 @@ int mqnic_process_rx_cq(struct net_device *ndev, struct mqnic_cq_ring *cq_ring,
|
||||
// RX hardware checksum
|
||||
if (ndev->features & NETIF_F_RXCSUM)
|
||||
{
|
||||
skb->csum = be16_to_cpu(cpl->rx_csum);
|
||||
skb->csum = csum_unfold((__sum16)cpu_to_be16(le16_to_cpu(cpl->rx_csum)));
|
||||
skb->ip_summed = CHECKSUM_COMPLETE;
|
||||
}
|
||||
|
||||
@ -333,7 +333,7 @@ int mqnic_process_rx_cq(struct net_device *ndev, struct mqnic_cq_ring *cq_ring,
|
||||
dma_unmap_page(priv->dev, dma_unmap_addr(rx_info, dma_addr), dma_unmap_len(rx_info, len), PCI_DMA_FROMDEVICE);
|
||||
rx_info->dma_addr = 0;
|
||||
|
||||
len = min_t(u32, cpl->len, rx_info->len);
|
||||
len = min_t(u32, le16_to_cpu(cpl->len), rx_info->len);
|
||||
|
||||
dma_sync_single_range_for_cpu(priv->dev, rx_info->dma_addr, rx_info->page_offset, rx_info->len, PCI_DMA_FROMDEVICE);
|
||||
|
||||
@ -349,7 +349,7 @@ int mqnic_process_rx_cq(struct net_device *ndev, struct mqnic_cq_ring *cq_ring,
|
||||
napi_gro_frags(&cq_ring->napi);
|
||||
|
||||
ring->packets++;
|
||||
ring->bytes += cpl->len;
|
||||
ring->bytes += le16_to_cpu(cpl->len);
|
||||
|
||||
done++;
|
||||
|
||||
|
@ -241,7 +241,7 @@ int mqnic_process_tx_cq(struct net_device *ndev, struct mqnic_cq_ring *cq_ring,
|
||||
while (cq_ring->head_ptr != cq_tail_ptr && done < budget)
|
||||
{
|
||||
cpl = (struct mqnic_cpl *)(cq_ring->buf + cq_index*cq_ring->stride);
|
||||
ring_index = cpl->index & ring->size_mask;
|
||||
ring_index = le16_to_cpu(cpl->index) & ring->size_mask;
|
||||
tx_info = &ring->tx_info[ring_index];
|
||||
|
||||
// TX hardware timestamp
|
||||
@ -257,7 +257,7 @@ int mqnic_process_tx_cq(struct net_device *ndev, struct mqnic_cq_ring *cq_ring,
|
||||
mqnic_free_tx_desc(priv, ring, ring_index, napi_budget);
|
||||
|
||||
packets++;
|
||||
bytes += cpl->len;
|
||||
bytes += le16_to_cpu(cpl->len);
|
||||
|
||||
done++;
|
||||
|
||||
@ -359,8 +359,8 @@ static bool mqnic_map_skb(struct mqnic_priv *priv, struct mqnic_ring *ring, stru
|
||||
}
|
||||
|
||||
// write descriptor
|
||||
tx_desc[i+1].len = len;
|
||||
tx_desc[i+1].addr = dma_addr;
|
||||
tx_desc[i+1].len = cpu_to_le32(len);
|
||||
tx_desc[i+1].addr = cpu_to_le64(dma_addr);
|
||||
|
||||
// update tx_info
|
||||
tx_info->frag_count = i+1;
|
||||
@ -385,8 +385,8 @@ static bool mqnic_map_skb(struct mqnic_priv *priv, struct mqnic_ring *ring, stru
|
||||
}
|
||||
|
||||
// write descriptor
|
||||
tx_desc[0].len = len;
|
||||
tx_desc[0].addr = dma_addr;
|
||||
tx_desc[0].len = cpu_to_le32(len);
|
||||
tx_desc[0].addr = cpu_to_le64(dma_addr);
|
||||
|
||||
// update tx_info
|
||||
dma_unmap_addr_set(tx_info, dma_addr, dma_addr);
|
||||
@ -475,7 +475,7 @@ netdev_tx_t mqnic_start_xmit(struct sk_buff *skb, struct net_device *ndev)
|
||||
}
|
||||
else
|
||||
{
|
||||
tx_desc->tx_csum_cmd = 0x8000 | (csum_offset << 8) | (csum_start);
|
||||
tx_desc->tx_csum_cmd = cpu_to_le16(0x8000 | (csum_offset << 8) | (csum_start));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user