Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Intel Ethernet Controller XL710 Family Linux Driver |
Greg Rose | dc641b7 | 2013-12-18 13:45:51 +0000 | [diff] [blame] | 4 | * Copyright(c) 2013 - 2014 Intel Corporation. |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
Greg Rose | dc641b7 | 2013-12-18 13:45:51 +0000 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 17 | * |
| 18 | * The full GNU General Public License is included in this distribution in |
| 19 | * the file called "COPYING". |
| 20 | * |
| 21 | * Contact Information: |
| 22 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 24 | * |
| 25 | ******************************************************************************/ |
| 26 | |
| 27 | #ifndef _I40E_ADMINQ_H_ |
| 28 | #define _I40E_ADMINQ_H_ |
| 29 | |
| 30 | #include "i40e_osdep.h" |
| 31 | #include "i40e_adminq_cmd.h" |
| 32 | |
| 33 | #define I40E_ADMINQ_DESC(R, i) \ |
David Cassard | 90bb776 | 2013-11-28 06:39:35 +0000 | [diff] [blame] | 34 | (&(((struct i40e_aq_desc *)((R).desc_buf.va))[i])) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 35 | |
| 36 | #define I40E_ADMINQ_DESC_ALIGNMENT 4096 |
| 37 | |
| 38 | struct i40e_adminq_ring { |
David Cassard | 90bb776 | 2013-11-28 06:39:35 +0000 | [diff] [blame] | 39 | struct i40e_virt_mem dma_head; /* space for dma structures */ |
| 40 | struct i40e_dma_mem desc_buf; /* descriptor ring memory */ |
| 41 | struct i40e_virt_mem cmd_buf; /* command buffer memory */ |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 42 | |
| 43 | union { |
| 44 | struct i40e_dma_mem *asq_bi; |
| 45 | struct i40e_dma_mem *arq_bi; |
| 46 | } r; |
| 47 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 48 | u16 count; /* Number of descriptors */ |
| 49 | u16 rx_buf_len; /* Admin Receive Queue buffer length */ |
| 50 | |
| 51 | /* used for interrupt processing */ |
| 52 | u16 next_to_use; |
| 53 | u16 next_to_clean; |
| 54 | |
| 55 | /* used for queue tracking */ |
| 56 | u32 head; |
| 57 | u32 tail; |
Shannon Nelson | 17e6a84 | 2013-11-16 10:00:36 +0000 | [diff] [blame] | 58 | u32 len; |
Shannon Nelson | 87dc346 | 2014-06-04 20:41:17 +0000 | [diff] [blame] | 59 | u32 bah; |
| 60 | u32 bal; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | /* ASQ transaction details */ |
| 64 | struct i40e_asq_cmd_details { |
| 65 | void *callback; /* cast from type I40E_ADMINQ_CALLBACK */ |
| 66 | u64 cookie; |
| 67 | u16 flags_ena; |
| 68 | u16 flags_dis; |
| 69 | bool async; |
| 70 | bool postpone; |
| 71 | }; |
| 72 | |
| 73 | #define I40E_ADMINQ_DETAILS(R, i) \ |
David Cassard | 90bb776 | 2013-11-28 06:39:35 +0000 | [diff] [blame] | 74 | (&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i])) |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 75 | |
| 76 | /* ARQ event information */ |
| 77 | struct i40e_arq_event_info { |
| 78 | struct i40e_aq_desc desc; |
Mitch Williams | 1001dc3 | 2014-11-11 20:02:19 +0000 | [diff] [blame^] | 79 | u16 msg_len; |
| 80 | u16 buf_len; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 81 | u8 *msg_buf; |
| 82 | }; |
| 83 | |
| 84 | /* Admin Queue information */ |
| 85 | struct i40e_adminq_info { |
| 86 | struct i40e_adminq_ring arq; /* receive queue */ |
| 87 | struct i40e_adminq_ring asq; /* send queue */ |
Kamil Krawczyk | 09c4e56 | 2014-06-04 20:41:43 +0000 | [diff] [blame] | 88 | u32 asq_cmd_timeout; /* send queue cmd write back timeout*/ |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 89 | u16 num_arq_entries; /* receive queue depth */ |
| 90 | u16 num_asq_entries; /* send queue depth */ |
| 91 | u16 arq_buf_size; /* receive queue buffer size */ |
| 92 | u16 asq_buf_size; /* send queue buffer size */ |
| 93 | u16 fw_maj_ver; /* firmware major version */ |
| 94 | u16 fw_min_ver; /* firmware minor version */ |
| 95 | u16 api_maj_ver; /* api major version */ |
| 96 | u16 api_min_ver; /* api minor version */ |
Shannon Nelson | c9296ad | 2014-03-14 07:32:22 +0000 | [diff] [blame] | 97 | bool nvm_busy; |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 98 | bool nvm_release_on_done; |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 99 | |
| 100 | struct mutex asq_mutex; /* Send queue lock */ |
| 101 | struct mutex arq_mutex; /* Receive queue lock */ |
| 102 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 103 | /* last status values on send and receive queues */ |
| 104 | enum i40e_admin_queue_err asq_last_status; |
| 105 | enum i40e_admin_queue_err arq_last_status; |
| 106 | }; |
| 107 | |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 108 | /** |
| 109 | * i40e_aq_rc_to_posix - convert errors to user-land codes |
| 110 | * aq_rc: AdminQ error code to convert |
| 111 | **/ |
| 112 | static inline int i40e_aq_rc_to_posix(u16 aq_rc) |
| 113 | { |
| 114 | int aq_to_posix[] = { |
| 115 | 0, /* I40E_AQ_RC_OK */ |
| 116 | -EPERM, /* I40E_AQ_RC_EPERM */ |
| 117 | -ENOENT, /* I40E_AQ_RC_ENOENT */ |
| 118 | -ESRCH, /* I40E_AQ_RC_ESRCH */ |
| 119 | -EINTR, /* I40E_AQ_RC_EINTR */ |
| 120 | -EIO, /* I40E_AQ_RC_EIO */ |
| 121 | -ENXIO, /* I40E_AQ_RC_ENXIO */ |
| 122 | -E2BIG, /* I40E_AQ_RC_E2BIG */ |
| 123 | -EAGAIN, /* I40E_AQ_RC_EAGAIN */ |
| 124 | -ENOMEM, /* I40E_AQ_RC_ENOMEM */ |
| 125 | -EACCES, /* I40E_AQ_RC_EACCES */ |
| 126 | -EFAULT, /* I40E_AQ_RC_EFAULT */ |
| 127 | -EBUSY, /* I40E_AQ_RC_EBUSY */ |
| 128 | -EEXIST, /* I40E_AQ_RC_EEXIST */ |
| 129 | -EINVAL, /* I40E_AQ_RC_EINVAL */ |
| 130 | -ENOTTY, /* I40E_AQ_RC_ENOTTY */ |
| 131 | -ENOSPC, /* I40E_AQ_RC_ENOSPC */ |
| 132 | -ENOSYS, /* I40E_AQ_RC_ENOSYS */ |
| 133 | -ERANGE, /* I40E_AQ_RC_ERANGE */ |
| 134 | -EPIPE, /* I40E_AQ_RC_EFLUSHED */ |
| 135 | -ESPIPE, /* I40E_AQ_RC_BAD_ADDR */ |
| 136 | -EROFS, /* I40E_AQ_RC_EMODE */ |
| 137 | -EFBIG, /* I40E_AQ_RC_EFBIG */ |
| 138 | }; |
| 139 | |
| 140 | return aq_to_posix[aq_rc]; |
| 141 | } |
| 142 | |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 143 | /* general information */ |
| 144 | #define I40E_AQ_LARGE_BUF 512 |
Kamil Krawczyk | 0db4e16 | 2014-10-25 03:24:30 +0000 | [diff] [blame] | 145 | #define I40E_ASQ_CMD_TIMEOUT 100 /* msecs */ |
Jesse Brandeburg | 56a62fc | 2013-09-11 08:40:12 +0000 | [diff] [blame] | 146 | |
| 147 | void i40e_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc, |
| 148 | u16 opcode); |
| 149 | |
| 150 | #endif /* _I40E_ADMINQ_H_ */ |