Skip to content

Commit

Permalink
be2net: Minor code cleanup in tx completion process
Browse files Browse the repository at this point in the history
- To avoid multiple accesses to CQE, extract compl_status and end_idx from
  be_tx_compl_get().

Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Sriharsha Basavapatna authored and David S. Miller committed Feb 20, 2015
1 parent 79a0d7d commit 152ffe5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
7 changes: 7 additions & 0 deletions drivers/net/ethernet/emulex/benet/be.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,17 @@ struct be_tx_stats {
struct u64_stats_sync sync_compl;
};

/* Structure to hold some data of interest obtained from a TX CQE */
struct be_tx_compl_info {
u8 status; /* Completion status */
u16 end_index; /* Completed TXQ Index */
};

struct be_tx_obj {
u32 db_offset;
struct be_queue_info q;
struct be_queue_info cq;
struct be_tx_compl_info txcp;
/* Remember the skbs that were transmitted */
struct sk_buff *sent_skb_list[TX_Q_LEN];
struct be_tx_stats stats;
Expand Down
47 changes: 24 additions & 23 deletions drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,18 +2064,23 @@ static void be_post_rx_frags(struct be_rx_obj *rxo, gfp_t gfp, u32 frags_needed)
}
}

static struct be_eth_tx_compl *be_tx_compl_get(struct be_queue_info *tx_cq)
static struct be_tx_compl_info *be_tx_compl_get(struct be_tx_obj *txo)
{
struct be_eth_tx_compl *txcp = queue_tail_node(tx_cq);
struct be_queue_info *tx_cq = &txo->cq;
struct be_tx_compl_info *txcp = &txo->txcp;
struct be_eth_tx_compl *compl = queue_tail_node(tx_cq);

if (txcp->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] == 0)
if (compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] == 0)
return NULL;

/* Ensure load ordering of valid bit dword and other dwords below */
rmb();
be_dws_le_to_cpu(txcp, sizeof(*txcp));
be_dws_le_to_cpu(compl, sizeof(*compl));

txcp->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] = 0;
txcp->status = GET_TX_COMPL_BITS(status, compl);
txcp->end_index = GET_TX_COMPL_BITS(wrb_index, compl);

compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] = 0;
queue_tail_inc(tx_cq);
return txcp;
}
Expand Down Expand Up @@ -2196,9 +2201,9 @@ static void be_tx_compl_clean(struct be_adapter *adapter)
{
u16 end_idx, notified_idx, cmpl = 0, timeo = 0, num_wrbs = 0;
struct device *dev = &adapter->pdev->dev;
struct be_tx_obj *txo;
struct be_tx_compl_info *txcp;
struct be_queue_info *txq;
struct be_eth_tx_compl *txcp;
struct be_tx_obj *txo;
int i, pending_txqs;

/* Stop polling for compls when HW has been silent for 10ms */
Expand All @@ -2209,10 +2214,10 @@ static void be_tx_compl_clean(struct be_adapter *adapter)
cmpl = 0;
num_wrbs = 0;
txq = &txo->q;
while ((txcp = be_tx_compl_get(&txo->cq))) {
end_idx = GET_TX_COMPL_BITS(wrb_index, txcp);
num_wrbs += be_tx_compl_process(adapter, txo,
end_idx);
while ((txcp = be_tx_compl_get(txo))) {
num_wrbs +=
be_tx_compl_process(adapter, txo,
txcp->end_index);
cmpl++;
}
if (cmpl) {
Expand Down Expand Up @@ -2571,7 +2576,7 @@ static int be_process_rx(struct be_rx_obj *rxo, struct napi_struct *napi,
return work_done;
}

static inline void be_update_tx_err(struct be_tx_obj *txo, u32 status)
static inline void be_update_tx_err(struct be_tx_obj *txo, u8 status)
{
switch (status) {
case BE_TX_COMP_HDR_PARSE_ERR:
Expand All @@ -2586,7 +2591,7 @@ static inline void be_update_tx_err(struct be_tx_obj *txo, u32 status)
}
}

static inline void lancer_update_tx_err(struct be_tx_obj *txo, u32 status)
static inline void lancer_update_tx_err(struct be_tx_obj *txo, u8 status)
{
switch (status) {
case LANCER_TX_COMP_LSO_ERR:
Expand All @@ -2611,22 +2616,18 @@ static inline void lancer_update_tx_err(struct be_tx_obj *txo, u32 status)
static void be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo,
int idx)
{
struct be_eth_tx_compl *txcp;
int num_wrbs = 0, work_done = 0;
u32 compl_status;
u16 last_idx;
struct be_tx_compl_info *txcp;

while ((txcp = be_tx_compl_get(&txo->cq))) {
last_idx = GET_TX_COMPL_BITS(wrb_index, txcp);
num_wrbs += be_tx_compl_process(adapter, txo, last_idx);
while ((txcp = be_tx_compl_get(txo))) {
num_wrbs += be_tx_compl_process(adapter, txo, txcp->end_index);
work_done++;

compl_status = GET_TX_COMPL_BITS(status, txcp);
if (compl_status) {
if (txcp->status) {
if (lancer_chip(adapter))
lancer_update_tx_err(txo, compl_status);
lancer_update_tx_err(txo, txcp->status);
else
be_update_tx_err(txo, compl_status);
be_update_tx_err(txo, txcp->status);
}
}

Expand Down

0 comments on commit 152ffe5

Please sign in to comment.