Re: [PATCH net-next 2/8] qed: Revise ll2 Rx completion

2017-06-08 Thread David Miller
From: Yuval Mintz 
Date: Thu, 8 Jun 2017 19:13:17 +0300

> +struct qed_ll2_comp_rx_data {
> + u8 connection_handle;
> + void *cookie;
> + dma_addr_t rx_buf_addr;
> + u16 parse_flags;
> + u16 vlan;
> + bool b_last_packet;
> +
> + union {
> + u8 placement_offset;
> + u8 data_length_error;
> + } u;
> + union {
> + u16 packet_length;
> + u16 data_length;
> + } length;
> +
> + u32 opaque_data_0;
> + u32 opaque_data_1;
> +
> + /* GSI only */
> + u32 gid_dst[4];
> + u16 qp_id;
> +};
> +

Again, a lot of unnecessary padding in the structure due to suboptimal
member ordering.

Please fix this.

Thank you.


[PATCH net-next 2/8] qed: Revise ll2 Rx completion

2017-06-08 Thread Yuval Mintz
This introduces qed_ll2_comp_rx_data as a public struct
and moves handling of Rx packets in LL2 into using it.

Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/qed/qed_ll2.c | 84 ++-
 include/linux/qed/qed_ll2_if.h| 25 +
 2 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c 
b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
index 0b75f5d..46b71a6 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c
@@ -165,41 +165,33 @@ static void qed_ll2_kill_buffers(struct qed_dev *cdev)
 }
 
 static void qed_ll2b_complete_rx_packet(struct qed_hwfn *p_hwfn,
-   u8 connection_handle,
-   struct qed_ll2_rx_packet *p_pkt,
-   struct core_rx_fast_path_cqe *p_cqe,
-   bool b_last_packet)
+struct qed_ll2_comp_rx_data *data)
 {
-   u16 packet_length = le16_to_cpu(p_cqe->packet_length);
-   struct qed_ll2_buffer *buffer = p_pkt->cookie;
+   struct qed_ll2_buffer *buffer = data->cookie;
struct qed_dev *cdev = p_hwfn->cdev;
-   u16 vlan = le16_to_cpu(p_cqe->vlan);
-   u32 opaque_data_0, opaque_data_1;
-   u8 pad = p_cqe->placement_offset;
dma_addr_t new_phys_addr;
struct sk_buff *skb;
bool reuse = false;
int rc = -EINVAL;
u8 *new_data;
 
-   opaque_data_0 = le32_to_cpu(p_cqe->opaque_data.data[0]);
-   opaque_data_1 = le32_to_cpu(p_cqe->opaque_data.data[1]);
-
DP_VERBOSE(p_hwfn,
   (NETIF_MSG_RX_STATUS | QED_MSG_STORAGE | NETIF_MSG_PKTDATA),
   "Got an LL2 Rx completion: [Buffer at phys 0x%llx, offset 
0x%02x] Length 0x%04x Parse_flags 0x%04x vlan 0x%04x Opaque data 
[0x%08x:0x%08x]\n",
-  (u64)p_pkt->rx_buf_addr, pad, packet_length,
-  le16_to_cpu(p_cqe->parse_flags.flags), vlan,
-  opaque_data_0, opaque_data_1);
+  (u64)data->rx_buf_addr,
+  data->u.placement_offset,
+  data->length.packet_length,
+  data->parse_flags,
+  data->vlan, data->opaque_data_0, data->opaque_data_1);
 
if ((cdev->dp_module & NETIF_MSG_PKTDATA) && buffer->data) {
print_hex_dump(KERN_INFO, "",
   DUMP_PREFIX_OFFSET, 16, 1,
-  buffer->data, packet_length, false);
+  buffer->data, data->length.packet_length, false);
}
 
/* Determine if data is valid */
-   if (packet_length < ETH_HLEN)
+   if (data->length.packet_length < ETH_HLEN)
reuse = true;
 
/* Allocate a replacement for buffer; Reuse upon failure */
@@ -219,9 +211,9 @@ static void qed_ll2b_complete_rx_packet(struct qed_hwfn 
*p_hwfn,
goto out_post;
}
 
-   pad += NET_SKB_PAD;
-   skb_reserve(skb, pad);
-   skb_put(skb, packet_length);
+   data->u.placement_offset += NET_SKB_PAD;
+   skb_reserve(skb, data->u.placement_offset);
+   skb_put(skb, data->length.packet_length);
skb_checksum_none_assert(skb);
 
/* Get parital ethernet information instead of eth_type_trans(),
@@ -232,10 +224,12 @@ static void qed_ll2b_complete_rx_packet(struct qed_hwfn 
*p_hwfn,
 
/* Pass SKB onward */
if (cdev->ll2->cbs && cdev->ll2->cbs->rx_cb) {
-   if (vlan)
-   __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan);
+   if (data->vlan)
+   __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
+  data->vlan);
cdev->ll2->cbs->rx_cb(cdev->ll2->cb_cookie, skb,
- opaque_data_0, opaque_data_1);
+ data->opaque_data_0,
+ data->opaque_data_1);
}
 
/* Update Buffer information and update FW producer */
@@ -472,33 +466,55 @@ qed_ll2_rxq_completion_gsi(struct qed_hwfn *p_hwfn,
return 0;
 }
 
-static int qed_ll2_rxq_completion_reg(struct qed_hwfn *p_hwfn,
- struct qed_ll2_info *p_ll2_conn,
- union core_rx_cqe_union *p_cqe,
- unsigned long *p_lock_flags,
- bool b_last_cqe)
+static void qed_ll2_rxq_parse_reg(struct qed_hwfn *p_hwfn,
+ union core_rx_cqe_union *p_cqe,
+ struct qed_ll2_comp_rx_data *data)
+{
+   data->parse_flags = le16_to_cpu(p_cqe->rx_cqe_fp.parse_flags.flags);
+   data->length.packet_length =
+