Skip to content

Commit

Permalink
Merge branch 'ionic-struct-cleanups'
Browse files Browse the repository at this point in the history
Shannon Nelson says:

====================
ionic: struct cleanups

This patchset has a few changes for better cacheline use,
to cleanup a page handling API, and to streamline the
Adminq/Notifyq queue handling.  Lastly, we also have a couple
of fixes pointed out by the friendly kernel test robot.

v2: dropped change to irq coalesce default
    fixed Neel's attributions to Co-developed-by
    dropped the unnecessary new call to dma_sync_single_for_cpu()
    added 2 patches from kernel test robot results
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Sep 2, 2020
2 parents d3dfc36 + 2aaa05a commit 22b330b
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 138 deletions.
3 changes: 0 additions & 3 deletions drivers/net/ethernet/pensando/ionic/ionic.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ struct ionic_admin_ctx {
union ionic_adminq_comp comp;
};

int ionic_napi(struct napi_struct *napi, int budget, ionic_cq_cb cb,
ionic_cq_done_cb done_cb, void *done_arg);

int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_wait);
int ionic_set_dma_mask(struct ionic *ionic);
Expand Down
33 changes: 3 additions & 30 deletions drivers/net/ethernet/pensando/ionic/ionic_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,7 @@ int ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq,
struct ionic_intr_info *intr,
unsigned int num_descs, size_t desc_size)
{
struct ionic_cq_info *cur;
unsigned int ring_size;
unsigned int i;

if (desc_size == 0 || !is_power_of_2(num_descs))
return -EINVAL;
Expand All @@ -485,19 +483,6 @@ int ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq,
cq->tail_idx = 0;
cq->done_color = 1;

cur = cq->info;

for (i = 0; i < num_descs; i++) {
if (i + 1 == num_descs) {
cur->next = cq->info;
cur->last = true;
} else {
cur->next = cur + 1;
}
cur->index = i;
cur++;
}

return 0;
}

Expand Down Expand Up @@ -551,9 +536,7 @@ int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
unsigned int num_descs, size_t desc_size,
size_t sg_desc_size, unsigned int pid)
{
struct ionic_desc_info *cur;
unsigned int ring_size;
unsigned int i;

if (desc_size == 0 || !is_power_of_2(num_descs))
return -EINVAL;
Expand All @@ -574,18 +557,6 @@ int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,

snprintf(q->name, sizeof(q->name), "L%d-%s%u", lif->index, name, index);

cur = q->info;

for (i = 0; i < num_descs; i++) {
if (i + 1 == num_descs)
cur->next = q->info;
else
cur->next = cur + 1;
cur->index = i;
cur->left = num_descs - i;
cur++;
}

return 0;
}

Expand Down Expand Up @@ -652,6 +623,7 @@ void ionic_q_service(struct ionic_queue *q, struct ionic_cq_info *cq_info,
struct ionic_desc_info *desc_info;
ionic_desc_cb cb;
void *cb_arg;
u16 index;

/* check for empty queue */
if (q->tail_idx == q->head_idx)
Expand All @@ -665,6 +637,7 @@ void ionic_q_service(struct ionic_queue *q, struct ionic_cq_info *cq_info,

do {
desc_info = &q->info[q->tail_idx];
index = q->tail_idx;
q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);

cb = desc_info->cb;
Expand All @@ -675,5 +648,5 @@ void ionic_q_service(struct ionic_queue *q, struct ionic_cq_info *cq_info,

if (cb)
cb(q, desc_info, cq_info, cb_arg);
} while (desc_info->index != stop_index);
} while (index != stop_index);
}
24 changes: 9 additions & 15 deletions drivers/net/ethernet/pensando/ionic/ionic_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ struct ionic_cq_info {
struct ionic_admin_comp *admincq;
struct ionic_notifyq_event *notifyq;
};
struct ionic_cq_info *next;
unsigned int index;
bool last;
};

struct ionic_queue;
Expand Down Expand Up @@ -186,9 +183,6 @@ struct ionic_desc_info {
struct ionic_txq_sg_desc *txq_sg_desc;
struct ionic_rxq_sg_desc *rxq_sgl_desc;
};
struct ionic_desc_info *next;
unsigned int index;
unsigned int left;
unsigned int npages;
struct ionic_page_info pages[IONIC_RX_MAX_SG_ELEMS + 1];
ionic_desc_cb cb;
Expand All @@ -199,16 +193,17 @@ struct ionic_desc_info {

struct ionic_queue {
struct device *dev;
u64 dbell_count;
u64 drop;
u64 stop;
u64 wake;
struct ionic_lif *lif;
struct ionic_desc_info *info;
struct ionic_dev *idev;
u16 head_idx;
u16 tail_idx;
unsigned int index;
unsigned int num_descs;
u64 dbell_count;
u64 stop;
u64 wake;
u64 drop;
struct ionic_dev *idev;
unsigned int type;
unsigned int hw_index;
unsigned int hw_type;
Expand All @@ -226,7 +221,6 @@ struct ionic_queue {
};
dma_addr_t base_pa;
dma_addr_t sg_base_pa;
unsigned int num_descs;
unsigned int desc_size;
unsigned int sg_desc_size;
unsigned int pid;
Expand All @@ -246,17 +240,17 @@ struct ionic_intr_info {
};

struct ionic_cq {
void *base;
dma_addr_t base_pa;
struct ionic_lif *lif;
struct ionic_cq_info *info;
struct ionic_queue *bound_q;
struct ionic_intr_info *bound_intr;
u16 tail_idx;
bool done_color;
unsigned int num_descs;
u64 compl_count;
unsigned int desc_size;
u64 compl_count;
void *base;
dma_addr_t base_pa;
};

struct ionic;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ static void ionic_get_pauseparam(struct net_device *netdev,

pause_type = lif->ionic->idev.port_info->config.pause_type;
if (pause_type) {
pause->rx_pause = pause_type & IONIC_PAUSE_F_RX ? 1 : 0;
pause->tx_pause = pause_type & IONIC_PAUSE_F_TX ? 1 : 0;
pause->rx_pause = (pause_type & IONIC_PAUSE_F_RX) ? 1 : 0;
pause->tx_pause = (pause_type & IONIC_PAUSE_F_TX) ? 1 : 0;
}
}

Expand Down
44 changes: 25 additions & 19 deletions drivers/net/ethernet/pensando/ionic/ionic_lif.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,21 +800,6 @@ static bool ionic_notifyq_service(struct ionic_cq *cq,
return true;
}

static int ionic_notifyq_clean(struct ionic_lif *lif, int budget)
{
struct ionic_dev *idev = &lif->ionic->idev;
struct ionic_cq *cq = &lif->notifyqcq->cq;
u32 work_done;

work_done = ionic_cq_service(cq, budget, ionic_notifyq_service,
NULL, NULL);
if (work_done)
ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index,
work_done, IONIC_INTR_CRED_RESET_COALESCE);

return work_done;
}

static bool ionic_adminq_service(struct ionic_cq *cq,
struct ionic_cq_info *cq_info)
{
Expand All @@ -830,15 +815,36 @@ static bool ionic_adminq_service(struct ionic_cq *cq,

static int ionic_adminq_napi(struct napi_struct *napi, int budget)
{
struct ionic_intr_info *intr = napi_to_cq(napi)->bound_intr;
struct ionic_lif *lif = napi_to_cq(napi)->lif;
struct ionic_dev *idev = &lif->ionic->idev;
unsigned int flags = 0;
int n_work = 0;
int a_work = 0;
int work_done;

if (lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED)
n_work = ionic_cq_service(&lif->notifyqcq->cq, budget,
ionic_notifyq_service, NULL, NULL);

if (likely(lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED))
n_work = ionic_notifyq_clean(lif, budget);
a_work = ionic_napi(napi, budget, ionic_adminq_service, NULL, NULL);
if (lif->adminqcq && lif->adminqcq->flags & IONIC_QCQ_F_INITED)
a_work = ionic_cq_service(&lif->adminqcq->cq, budget,
ionic_adminq_service, NULL, NULL);

work_done = max(n_work, a_work);
if (work_done < budget && napi_complete_done(napi, work_done)) {
flags |= IONIC_INTR_CRED_UNMASK;
DEBUG_STATS_INTR_REARM(intr);
}

return max(n_work, a_work);
if (work_done || flags) {
flags |= IONIC_INTR_CRED_RESET_COALESCE;
ionic_intr_credits(idev->intr_ctrl,
intr->index,
n_work + a_work, flags);
}

return work_done;
}

void ionic_get_stats64(struct net_device *netdev,
Expand Down
14 changes: 7 additions & 7 deletions drivers/net/ethernet/pensando/ionic/ionic_lif.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
#define IONIC_TX_BUDGET_DEFAULT 256

struct ionic_tx_stats {
u64 dma_map_err;
u64 pkts;
u64 bytes;
u64 clean;
u64 linearize;
u64 csum_none;
u64 csum;
u64 crc32_csum;
u64 tso;
u64 tso_bytes;
u64 frags;
u64 vlan_inserted;
u64 clean;
u64 linearize;
u64 crc32_csum;
u64 sg_cntr[IONIC_MAX_NUM_SG_CNTR];
u64 dma_map_err;
};

struct ionic_rx_stats {
u64 dma_map_err;
u64 alloc_err;
u64 pkts;
u64 bytes;
u64 csum_none;
u64 csum_complete;
u64 csum_error;
u64 buffers_posted;
u64 dropped;
u64 vlan_stripped;
u64 csum_error;
u64 dma_map_err;
u64 alloc_err;
};

#define IONIC_QCQ_F_INITED BIT(0)
Expand Down
26 changes: 0 additions & 26 deletions drivers/net/ethernet/pensando/ionic/ionic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,32 +305,6 @@ int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
return ionic_adminq_check_err(lif, ctx, (remaining == 0));
}

int ionic_napi(struct napi_struct *napi, int budget, ionic_cq_cb cb,
ionic_cq_done_cb done_cb, void *done_arg)
{
struct ionic_qcq *qcq = napi_to_qcq(napi);
struct ionic_cq *cq = &qcq->cq;
u32 work_done, flags = 0;

work_done = ionic_cq_service(cq, budget, cb, done_cb, done_arg);

if (work_done < budget && napi_complete_done(napi, work_done)) {
flags |= IONIC_INTR_CRED_UNMASK;
DEBUG_STATS_INTR_REARM(cq->bound_intr);
}

if (work_done || flags) {
flags |= IONIC_INTR_CRED_RESET_COALESCE;
ionic_intr_credits(cq->lif->ionic->idev.intr_ctrl,
cq->bound_intr->index,
work_done, flags);
}

DEBUG_STATS_NAPI_POLL(qcq, work_done);

return work_done;
}

static void ionic_dev_cmd_clean(struct ionic *ionic)
{
union ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs;
Expand Down
Loading

0 comments on commit 22b330b

Please sign in to comment.