Skip to content

Commit 0cd1453

Browse files
Amit Cohenkuba-moo
authored andcommitted
mlxsw: pci: Remove mlxsw_pci_sdq_count()
The number of SDQs is stored as part of 'mlxsw_pci' structure. In some cases, the driver uses this value and in some cases it calls mlxsw_pci_sdq_count() to get the value. Align the code to use the stored value. This simplifies the code and makes it clearer that the value is always the same. Rename 'mlxsw_pci->num_sdq_cqs' to 'mlxsw_pci->num_sdqs' as now it is used not only in CQ context. Signed-off-by: Amit Cohen <amcohen@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/0c8788506d9af35d589dbf64be35a508fd63d681.1712062203.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 1df7d87 commit 0cd1453

File tree

1 file changed

+7
-12
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+7
-12
lines changed

drivers/net/ethernet/mellanox/mlxsw/pci.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct mlxsw_pci {
123123
struct mlxsw_bus_info bus_info;
124124
const struct pci_device_id *id;
125125
enum mlxsw_pci_cqe_v max_cqe_ver; /* Maximal supported CQE version */
126-
u8 num_sdq_cqs; /* Number of CQs used for SDQs */
126+
u8 num_sdqs; /* Number of SDQs */
127127
bool skip_reset;
128128
};
129129

@@ -188,11 +188,6 @@ static u8 __mlxsw_pci_queue_count(struct mlxsw_pci *mlxsw_pci,
188188
return queue_group->count;
189189
}
190190

191-
static u8 mlxsw_pci_sdq_count(struct mlxsw_pci *mlxsw_pci)
192-
{
193-
return __mlxsw_pci_queue_count(mlxsw_pci, MLXSW_PCI_QUEUE_TYPE_SDQ);
194-
}
195-
196191
static u8 mlxsw_pci_cq_count(struct mlxsw_pci *mlxsw_pci)
197192
{
198193
return __mlxsw_pci_queue_count(mlxsw_pci, MLXSW_PCI_QUEUE_TYPE_CQ);
@@ -391,7 +386,7 @@ static int mlxsw_pci_rdq_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
391386
struct mlxsw_pci_queue *q)
392387
{
393388
struct mlxsw_pci_queue_elem_info *elem_info;
394-
u8 sdq_count = mlxsw_pci_sdq_count(mlxsw_pci);
389+
u8 sdq_count = mlxsw_pci->num_sdqs;
395390
int i;
396391
int err;
397392

@@ -457,7 +452,7 @@ static void mlxsw_pci_cq_pre_init(struct mlxsw_pci *mlxsw_pci,
457452
q->cq.v = mlxsw_pci->max_cqe_ver;
458453

459454
if (q->cq.v == MLXSW_PCI_CQE_V2 &&
460-
q->num < mlxsw_pci->num_sdq_cqs &&
455+
q->num < mlxsw_pci->num_sdqs &&
461456
!mlxsw_core_sdq_supports_cqe_v2(mlxsw_pci->core))
462457
q->cq.v = MLXSW_PCI_CQE_V1;
463458
}
@@ -735,10 +730,10 @@ static enum mlxsw_pci_cq_type
735730
mlxsw_pci_cq_type(const struct mlxsw_pci *mlxsw_pci,
736731
const struct mlxsw_pci_queue *q)
737732
{
738-
/* Each CQ is mapped to one DQ. The first 'num_sdq_cqs' queues are used
733+
/* Each CQ is mapped to one DQ. The first 'num_sdqs' queues are used
739734
* for SDQs and the rest are used for RDQs.
740735
*/
741-
if (q->num < mlxsw_pci->num_sdq_cqs)
736+
if (q->num < mlxsw_pci->num_sdqs)
742737
return MLXSW_PCI_CQ_SDQ;
743738

744739
return MLXSW_PCI_CQ_RDQ;
@@ -1112,7 +1107,7 @@ static int mlxsw_pci_aqs_init(struct mlxsw_pci *mlxsw_pci, char *mbox)
11121107
return -EINVAL;
11131108
}
11141109

1115-
mlxsw_pci->num_sdq_cqs = num_sdqs;
1110+
mlxsw_pci->num_sdqs = num_sdqs;
11161111

11171112
err = mlxsw_pci_queue_group_init(mlxsw_pci, mbox, &mlxsw_pci_eq_ops,
11181113
MLXSW_PCI_EQS_COUNT);
@@ -1780,7 +1775,7 @@ static struct mlxsw_pci_queue *
17801775
mlxsw_pci_sdq_pick(struct mlxsw_pci *mlxsw_pci,
17811776
const struct mlxsw_tx_info *tx_info)
17821777
{
1783-
u8 ctl_sdq_count = mlxsw_pci_sdq_count(mlxsw_pci) - 1;
1778+
u8 ctl_sdq_count = mlxsw_pci->num_sdqs - 1;
17841779
u8 sdqn;
17851780

17861781
if (tx_info->is_emad) {

0 commit comments

Comments
 (0)