Skip to content

Commit 138635c

Browse files
Gavin Shandavem330
authored andcommitted
net/ncsi: NCSI response packet handler
The NCSI response packets are sent to MC (Management Controller) from the remote end. They are responses of NCSI command packets for multiple purposes: completion status of NCSI command packets, return NCSI channel's capability or configuration etc. This defines struct to represent NCSI response packets and introduces function ncsi_rcv_rsp() which will be used to receive NCSI response packets and parse them. Signed-off-by: Gavin Shan <[email protected]> Acked-by: Joel Stanley <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6389eaa commit 138635c

File tree

4 files changed

+1227
-1
lines changed

4 files changed

+1227
-1
lines changed

net/ncsi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#
22
# Makefile for NCSI API
33
#
4-
obj-$(CONFIG_NET_NCSI) += ncsi-cmd.o ncsi-manage.o
4+
obj-$(CONFIG_NET_NCSI) += ncsi-cmd.o ncsi-rsp.o ncsi-manage.o

net/ncsi/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,7 @@ struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
271271
/* Packet handlers */
272272
u32 ncsi_calculate_checksum(unsigned char *data, int len);
273273
int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);
274+
int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
275+
struct packet_type *pt, struct net_device *orig_dev);
274276

275277
#endif /* __NCSI_INTERNAL_H__ */

net/ncsi/ncsi-pkt.h

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,25 @@ struct ncsi_cmd_pkt_hdr {
2525
struct ncsi_pkt_hdr common; /* Common NCSI packet header */
2626
};
2727

28+
struct ncsi_rsp_pkt_hdr {
29+
struct ncsi_pkt_hdr common; /* Common NCSI packet header */
30+
__be16 code; /* Response code */
31+
__be16 reason; /* Response reason */
32+
};
33+
2834
/* NCSI common command packet */
2935
struct ncsi_cmd_pkt {
3036
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
3137
__be32 checksum; /* Checksum */
3238
unsigned char pad[26];
3339
};
3440

41+
struct ncsi_rsp_pkt {
42+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
43+
__be32 checksum; /* Checksum */
44+
unsigned char pad[22];
45+
};
46+
3547
/* Select Package */
3648
struct ncsi_cmd_sp_pkt {
3749
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
@@ -133,6 +145,157 @@ struct ncsi_cmd_snfc_pkt {
133145
unsigned char pad[22];
134146
};
135147

148+
/* Get Link Status */
149+
struct ncsi_rsp_gls_pkt {
150+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
151+
__be32 status; /* Link status */
152+
__be32 other; /* Other indications */
153+
__be32 oem_status; /* OEM link status */
154+
__be32 checksum;
155+
unsigned char pad[10];
156+
};
157+
158+
/* Get Version ID */
159+
struct ncsi_rsp_gvi_pkt {
160+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
161+
__be32 ncsi_version; /* NCSI version */
162+
unsigned char reserved[3]; /* Reserved */
163+
unsigned char alpha2; /* NCSI version */
164+
unsigned char fw_name[12]; /* f/w name string */
165+
__be32 fw_version; /* f/w version */
166+
__be16 pci_ids[4]; /* PCI IDs */
167+
__be32 mf_id; /* Manufacture ID */
168+
__be32 checksum;
169+
};
170+
171+
/* Get Capabilities */
172+
struct ncsi_rsp_gc_pkt {
173+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
174+
__be32 cap; /* Capabilities */
175+
__be32 bc_cap; /* Broadcast cap */
176+
__be32 mc_cap; /* Multicast cap */
177+
__be32 buf_cap; /* Buffering cap */
178+
__be32 aen_cap; /* AEN cap */
179+
unsigned char vlan_cnt; /* VLAN filter count */
180+
unsigned char mixed_cnt; /* Mix filter count */
181+
unsigned char mc_cnt; /* MC filter count */
182+
unsigned char uc_cnt; /* UC filter count */
183+
unsigned char reserved[2]; /* Reserved */
184+
unsigned char vlan_mode; /* VLAN mode */
185+
unsigned char channel_cnt; /* Channel count */
186+
__be32 checksum; /* Checksum */
187+
};
188+
189+
/* Get Parameters */
190+
struct ncsi_rsp_gp_pkt {
191+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
192+
unsigned char mac_cnt; /* Number of MAC addr */
193+
unsigned char reserved[2]; /* Reserved */
194+
unsigned char mac_enable; /* MAC addr enable flags */
195+
unsigned char vlan_cnt; /* VLAN tag count */
196+
unsigned char reserved1; /* Reserved */
197+
__be16 vlan_enable; /* VLAN tag enable flags */
198+
__be32 link_mode; /* Link setting */
199+
__be32 bc_mode; /* BC filter mode */
200+
__be32 valid_modes; /* Valid mode parameters */
201+
unsigned char vlan_mode; /* VLAN mode */
202+
unsigned char fc_mode; /* Flow control mode */
203+
unsigned char reserved2[2]; /* Reserved */
204+
__be32 aen_mode; /* AEN mode */
205+
unsigned char mac[6]; /* Supported MAC addr */
206+
__be16 vlan; /* Supported VLAN tags */
207+
__be32 checksum; /* Checksum */
208+
};
209+
210+
/* Get Controller Packet Statistics */
211+
struct ncsi_rsp_gcps_pkt {
212+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
213+
__be32 cnt_hi; /* Counter cleared */
214+
__be32 cnt_lo; /* Counter cleared */
215+
__be32 rx_bytes; /* Rx bytes */
216+
__be32 tx_bytes; /* Tx bytes */
217+
__be32 rx_uc_pkts; /* Rx UC packets */
218+
__be32 rx_mc_pkts; /* Rx MC packets */
219+
__be32 rx_bc_pkts; /* Rx BC packets */
220+
__be32 tx_uc_pkts; /* Tx UC packets */
221+
__be32 tx_mc_pkts; /* Tx MC packets */
222+
__be32 tx_bc_pkts; /* Tx BC packets */
223+
__be32 fcs_err; /* FCS errors */
224+
__be32 align_err; /* Alignment errors */
225+
__be32 false_carrier; /* False carrier detection */
226+
__be32 runt_pkts; /* Rx runt packets */
227+
__be32 jabber_pkts; /* Rx jabber packets */
228+
__be32 rx_pause_xon; /* Rx pause XON frames */
229+
__be32 rx_pause_xoff; /* Rx XOFF frames */
230+
__be32 tx_pause_xon; /* Tx XON frames */
231+
__be32 tx_pause_xoff; /* Tx XOFF frames */
232+
__be32 tx_s_collision; /* Single collision frames */
233+
__be32 tx_m_collision; /* Multiple collision frames */
234+
__be32 l_collision; /* Late collision frames */
235+
__be32 e_collision; /* Excessive collision frames */
236+
__be32 rx_ctl_frames; /* Rx control frames */
237+
__be32 rx_64_frames; /* Rx 64-bytes frames */
238+
__be32 rx_127_frames; /* Rx 65-127 bytes frames */
239+
__be32 rx_255_frames; /* Rx 128-255 bytes frames */
240+
__be32 rx_511_frames; /* Rx 256-511 bytes frames */
241+
__be32 rx_1023_frames; /* Rx 512-1023 bytes frames */
242+
__be32 rx_1522_frames; /* Rx 1024-1522 bytes frames */
243+
__be32 rx_9022_frames; /* Rx 1523-9022 bytes frames */
244+
__be32 tx_64_frames; /* Tx 64-bytes frames */
245+
__be32 tx_127_frames; /* Tx 65-127 bytes frames */
246+
__be32 tx_255_frames; /* Tx 128-255 bytes frames */
247+
__be32 tx_511_frames; /* Tx 256-511 bytes frames */
248+
__be32 tx_1023_frames; /* Tx 512-1023 bytes frames */
249+
__be32 tx_1522_frames; /* Tx 1024-1522 bytes frames */
250+
__be32 tx_9022_frames; /* Tx 1523-9022 bytes frames */
251+
__be32 rx_valid_bytes; /* Rx valid bytes */
252+
__be32 rx_runt_pkts; /* Rx error runt packets */
253+
__be32 rx_jabber_pkts; /* Rx error jabber packets */
254+
__be32 checksum; /* Checksum */
255+
};
256+
257+
/* Get NCSI Statistics */
258+
struct ncsi_rsp_gns_pkt {
259+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
260+
__be32 rx_cmds; /* Rx NCSI commands */
261+
__be32 dropped_cmds; /* Dropped commands */
262+
__be32 cmd_type_errs; /* Command type errors */
263+
__be32 cmd_csum_errs; /* Command checksum errors */
264+
__be32 rx_pkts; /* Rx NCSI packets */
265+
__be32 tx_pkts; /* Tx NCSI packets */
266+
__be32 tx_aen_pkts; /* Tx AEN packets */
267+
__be32 checksum; /* Checksum */
268+
};
269+
270+
/* Get NCSI Pass-through Statistics */
271+
struct ncsi_rsp_gnpts_pkt {
272+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
273+
__be32 tx_pkts; /* Tx packets */
274+
__be32 tx_dropped; /* Tx dropped packets */
275+
__be32 tx_channel_err; /* Tx channel errors */
276+
__be32 tx_us_err; /* Tx undersize errors */
277+
__be32 rx_pkts; /* Rx packets */
278+
__be32 rx_dropped; /* Rx dropped packets */
279+
__be32 rx_channel_err; /* Rx channel errors */
280+
__be32 rx_us_err; /* Rx undersize errors */
281+
__be32 rx_os_err; /* Rx oversize errors */
282+
__be32 checksum; /* Checksum */
283+
};
284+
285+
/* Get package status */
286+
struct ncsi_rsp_gps_pkt {
287+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
288+
__be32 status; /* Hardware arbitration status */
289+
__be32 checksum;
290+
};
291+
292+
/* Get package UUID */
293+
struct ncsi_rsp_gpuuid_pkt {
294+
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
295+
unsigned char uuid[16]; /* UUID */
296+
__be32 checksum;
297+
};
298+
136299
/* NCSI packet revision */
137300
#define NCSI_PKT_REVISION 0x01
138301

@@ -168,4 +331,49 @@ struct ncsi_cmd_snfc_pkt {
168331
#define NCSI_PKT_CMD_PLDM 0x51 /* PLDM request over NCSI over RBT */
169332
#define NCSI_PKT_CMD_GPUUID 0x52 /* Get package UUID */
170333

334+
/* NCSI packet responses */
335+
#define NCSI_PKT_RSP_CIS (NCSI_PKT_CMD_CIS + 0x80)
336+
#define NCSI_PKT_RSP_SP (NCSI_PKT_CMD_SP + 0x80)
337+
#define NCSI_PKT_RSP_DP (NCSI_PKT_CMD_DP + 0x80)
338+
#define NCSI_PKT_RSP_EC (NCSI_PKT_CMD_EC + 0x80)
339+
#define NCSI_PKT_RSP_DC (NCSI_PKT_CMD_DC + 0x80)
340+
#define NCSI_PKT_RSP_RC (NCSI_PKT_CMD_RC + 0x80)
341+
#define NCSI_PKT_RSP_ECNT (NCSI_PKT_CMD_ECNT + 0x80)
342+
#define NCSI_PKT_RSP_DCNT (NCSI_PKT_CMD_DCNT + 0x80)
343+
#define NCSI_PKT_RSP_AE (NCSI_PKT_CMD_AE + 0x80)
344+
#define NCSI_PKT_RSP_SL (NCSI_PKT_CMD_SL + 0x80)
345+
#define NCSI_PKT_RSP_GLS (NCSI_PKT_CMD_GLS + 0x80)
346+
#define NCSI_PKT_RSP_SVF (NCSI_PKT_CMD_SVF + 0x80)
347+
#define NCSI_PKT_RSP_EV (NCSI_PKT_CMD_EV + 0x80)
348+
#define NCSI_PKT_RSP_DV (NCSI_PKT_CMD_DV + 0x80)
349+
#define NCSI_PKT_RSP_SMA (NCSI_PKT_CMD_SMA + 0x80)
350+
#define NCSI_PKT_RSP_EBF (NCSI_PKT_CMD_EBF + 0x80)
351+
#define NCSI_PKT_RSP_DBF (NCSI_PKT_CMD_DBF + 0x80)
352+
#define NCSI_PKT_RSP_EGMF (NCSI_PKT_CMD_EGMF + 0x80)
353+
#define NCSI_PKT_RSP_DGMF (NCSI_PKT_CMD_DGMF + 0x80)
354+
#define NCSI_PKT_RSP_SNFC (NCSI_PKT_CMD_SNFC + 0x80)
355+
#define NCSI_PKT_RSP_GVI (NCSI_PKT_CMD_GVI + 0x80)
356+
#define NCSI_PKT_RSP_GC (NCSI_PKT_CMD_GC + 0x80)
357+
#define NCSI_PKT_RSP_GP (NCSI_PKT_CMD_GP + 0x80)
358+
#define NCSI_PKT_RSP_GCPS (NCSI_PKT_CMD_GCPS + 0x80)
359+
#define NCSI_PKT_RSP_GNS (NCSI_PKT_CMD_GNS + 0x80)
360+
#define NCSI_PKT_RSP_GNPTS (NCSI_PKT_CMD_GNPTS + 0x80)
361+
#define NCSI_PKT_RSP_GPS (NCSI_PKT_CMD_GPS + 0x80)
362+
#define NCSI_PKT_RSP_OEM (NCSI_PKT_CMD_OEM + 0x80)
363+
#define NCSI_PKT_RSP_PLDM (NCSI_PKT_CMD_PLDM + 0x80)
364+
#define NCSI_PKT_RSP_GPUUID (NCSI_PKT_CMD_GPUUID + 0x80)
365+
366+
/* NCSI response code/reason */
367+
#define NCSI_PKT_RSP_C_COMPLETED 0x0000 /* Command Completed */
368+
#define NCSI_PKT_RSP_C_FAILED 0x0001 /* Command Failed */
369+
#define NCSI_PKT_RSP_C_UNAVAILABLE 0x0002 /* Command Unavailable */
370+
#define NCSI_PKT_RSP_C_UNSUPPORTED 0x0003 /* Command Unsupported */
371+
#define NCSI_PKT_RSP_R_NO_ERROR 0x0000 /* No Error */
372+
#define NCSI_PKT_RSP_R_INTERFACE 0x0001 /* Interface not ready */
373+
#define NCSI_PKT_RSP_R_PARAM 0x0002 /* Invalid Parameter */
374+
#define NCSI_PKT_RSP_R_CHANNEL 0x0003 /* Channel not Ready */
375+
#define NCSI_PKT_RSP_R_PACKAGE 0x0004 /* Package not Ready */
376+
#define NCSI_PKT_RSP_R_LENGTH 0x0005 /* Invalid payload length */
377+
#define NCSI_PKT_RSP_R_UNKNOWN 0x7fff /* Command type unsupported */
378+
171379
#endif /* __NCSI_PKT_H__ */

0 commit comments

Comments
 (0)