Skip to content

Commit 0eb61b3

Browse files
Michal Swiatkowskianguy11
authored andcommitted
iavf: use libie adminq descriptors
Use libie_aq_desc instead of iavf_aq_desc. Do needed changes to allow clean build Use libie_aq_raw() wherever it can be used. Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent b46012a commit 0eb61b3

File tree

6 files changed

+106
-191
lines changed

6 files changed

+106
-191
lines changed

drivers/net/ethernet/intel/iavf/iavf_adminq.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static enum iavf_status iavf_alloc_adminq_asq_ring(struct iavf_hw *hw)
1818
ret_code = iavf_allocate_dma_mem(hw, &hw->aq.asq.desc_buf,
1919
iavf_mem_atq_ring,
2020
(hw->aq.num_asq_entries *
21-
sizeof(struct iavf_aq_desc)),
21+
sizeof(struct libie_aq_desc)),
2222
IAVF_ADMINQ_DESC_ALIGNMENT);
2323
if (ret_code)
2424
return ret_code;
@@ -45,7 +45,7 @@ static enum iavf_status iavf_alloc_adminq_arq_ring(struct iavf_hw *hw)
4545
ret_code = iavf_allocate_dma_mem(hw, &hw->aq.arq.desc_buf,
4646
iavf_mem_arq_ring,
4747
(hw->aq.num_arq_entries *
48-
sizeof(struct iavf_aq_desc)),
48+
sizeof(struct libie_aq_desc)),
4949
IAVF_ADMINQ_DESC_ALIGNMENT);
5050

5151
return ret_code;
@@ -81,7 +81,7 @@ static void iavf_free_adminq_arq(struct iavf_hw *hw)
8181
**/
8282
static enum iavf_status iavf_alloc_arq_bufs(struct iavf_hw *hw)
8383
{
84-
struct iavf_aq_desc *desc;
84+
struct libie_aq_desc *desc;
8585
struct iavf_dma_mem *bi;
8686
enum iavf_status ret_code;
8787
int i;
@@ -111,9 +111,9 @@ static enum iavf_status iavf_alloc_arq_bufs(struct iavf_hw *hw)
111111
/* now configure the descriptors for use */
112112
desc = IAVF_ADMINQ_DESC(hw->aq.arq, i);
113113

114-
desc->flags = cpu_to_le16(IAVF_AQ_FLAG_BUF);
114+
desc->flags = cpu_to_le16(LIBIE_AQ_FLAG_BUF);
115115
if (hw->aq.arq_buf_size > IAVF_AQ_LARGE_BUF)
116-
desc->flags |= cpu_to_le16(IAVF_AQ_FLAG_LB);
116+
desc->flags |= cpu_to_le16(LIBIE_AQ_FLAG_LB);
117117
desc->opcode = 0;
118118
/* This is in accordance with Admin queue design, there is no
119119
* register for buffer size configuration
@@ -122,12 +122,12 @@ static enum iavf_status iavf_alloc_arq_bufs(struct iavf_hw *hw)
122122
desc->retval = 0;
123123
desc->cookie_high = 0;
124124
desc->cookie_low = 0;
125-
desc->params.external.addr_high =
125+
desc->params.generic.addr_high =
126126
cpu_to_le32(upper_32_bits(bi->pa));
127-
desc->params.external.addr_low =
127+
desc->params.generic.addr_low =
128128
cpu_to_le32(lower_32_bits(bi->pa));
129-
desc->params.external.param0 = 0;
130-
desc->params.external.param1 = 0;
129+
desc->params.generic.param0 = 0;
130+
desc->params.generic.param1 = 0;
131131
}
132132

133133
alloc_arq_bufs:
@@ -558,8 +558,8 @@ static u16 iavf_clean_asq(struct iavf_hw *hw)
558558
struct iavf_adminq_ring *asq = &hw->aq.asq;
559559
struct iavf_asq_cmd_details *details;
560560
u16 ntc = asq->next_to_clean;
561-
struct iavf_aq_desc desc_cb;
562-
struct iavf_aq_desc *desc;
561+
struct libie_aq_desc desc_cb;
562+
struct libie_aq_desc *desc;
563563

564564
desc = IAVF_ADMINQ_DESC(*asq, ntc);
565565
details = IAVF_ADMINQ_DETAILS(*asq, ntc);
@@ -573,7 +573,7 @@ static u16 iavf_clean_asq(struct iavf_hw *hw)
573573
desc_cb = *desc;
574574
cb_func(hw, &desc_cb);
575575
}
576-
memset((void *)desc, 0, sizeof(struct iavf_aq_desc));
576+
memset((void *)desc, 0, sizeof(struct libie_aq_desc));
577577
memset((void *)details, 0,
578578
sizeof(struct iavf_asq_cmd_details));
579579
ntc++;
@@ -615,14 +615,14 @@ bool iavf_asq_done(struct iavf_hw *hw)
615615
* queue. It runs the queue, cleans the queue, etc
616616
**/
617617
enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
618-
struct iavf_aq_desc *desc,
618+
struct libie_aq_desc *desc,
619619
void *buff, /* can be NULL */
620620
u16 buff_size,
621621
struct iavf_asq_cmd_details *cmd_details)
622622
{
623623
struct iavf_dma_mem *dma_buff = NULL;
624624
struct iavf_asq_cmd_details *details;
625-
struct iavf_aq_desc *desc_on_ring;
625+
struct libie_aq_desc *desc_on_ring;
626626
bool cmd_completed = false;
627627
enum iavf_status status = 0;
628628
u16 retval = 0;
@@ -637,7 +637,7 @@ enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
637637
goto asq_send_command_error;
638638
}
639639

640-
hw->aq.asq_last_status = IAVF_AQ_RC_OK;
640+
hw->aq.asq_last_status = LIBIE_AQ_RC_OK;
641641

642642
val = rd32(hw, IAVF_VF_ATQH1);
643643
if (val >= hw->aq.num_asq_entries) {
@@ -717,9 +717,9 @@ enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
717717
/* Update the address values in the desc with the pa value
718718
* for respective buffer
719719
*/
720-
desc_on_ring->params.external.addr_high =
720+
desc_on_ring->params.generic.addr_high =
721721
cpu_to_le32(upper_32_bits(dma_buff->pa));
722-
desc_on_ring->params.external.addr_low =
722+
desc_on_ring->params.generic.addr_low =
723723
cpu_to_le32(lower_32_bits(dma_buff->pa));
724724
}
725725

@@ -766,13 +766,13 @@ enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
766766
retval &= 0xff;
767767
}
768768
cmd_completed = true;
769-
if ((enum iavf_admin_queue_err)retval == IAVF_AQ_RC_OK)
769+
if ((enum libie_aq_err)retval == LIBIE_AQ_RC_OK)
770770
status = 0;
771-
else if ((enum iavf_admin_queue_err)retval == IAVF_AQ_RC_EBUSY)
771+
else if ((enum libie_aq_err)retval == LIBIE_AQ_RC_EBUSY)
772772
status = IAVF_ERR_NOT_READY;
773773
else
774774
status = IAVF_ERR_ADMIN_QUEUE_ERROR;
775-
hw->aq.asq_last_status = (enum iavf_admin_queue_err)retval;
775+
hw->aq.asq_last_status = (enum libie_aq_err)retval;
776776
}
777777

778778
iavf_debug(hw, IAVF_DEBUG_AQ_MESSAGE,
@@ -809,12 +809,12 @@ enum iavf_status iavf_asq_send_command(struct iavf_hw *hw,
809809
*
810810
* Fill the desc with default values
811811
**/
812-
void iavf_fill_default_direct_cmd_desc(struct iavf_aq_desc *desc, u16 opcode)
812+
void iavf_fill_default_direct_cmd_desc(struct libie_aq_desc *desc, u16 opcode)
813813
{
814814
/* zero out the desc */
815-
memset((void *)desc, 0, sizeof(struct iavf_aq_desc));
815+
memset((void *)desc, 0, sizeof(struct libie_aq_desc));
816816
desc->opcode = cpu_to_le16(opcode);
817-
desc->flags = cpu_to_le16(IAVF_AQ_FLAG_SI);
817+
desc->flags = cpu_to_le16(LIBIE_AQ_FLAG_SI);
818818
}
819819

820820
/**
@@ -832,7 +832,7 @@ enum iavf_status iavf_clean_arq_element(struct iavf_hw *hw,
832832
u16 *pending)
833833
{
834834
u16 ntc = hw->aq.arq.next_to_clean;
835-
struct iavf_aq_desc *desc;
835+
struct libie_aq_desc *desc;
836836
enum iavf_status ret_code = 0;
837837
struct iavf_dma_mem *bi;
838838
u16 desc_idx;
@@ -866,9 +866,9 @@ enum iavf_status iavf_clean_arq_element(struct iavf_hw *hw,
866866
desc_idx = ntc;
867867

868868
hw->aq.arq_last_status =
869-
(enum iavf_admin_queue_err)le16_to_cpu(desc->retval);
869+
(enum libie_aq_err)le16_to_cpu(desc->retval);
870870
flags = le16_to_cpu(desc->flags);
871-
if (flags & IAVF_AQ_FLAG_ERR) {
871+
if (flags & LIBIE_AQ_FLAG_ERR) {
872872
ret_code = IAVF_ERR_ADMIN_QUEUE_ERROR;
873873
iavf_debug(hw,
874874
IAVF_DEBUG_AQ_MESSAGE,
@@ -892,14 +892,14 @@ enum iavf_status iavf_clean_arq_element(struct iavf_hw *hw,
892892
* size
893893
*/
894894
bi = &hw->aq.arq.r.arq_bi[ntc];
895-
memset((void *)desc, 0, sizeof(struct iavf_aq_desc));
895+
memset((void *)desc, 0, sizeof(struct libie_aq_desc));
896896

897-
desc->flags = cpu_to_le16(IAVF_AQ_FLAG_BUF);
897+
desc->flags = cpu_to_le16(LIBIE_AQ_FLAG_BUF);
898898
if (hw->aq.arq_buf_size > IAVF_AQ_LARGE_BUF)
899-
desc->flags |= cpu_to_le16(IAVF_AQ_FLAG_LB);
899+
desc->flags |= cpu_to_le16(LIBIE_AQ_FLAG_LB);
900900
desc->datalen = cpu_to_le16((u16)bi->size);
901-
desc->params.external.addr_high = cpu_to_le32(upper_32_bits(bi->pa));
902-
desc->params.external.addr_low = cpu_to_le32(lower_32_bits(bi->pa));
901+
desc->params.generic.addr_high = cpu_to_le32(upper_32_bits(bi->pa));
902+
desc->params.generic.addr_low = cpu_to_le32(lower_32_bits(bi->pa));
903903

904904
/* set tail = the last cleaned desc index. */
905905
wr32(hw, IAVF_VF_ARQT1, ntc);

drivers/net/ethernet/intel/iavf/iavf_adminq.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "iavf_adminq_cmd.h"
1010

1111
#define IAVF_ADMINQ_DESC(R, i) \
12-
(&(((struct iavf_aq_desc *)((R).desc_buf.va))[i]))
12+
(&(((struct libie_aq_desc *)((R).desc_buf.va))[i]))
1313

1414
#define IAVF_ADMINQ_DESC_ALIGNMENT 4096
1515

@@ -39,15 +39,15 @@ struct iavf_asq_cmd_details {
3939
u16 flags_dis;
4040
bool async;
4141
bool postpone;
42-
struct iavf_aq_desc *wb_desc;
42+
struct libie_aq_desc *wb_desc;
4343
};
4444

4545
#define IAVF_ADMINQ_DETAILS(R, i) \
4646
(&(((struct iavf_asq_cmd_details *)((R).cmd_buf.va))[i]))
4747

4848
/* ARQ event information */
4949
struct iavf_arq_event_info {
50-
struct iavf_aq_desc desc;
50+
struct libie_aq_desc desc;
5151
u16 msg_len;
5252
u16 buf_len;
5353
u8 *msg_buf;
@@ -72,8 +72,8 @@ struct iavf_adminq_info {
7272
struct mutex arq_mutex; /* Receive queue lock */
7373

7474
/* last status values on send and receive queues */
75-
enum iavf_admin_queue_err asq_last_status;
76-
enum iavf_admin_queue_err arq_last_status;
75+
enum libie_aq_err asq_last_status;
76+
enum libie_aq_err arq_last_status;
7777
};
7878

7979
/**
@@ -123,6 +123,6 @@ static inline int iavf_aq_rc_to_posix(int aq_ret, int aq_rc)
123123
#define IAVF_AQ_LARGE_BUF 512
124124
#define IAVF_ASQ_CMD_TIMEOUT 250000 /* usecs */
125125

126-
void iavf_fill_default_direct_cmd_desc(struct iavf_aq_desc *desc, u16 opcode);
126+
void iavf_fill_default_direct_cmd_desc(struct libie_aq_desc *desc, u16 opcode);
127127

128128
#endif /* _IAVF_ADMINQ_H_ */

drivers/net/ethernet/intel/iavf/iavf_adminq_cmd.h

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef _IAVF_ADMINQ_CMD_H_
55
#define _IAVF_ADMINQ_CMD_H_
66

7+
#include <linux/net/intel/libie/adminq.h>
8+
79
/* This header file defines the iavf Admin Queue commands and is shared between
810
* iavf Firmware and Software.
911
*
@@ -21,87 +23,6 @@
2123
/* API version 1.7 implements additional link and PHY-specific APIs */
2224
#define IAVF_MINOR_VER_GET_LINK_INFO_XL710 0x0007
2325

24-
struct iavf_aq_desc {
25-
__le16 flags;
26-
__le16 opcode;
27-
__le16 datalen;
28-
__le16 retval;
29-
__le32 cookie_high;
30-
__le32 cookie_low;
31-
union {
32-
struct {
33-
__le32 param0;
34-
__le32 param1;
35-
__le32 param2;
36-
__le32 param3;
37-
} internal;
38-
struct {
39-
__le32 param0;
40-
__le32 param1;
41-
__le32 addr_high;
42-
__le32 addr_low;
43-
} external;
44-
u8 raw[16];
45-
} params;
46-
};
47-
48-
/* Flags sub-structure
49-
* |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |10 |11 |12 |13 |14 |15 |
50-
* |DD |CMP|ERR|VFE| * * RESERVED * * |LB |RD |VFC|BUF|SI |EI |FE |
51-
*/
52-
53-
/* command flags and offsets*/
54-
#define IAVF_AQ_FLAG_DD_SHIFT 0
55-
#define IAVF_AQ_FLAG_CMP_SHIFT 1
56-
#define IAVF_AQ_FLAG_ERR_SHIFT 2
57-
#define IAVF_AQ_FLAG_VFE_SHIFT 3
58-
#define IAVF_AQ_FLAG_LB_SHIFT 9
59-
#define IAVF_AQ_FLAG_RD_SHIFT 10
60-
#define IAVF_AQ_FLAG_VFC_SHIFT 11
61-
#define IAVF_AQ_FLAG_BUF_SHIFT 12
62-
#define IAVF_AQ_FLAG_SI_SHIFT 13
63-
#define IAVF_AQ_FLAG_EI_SHIFT 14
64-
#define IAVF_AQ_FLAG_FE_SHIFT 15
65-
66-
#define IAVF_AQ_FLAG_DD BIT(IAVF_AQ_FLAG_DD_SHIFT) /* 0x1 */
67-
#define IAVF_AQ_FLAG_CMP BIT(IAVF_AQ_FLAG_CMP_SHIFT) /* 0x2 */
68-
#define IAVF_AQ_FLAG_ERR BIT(IAVF_AQ_FLAG_ERR_SHIFT) /* 0x4 */
69-
#define IAVF_AQ_FLAG_VFE BIT(IAVF_AQ_FLAG_VFE_SHIFT) /* 0x8 */
70-
#define IAVF_AQ_FLAG_LB BIT(IAVF_AQ_FLAG_LB_SHIFT) /* 0x200 */
71-
#define IAVF_AQ_FLAG_RD BIT(IAVF_AQ_FLAG_RD_SHIFT) /* 0x400 */
72-
#define IAVF_AQ_FLAG_VFC BIT(IAVF_AQ_FLAG_VFC_SHIFT) /* 0x800 */
73-
#define IAVF_AQ_FLAG_BUF BIT(IAVF_AQ_FLAG_BUF_SHIFT) /* 0x1000 */
74-
#define IAVF_AQ_FLAG_SI BIT(IAVF_AQ_FLAG_SI_SHIFT) /* 0x2000 */
75-
#define IAVF_AQ_FLAG_EI BIT(IAVF_AQ_FLAG_EI_SHIFT) /* 0x4000 */
76-
#define IAVF_AQ_FLAG_FE BIT(IAVF_AQ_FLAG_FE_SHIFT) /* 0x8000 */
77-
78-
/* error codes */
79-
enum iavf_admin_queue_err {
80-
IAVF_AQ_RC_OK = 0, /* success */
81-
IAVF_AQ_RC_EPERM = 1, /* Operation not permitted */
82-
IAVF_AQ_RC_ENOENT = 2, /* No such element */
83-
IAVF_AQ_RC_ESRCH = 3, /* Bad opcode */
84-
IAVF_AQ_RC_EINTR = 4, /* operation interrupted */
85-
IAVF_AQ_RC_EIO = 5, /* I/O error */
86-
IAVF_AQ_RC_ENXIO = 6, /* No such resource */
87-
IAVF_AQ_RC_E2BIG = 7, /* Arg too long */
88-
IAVF_AQ_RC_EAGAIN = 8, /* Try again */
89-
IAVF_AQ_RC_ENOMEM = 9, /* Out of memory */
90-
IAVF_AQ_RC_EACCES = 10, /* Permission denied */
91-
IAVF_AQ_RC_EFAULT = 11, /* Bad address */
92-
IAVF_AQ_RC_EBUSY = 12, /* Device or resource busy */
93-
IAVF_AQ_RC_EEXIST = 13, /* object already exists */
94-
IAVF_AQ_RC_EINVAL = 14, /* Invalid argument */
95-
IAVF_AQ_RC_ENOTTY = 15, /* Not a typewriter */
96-
IAVF_AQ_RC_ENOSPC = 16, /* No space left or alloc failure */
97-
IAVF_AQ_RC_ENOSYS = 17, /* Function not implemented */
98-
IAVF_AQ_RC_ERANGE = 18, /* Parameter out of range */
99-
IAVF_AQ_RC_EFLUSHED = 19, /* Cmd flushed due to prev cmd error */
100-
IAVF_AQ_RC_BAD_ADDR = 20, /* Descriptor contains a bad pointer */
101-
IAVF_AQ_RC_EMODE = 21, /* Op not allowed in current dev mode */
102-
IAVF_AQ_RC_EFBIG = 22, /* File too large */
103-
};
104-
10526
/* Admin Queue command opcodes */
10627
enum iavf_admin_queue_opc {
10728
/* aq commands */

0 commit comments

Comments
 (0)