Skip to content

Commit 1d5c960

Browse files
wujingjiJeff Kirsher
authored andcommitted
i40e: new AQ commands
Add admin queue functions for Pipeline Personalization Profile AQ commands: - Write Recipe Command buffer (Opcode: 0x0270) - Get Applied Profiles list (Opcode: 0x0271) Change-ID: I558b4145364140f624013af48d4bbf79d21ebb0d Signed-off-by: Jingjing Wu <jingjing.wu@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent ed0980c commit 1d5c960

File tree

8 files changed

+686
-0
lines changed

8 files changed

+686
-0
lines changed

drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ enum i40e_admin_queue_opc {
190190
i40e_aqc_opc_add_mirror_rule = 0x0260,
191191
i40e_aqc_opc_delete_mirror_rule = 0x0261,
192192

193+
/* Pipeline Personalization Profile */
194+
i40e_aqc_opc_write_personalization_profile = 0x0270,
195+
i40e_aqc_opc_get_personalization_profile_list = 0x0271,
196+
193197
/* DCB commands */
194198
i40e_aqc_opc_dcb_ignore_pfc = 0x0301,
195199
i40e_aqc_opc_dcb_updated = 0x0302,
@@ -1431,6 +1435,36 @@ struct i40e_aqc_add_delete_mirror_rule_completion {
14311435

14321436
I40E_CHECK_CMD_LENGTH(i40e_aqc_add_delete_mirror_rule_completion);
14331437

1438+
/* Pipeline Personalization Profile */
1439+
struct i40e_aqc_write_personalization_profile {
1440+
u8 flags;
1441+
u8 reserved[3];
1442+
__le32 profile_track_id;
1443+
__le32 addr_high;
1444+
__le32 addr_low;
1445+
};
1446+
1447+
I40E_CHECK_CMD_LENGTH(i40e_aqc_write_personalization_profile);
1448+
1449+
struct i40e_aqc_write_ppp_resp {
1450+
__le32 error_offset;
1451+
__le32 error_info;
1452+
__le32 addr_high;
1453+
__le32 addr_low;
1454+
};
1455+
1456+
struct i40e_aqc_get_applied_profiles {
1457+
u8 flags;
1458+
#define I40E_AQC_GET_PPP_GET_CONF 0x1
1459+
#define I40E_AQC_GET_PPP_GET_RDPU_CONF 0x2
1460+
u8 rsv[3];
1461+
__le32 reserved;
1462+
__le32 addr_high;
1463+
__le32 addr_low;
1464+
};
1465+
1466+
I40E_CHECK_CMD_LENGTH(i40e_aqc_get_applied_profiles);
1467+
14341468
/* DCB 0x03xx*/
14351469

14361470
/* PFC Ignore (direct 0x0301)

drivers/net/ethernet/intel/i40e/i40e_common.c

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5042,3 +5042,215 @@ void i40e_write_rx_ctl(struct i40e_hw *hw, u32 reg_addr, u32 reg_val)
50425042
if (status || use_register)
50435043
wr32(hw, reg_addr, reg_val);
50445044
}
5045+
5046+
/**
5047+
* i40e_aq_write_ppp - Write pipeline personalization profile (ppp)
5048+
* @hw: pointer to the hw struct
5049+
* @buff: command buffer (size in bytes = buff_size)
5050+
* @buff_size: buffer size in bytes
5051+
* @track_id: package tracking id
5052+
* @error_offset: returns error offset
5053+
* @error_info: returns error information
5054+
* @cmd_details: pointer to command details structure or NULL
5055+
**/
5056+
enum
5057+
i40e_status_code i40e_aq_write_ppp(struct i40e_hw *hw, void *buff,
5058+
u16 buff_size, u32 track_id,
5059+
u32 *error_offset, u32 *error_info,
5060+
struct i40e_asq_cmd_details *cmd_details)
5061+
{
5062+
struct i40e_aq_desc desc;
5063+
struct i40e_aqc_write_personalization_profile *cmd =
5064+
(struct i40e_aqc_write_personalization_profile *)
5065+
&desc.params.raw;
5066+
struct i40e_aqc_write_ppp_resp *resp;
5067+
i40e_status status;
5068+
5069+
i40e_fill_default_direct_cmd_desc(&desc,
5070+
i40e_aqc_opc_write_personalization_profile);
5071+
5072+
desc.flags |= cpu_to_le16(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD);
5073+
if (buff_size > I40E_AQ_LARGE_BUF)
5074+
desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
5075+
5076+
desc.datalen = cpu_to_le16(buff_size);
5077+
5078+
cmd->profile_track_id = cpu_to_le32(track_id);
5079+
5080+
status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
5081+
if (!status) {
5082+
resp = (struct i40e_aqc_write_ppp_resp *)&desc.params.raw;
5083+
if (error_offset)
5084+
*error_offset = le32_to_cpu(resp->error_offset);
5085+
if (error_info)
5086+
*error_info = le32_to_cpu(resp->error_info);
5087+
}
5088+
5089+
return status;
5090+
}
5091+
5092+
/**
5093+
* i40e_aq_get_ppp_list - Read pipeline personalization profile (ppp)
5094+
* @hw: pointer to the hw struct
5095+
* @buff: command buffer (size in bytes = buff_size)
5096+
* @buff_size: buffer size in bytes
5097+
* @cmd_details: pointer to command details structure or NULL
5098+
**/
5099+
enum
5100+
i40e_status_code i40e_aq_get_ppp_list(struct i40e_hw *hw, void *buff,
5101+
u16 buff_size, u8 flags,
5102+
struct i40e_asq_cmd_details *cmd_details)
5103+
{
5104+
struct i40e_aq_desc desc;
5105+
struct i40e_aqc_get_applied_profiles *cmd =
5106+
(struct i40e_aqc_get_applied_profiles *)&desc.params.raw;
5107+
i40e_status status;
5108+
5109+
i40e_fill_default_direct_cmd_desc(&desc,
5110+
i40e_aqc_opc_get_personalization_profile_list);
5111+
5112+
desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_BUF);
5113+
if (buff_size > I40E_AQ_LARGE_BUF)
5114+
desc.flags |= cpu_to_le16((u16)I40E_AQ_FLAG_LB);
5115+
desc.datalen = cpu_to_le16(buff_size);
5116+
5117+
cmd->flags = flags;
5118+
5119+
status = i40e_asq_send_command(hw, &desc, buff, buff_size, cmd_details);
5120+
5121+
return status;
5122+
}
5123+
5124+
/**
5125+
* i40e_find_segment_in_package
5126+
* @segment_type: the segment type to search for (i.e., SEGMENT_TYPE_I40E)
5127+
* @pkg_hdr: pointer to the package header to be searched
5128+
*
5129+
* This function searches a package file for a particular segment type. On
5130+
* success it returns a pointer to the segment header, otherwise it will
5131+
* return NULL.
5132+
**/
5133+
struct i40e_generic_seg_header *
5134+
i40e_find_segment_in_package(u32 segment_type,
5135+
struct i40e_package_header *pkg_hdr)
5136+
{
5137+
struct i40e_generic_seg_header *segment;
5138+
u32 i;
5139+
5140+
/* Search all package segments for the requested segment type */
5141+
for (i = 0; i < pkg_hdr->segment_count; i++) {
5142+
segment =
5143+
(struct i40e_generic_seg_header *)((u8 *)pkg_hdr +
5144+
pkg_hdr->segment_offset[i]);
5145+
5146+
if (segment->type == segment_type)
5147+
return segment;
5148+
}
5149+
5150+
return NULL;
5151+
}
5152+
5153+
/**
5154+
* i40e_write_profile
5155+
* @hw: pointer to the hardware structure
5156+
* @profile: pointer to the profile segment of the package to be downloaded
5157+
* @track_id: package tracking id
5158+
*
5159+
* Handles the download of a complete package.
5160+
*/
5161+
enum i40e_status_code
5162+
i40e_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *profile,
5163+
u32 track_id)
5164+
{
5165+
i40e_status status = 0;
5166+
struct i40e_section_table *sec_tbl;
5167+
struct i40e_profile_section_header *sec = NULL;
5168+
u32 dev_cnt;
5169+
u32 vendor_dev_id;
5170+
u32 *nvm;
5171+
u32 section_size = 0;
5172+
u32 offset = 0, info = 0;
5173+
u32 i;
5174+
5175+
if (!track_id) {
5176+
i40e_debug(hw, I40E_DEBUG_PACKAGE, "Track_id can't be 0.");
5177+
return I40E_NOT_SUPPORTED;
5178+
}
5179+
5180+
dev_cnt = profile->device_table_count;
5181+
5182+
for (i = 0; i < dev_cnt; i++) {
5183+
vendor_dev_id = profile->device_table[i].vendor_dev_id;
5184+
if ((vendor_dev_id >> 16) == PCI_VENDOR_ID_INTEL)
5185+
if (hw->device_id == (vendor_dev_id & 0xFFFF))
5186+
break;
5187+
}
5188+
if (i == dev_cnt) {
5189+
i40e_debug(hw, I40E_DEBUG_PACKAGE, "Device doesn't support PPP");
5190+
return I40E_ERR_DEVICE_NOT_SUPPORTED;
5191+
}
5192+
5193+
nvm = (u32 *)&profile->device_table[dev_cnt];
5194+
sec_tbl = (struct i40e_section_table *)&nvm[nvm[0] + 1];
5195+
5196+
for (i = 0; i < sec_tbl->section_count; i++) {
5197+
sec = (struct i40e_profile_section_header *)((u8 *)profile +
5198+
sec_tbl->section_offset[i]);
5199+
5200+
/* Skip 'AQ', 'note' and 'name' sections */
5201+
if (sec->section.type != SECTION_TYPE_MMIO)
5202+
continue;
5203+
5204+
section_size = sec->section.size +
5205+
sizeof(struct i40e_profile_section_header);
5206+
5207+
/* Write profile */
5208+
status = i40e_aq_write_ppp(hw, (void *)sec, (u16)section_size,
5209+
track_id, &offset, &info, NULL);
5210+
if (status) {
5211+
i40e_debug(hw, I40E_DEBUG_PACKAGE,
5212+
"Failed to write profile: offset %d, info %d",
5213+
offset, info);
5214+
break;
5215+
}
5216+
}
5217+
return status;
5218+
}
5219+
5220+
/**
5221+
* i40e_add_pinfo_to_list
5222+
* @hw: pointer to the hardware structure
5223+
* @profile: pointer to the profile segment of the package
5224+
* @profile_info_sec: buffer for information section
5225+
* @track_id: package tracking id
5226+
*
5227+
* Register a profile to the list of loaded profiles.
5228+
*/
5229+
enum i40e_status_code
5230+
i40e_add_pinfo_to_list(struct i40e_hw *hw,
5231+
struct i40e_profile_segment *profile,
5232+
u8 *profile_info_sec, u32 track_id)
5233+
{
5234+
i40e_status status = 0;
5235+
struct i40e_profile_section_header *sec = NULL;
5236+
struct i40e_profile_info *pinfo;
5237+
u32 offset = 0, info = 0;
5238+
5239+
sec = (struct i40e_profile_section_header *)profile_info_sec;
5240+
sec->tbl_size = 1;
5241+
sec->data_end = sizeof(struct i40e_profile_section_header) +
5242+
sizeof(struct i40e_profile_info);
5243+
sec->section.type = SECTION_TYPE_INFO;
5244+
sec->section.offset = sizeof(struct i40e_profile_section_header);
5245+
sec->section.size = sizeof(struct i40e_profile_info);
5246+
pinfo = (struct i40e_profile_info *)(profile_info_sec +
5247+
sec->section.offset);
5248+
pinfo->track_id = track_id;
5249+
pinfo->version = profile->version;
5250+
pinfo->op = I40E_PPP_ADD_TRACKID;
5251+
memcpy(pinfo->name, profile->name, I40E_PPP_NAME_SIZE);
5252+
5253+
status = i40e_aq_write_ppp(hw, (void *)sec, sec->data_end,
5254+
track_id, &offset, &info, NULL);
5255+
return status;
5256+
}

drivers/net/ethernet/intel/i40e/i40e_prototype.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,4 +377,21 @@ i40e_status i40e_write_phy_register(struct i40e_hw *hw, u8 page, u16 reg,
377377
u8 i40e_get_phy_address(struct i40e_hw *hw, u8 dev_num);
378378
i40e_status i40e_blink_phy_link_led(struct i40e_hw *hw,
379379
u32 time, u32 interval);
380+
i40e_status i40e_aq_write_ppp(struct i40e_hw *hw, void *buff,
381+
u16 buff_size, u32 track_id,
382+
u32 *error_offset, u32 *error_info,
383+
struct i40e_asq_cmd_details *cmd_details);
384+
i40e_status i40e_aq_get_ppp_list(struct i40e_hw *hw, void *buff,
385+
u16 buff_size, u8 flags,
386+
struct i40e_asq_cmd_details *cmd_details);
387+
struct i40e_generic_seg_header *
388+
i40e_find_segment_in_package(u32 segment_type,
389+
struct i40e_package_header *pkg_header);
390+
enum i40e_status_code
391+
i40e_write_profile(struct i40e_hw *hw, struct i40e_profile_segment *i40e_seg,
392+
u32 track_id);
393+
enum i40e_status_code
394+
i40e_add_pinfo_to_list(struct i40e_hw *hw,
395+
struct i40e_profile_segment *profile,
396+
u8 *profile_info_sec, u32 track_id);
380397
#endif /* _I40E_PROTOTYPE_H_ */

drivers/net/ethernet/intel/i40e/i40e_type.h

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ enum i40e_debug_mask {
7878
I40E_DEBUG_DCB = 0x00000400,
7979
I40E_DEBUG_DIAG = 0x00000800,
8080
I40E_DEBUG_FD = 0x00001000,
81+
I40E_DEBUG_PACKAGE = 0x00002000,
8182
I40E_DEBUG_IWARP = 0x00F00000,
8283
I40E_DEBUG_AQ_MESSAGE = 0x01000000,
8384
I40E_DEBUG_AQ_DESCRIPTOR = 0x02000000,
@@ -1462,4 +1463,83 @@ struct i40e_lldp_variables {
14621463
#define I40E_FLEX_56_MASK (0x1ULL << I40E_FLEX_56_SHIFT)
14631464
#define I40E_FLEX_57_SHIFT 6
14641465
#define I40E_FLEX_57_MASK (0x1ULL << I40E_FLEX_57_SHIFT)
1466+
1467+
/* Version format for PPP */
1468+
struct i40e_ppp_version {
1469+
u8 major;
1470+
u8 minor;
1471+
u8 update;
1472+
u8 draft;
1473+
};
1474+
1475+
#define I40E_PPP_NAME_SIZE 32
1476+
1477+
/* Package header */
1478+
struct i40e_package_header {
1479+
struct i40e_ppp_version version;
1480+
u32 segment_count;
1481+
u32 segment_offset[1];
1482+
};
1483+
1484+
/* Generic segment header */
1485+
struct i40e_generic_seg_header {
1486+
#define SEGMENT_TYPE_METADATA 0x00000001
1487+
#define SEGMENT_TYPE_NOTES 0x00000002
1488+
#define SEGMENT_TYPE_I40E 0x00000011
1489+
#define SEGMENT_TYPE_X722 0x00000012
1490+
u32 type;
1491+
struct i40e_ppp_version version;
1492+
u32 size;
1493+
char name[I40E_PPP_NAME_SIZE];
1494+
};
1495+
1496+
struct i40e_metadata_segment {
1497+
struct i40e_generic_seg_header header;
1498+
struct i40e_ppp_version version;
1499+
u32 track_id;
1500+
char name[I40E_PPP_NAME_SIZE];
1501+
};
1502+
1503+
struct i40e_device_id_entry {
1504+
u32 vendor_dev_id;
1505+
u32 sub_vendor_dev_id;
1506+
};
1507+
1508+
struct i40e_profile_segment {
1509+
struct i40e_generic_seg_header header;
1510+
struct i40e_ppp_version version;
1511+
char name[I40E_PPP_NAME_SIZE];
1512+
u32 device_table_count;
1513+
struct i40e_device_id_entry device_table[1];
1514+
};
1515+
1516+
struct i40e_section_table {
1517+
u32 section_count;
1518+
u32 section_offset[1];
1519+
};
1520+
1521+
struct i40e_profile_section_header {
1522+
u16 tbl_size;
1523+
u16 data_end;
1524+
struct {
1525+
#define SECTION_TYPE_INFO 0x00000010
1526+
#define SECTION_TYPE_MMIO 0x00000800
1527+
#define SECTION_TYPE_AQ 0x00000801
1528+
#define SECTION_TYPE_NOTE 0x80000000
1529+
#define SECTION_TYPE_NAME 0x80000001
1530+
u32 type;
1531+
u32 offset;
1532+
u32 size;
1533+
} section;
1534+
};
1535+
1536+
struct i40e_profile_info {
1537+
u32 track_id;
1538+
struct i40e_ppp_version version;
1539+
u8 op;
1540+
#define I40E_PPP_ADD_TRACKID 0x01
1541+
#define I40E_PPP_REMOVE_TRACKID 0x02
1542+
u8 reserved[7];
1543+
u8 name[I40E_PPP_NAME_SIZE];
1544+
};
14651545
#endif /* _I40E_TYPE_H_ */

0 commit comments

Comments
 (0)