diff options
author | Dhananjay Phadke <dhananjay@netxen.com> | 2008-07-21 22:44:06 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-07-22 17:52:04 -0400 |
commit | 48bfd1e0fc66b27254ec742b014e689ef218e76c (patch) | |
tree | fd380b835dc12a5500ff5972981ee9ae767639b4 /drivers/net/netxen/netxen_nic.h | |
parent | a97342f9790f14ac20bd5f8b16ed661411fa2e3e (diff) |
netxen: add netxen_nic_ctx.c
Contains rx and tx ring context management and certain
firmware commands for netxen firmware v4.0.0+.
This patch gathers all HW context management code into
netxen_nic_ctx.c.
Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/netxen/netxen_nic.h')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 272 |
1 files changed, 268 insertions, 4 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 87be0a6ef51a..936219010e46 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -84,7 +84,7 @@ | |||
84 | #define TX_RINGSIZE \ | 84 | #define TX_RINGSIZE \ |
85 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) | 85 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) |
86 | #define RCV_BUFFSIZE \ | 86 | #define RCV_BUFFSIZE \ |
87 | (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) | 87 | (sizeof(struct netxen_rx_buffer) * rds_ring->max_rx_desc_count) |
88 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) | 88 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) |
89 | 89 | ||
90 | #define NETXEN_NETDEV_STATUS 0x1 | 90 | #define NETXEN_NETDEV_STATUS 0x1 |
@@ -303,7 +303,7 @@ struct netxen_ring_ctx { | |||
303 | #define netxen_set_cmd_desc_port(cmd_desc, var) \ | 303 | #define netxen_set_cmd_desc_port(cmd_desc, var) \ |
304 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) | 304 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) |
305 | #define netxen_set_cmd_desc_ctxid(cmd_desc, var) \ | 305 | #define netxen_set_cmd_desc_ctxid(cmd_desc, var) \ |
306 | ((cmd_desc)->port_ctxid |= ((var) & 0xF0)) | 306 | ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0)) |
307 | 307 | ||
308 | #define netxen_set_cmd_desc_flags(cmd_desc, val) \ | 308 | #define netxen_set_cmd_desc_flags(cmd_desc, val) \ |
309 | (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \ | 309 | (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \ |
@@ -844,7 +844,7 @@ struct netxen_adapter_stats { | |||
844 | * Rcv Descriptor Context. One such per Rcv Descriptor. There may | 844 | * Rcv Descriptor Context. One such per Rcv Descriptor. There may |
845 | * be one Rcv Descriptor for normal packets, one for jumbo and may be others. | 845 | * be one Rcv Descriptor for normal packets, one for jumbo and may be others. |
846 | */ | 846 | */ |
847 | struct netxen_rcv_desc_ctx { | 847 | struct nx_host_rds_ring { |
848 | u32 flags; | 848 | u32 flags; |
849 | u32 producer; | 849 | u32 producer; |
850 | dma_addr_t phys_addr; | 850 | dma_addr_t phys_addr; |
@@ -864,13 +864,270 @@ struct netxen_rcv_desc_ctx { | |||
864 | * present elsewhere. | 864 | * present elsewhere. |
865 | */ | 865 | */ |
866 | struct netxen_recv_context { | 866 | struct netxen_recv_context { |
867 | struct netxen_rcv_desc_ctx rcv_desc[NUM_RCV_DESC_RINGS]; | 867 | u32 state; |
868 | u16 context_id; | ||
869 | u16 virt_port; | ||
870 | |||
871 | struct nx_host_rds_ring rds_rings[NUM_RCV_DESC_RINGS]; | ||
868 | u32 status_rx_consumer; | 872 | u32 status_rx_consumer; |
869 | u32 crb_sts_consumer; /* reg offset */ | 873 | u32 crb_sts_consumer; /* reg offset */ |
870 | dma_addr_t rcv_status_desc_phys_addr; | 874 | dma_addr_t rcv_status_desc_phys_addr; |
871 | struct status_desc *rcv_status_desc_head; | 875 | struct status_desc *rcv_status_desc_head; |
872 | }; | 876 | }; |
873 | 877 | ||
878 | /* New HW context creation */ | ||
879 | |||
880 | #define NX_OS_CRB_RETRY_COUNT 4000 | ||
881 | #define NX_CDRP_SIGNATURE_MAKE(pcifn, version) \ | ||
882 | (((pcifn) & 0xff) | (((version) & 0xff) << 8) | (0xcafe << 16)) | ||
883 | |||
884 | #define NX_CDRP_CLEAR 0x00000000 | ||
885 | #define NX_CDRP_CMD_BIT 0x80000000 | ||
886 | |||
887 | /* | ||
888 | * All responses must have the NX_CDRP_CMD_BIT cleared | ||
889 | * in the crb NX_CDRP_CRB_OFFSET. | ||
890 | */ | ||
891 | #define NX_CDRP_FORM_RSP(rsp) (rsp) | ||
892 | #define NX_CDRP_IS_RSP(rsp) (((rsp) & NX_CDRP_CMD_BIT) == 0) | ||
893 | |||
894 | #define NX_CDRP_RSP_OK 0x00000001 | ||
895 | #define NX_CDRP_RSP_FAIL 0x00000002 | ||
896 | #define NX_CDRP_RSP_TIMEOUT 0x00000003 | ||
897 | |||
898 | /* | ||
899 | * All commands must have the NX_CDRP_CMD_BIT set in | ||
900 | * the crb NX_CDRP_CRB_OFFSET. | ||
901 | */ | ||
902 | #define NX_CDRP_FORM_CMD(cmd) (NX_CDRP_CMD_BIT | (cmd)) | ||
903 | #define NX_CDRP_IS_CMD(cmd) (((cmd) & NX_CDRP_CMD_BIT) != 0) | ||
904 | |||
905 | #define NX_CDRP_CMD_SUBMIT_CAPABILITIES 0x00000001 | ||
906 | #define NX_CDRP_CMD_READ_MAX_RDS_PER_CTX 0x00000002 | ||
907 | #define NX_CDRP_CMD_READ_MAX_SDS_PER_CTX 0x00000003 | ||
908 | #define NX_CDRP_CMD_READ_MAX_RULES_PER_CTX 0x00000004 | ||
909 | #define NX_CDRP_CMD_READ_MAX_RX_CTX 0x00000005 | ||
910 | #define NX_CDRP_CMD_READ_MAX_TX_CTX 0x00000006 | ||
911 | #define NX_CDRP_CMD_CREATE_RX_CTX 0x00000007 | ||
912 | #define NX_CDRP_CMD_DESTROY_RX_CTX 0x00000008 | ||
913 | #define NX_CDRP_CMD_CREATE_TX_CTX 0x00000009 | ||
914 | #define NX_CDRP_CMD_DESTROY_TX_CTX 0x0000000a | ||
915 | #define NX_CDRP_CMD_SETUP_STATISTICS 0x0000000e | ||
916 | #define NX_CDRP_CMD_GET_STATISTICS 0x0000000f | ||
917 | #define NX_CDRP_CMD_DELETE_STATISTICS 0x00000010 | ||
918 | #define NX_CDRP_CMD_SET_MTU 0x00000012 | ||
919 | #define NX_CDRP_CMD_MAX 0x00000013 | ||
920 | |||
921 | #define NX_RCODE_SUCCESS 0 | ||
922 | #define NX_RCODE_NO_HOST_MEM 1 | ||
923 | #define NX_RCODE_NO_HOST_RESOURCE 2 | ||
924 | #define NX_RCODE_NO_CARD_CRB 3 | ||
925 | #define NX_RCODE_NO_CARD_MEM 4 | ||
926 | #define NX_RCODE_NO_CARD_RESOURCE 5 | ||
927 | #define NX_RCODE_INVALID_ARGS 6 | ||
928 | #define NX_RCODE_INVALID_ACTION 7 | ||
929 | #define NX_RCODE_INVALID_STATE 8 | ||
930 | #define NX_RCODE_NOT_SUPPORTED 9 | ||
931 | #define NX_RCODE_NOT_PERMITTED 10 | ||
932 | #define NX_RCODE_NOT_READY 11 | ||
933 | #define NX_RCODE_DOES_NOT_EXIST 12 | ||
934 | #define NX_RCODE_ALREADY_EXISTS 13 | ||
935 | #define NX_RCODE_BAD_SIGNATURE 14 | ||
936 | #define NX_RCODE_CMD_NOT_IMPL 15 | ||
937 | #define NX_RCODE_CMD_INVALID 16 | ||
938 | #define NX_RCODE_TIMEOUT 17 | ||
939 | #define NX_RCODE_CMD_FAILED 18 | ||
940 | #define NX_RCODE_MAX_EXCEEDED 19 | ||
941 | #define NX_RCODE_MAX 20 | ||
942 | |||
943 | #define NX_DESTROY_CTX_RESET 0 | ||
944 | #define NX_DESTROY_CTX_D3_RESET 1 | ||
945 | #define NX_DESTROY_CTX_MAX 2 | ||
946 | |||
947 | /* | ||
948 | * Capabilities | ||
949 | */ | ||
950 | #define NX_CAP_BIT(class, bit) (1 << bit) | ||
951 | #define NX_CAP0_LEGACY_CONTEXT NX_CAP_BIT(0, 0) | ||
952 | #define NX_CAP0_MULTI_CONTEXT NX_CAP_BIT(0, 1) | ||
953 | #define NX_CAP0_LEGACY_MN NX_CAP_BIT(0, 2) | ||
954 | #define NX_CAP0_LEGACY_MS NX_CAP_BIT(0, 3) | ||
955 | #define NX_CAP0_CUT_THROUGH NX_CAP_BIT(0, 4) | ||
956 | #define NX_CAP0_LRO NX_CAP_BIT(0, 5) | ||
957 | #define NX_CAP0_LSO NX_CAP_BIT(0, 6) | ||
958 | #define NX_CAP0_JUMBO_CONTIGUOUS NX_CAP_BIT(0, 7) | ||
959 | #define NX_CAP0_LRO_CONTIGUOUS NX_CAP_BIT(0, 8) | ||
960 | |||
961 | /* | ||
962 | * Context state | ||
963 | */ | ||
964 | #define NX_HOST_CTX_STATE_FREED 0 | ||
965 | #define NX_HOST_CTX_STATE_ALLOCATED 1 | ||
966 | #define NX_HOST_CTX_STATE_ACTIVE 2 | ||
967 | #define NX_HOST_CTX_STATE_DISABLED 3 | ||
968 | #define NX_HOST_CTX_STATE_QUIESCED 4 | ||
969 | #define NX_HOST_CTX_STATE_MAX 5 | ||
970 | |||
971 | /* | ||
972 | * Rx context | ||
973 | */ | ||
974 | |||
975 | typedef struct { | ||
976 | u64 host_phys_addr; /* Ring base addr */ | ||
977 | u32 ring_size; /* Ring entries */ | ||
978 | u16 msi_index; | ||
979 | u16 rsvd; /* Padding */ | ||
980 | } nx_hostrq_sds_ring_t; | ||
981 | |||
982 | typedef struct { | ||
983 | u64 host_phys_addr; /* Ring base addr */ | ||
984 | u64 buff_size; /* Packet buffer size */ | ||
985 | u32 ring_size; /* Ring entries */ | ||
986 | u32 ring_kind; /* Class of ring */ | ||
987 | } nx_hostrq_rds_ring_t; | ||
988 | |||
989 | typedef struct { | ||
990 | u64 host_rsp_dma_addr; /* Response dma'd here */ | ||
991 | u32 capabilities[4]; /* Flag bit vector */ | ||
992 | u32 host_int_crb_mode; /* Interrupt crb usage */ | ||
993 | u32 host_rds_crb_mode; /* RDS crb usage */ | ||
994 | /* These ring offsets are relative to data[0] below */ | ||
995 | u32 rds_ring_offset; /* Offset to RDS config */ | ||
996 | u32 sds_ring_offset; /* Offset to SDS config */ | ||
997 | u16 num_rds_rings; /* Count of RDS rings */ | ||
998 | u16 num_sds_rings; /* Count of SDS rings */ | ||
999 | u16 rsvd1; /* Padding */ | ||
1000 | u16 rsvd2; /* Padding */ | ||
1001 | u8 reserved[128]; /* reserve space for future expansion*/ | ||
1002 | /* MUST BE 64-bit aligned. | ||
1003 | The following is packed: | ||
1004 | - N hostrq_rds_rings | ||
1005 | - N hostrq_sds_rings */ | ||
1006 | char data[0]; | ||
1007 | } nx_hostrq_rx_ctx_t; | ||
1008 | |||
1009 | typedef struct { | ||
1010 | u32 host_producer_crb; /* Crb to use */ | ||
1011 | u32 rsvd1; /* Padding */ | ||
1012 | } nx_cardrsp_rds_ring_t; | ||
1013 | |||
1014 | typedef struct { | ||
1015 | u32 host_consumer_crb; /* Crb to use */ | ||
1016 | u32 interrupt_crb; /* Crb to use */ | ||
1017 | } nx_cardrsp_sds_ring_t; | ||
1018 | |||
1019 | typedef struct { | ||
1020 | /* These ring offsets are relative to data[0] below */ | ||
1021 | u32 rds_ring_offset; /* Offset to RDS config */ | ||
1022 | u32 sds_ring_offset; /* Offset to SDS config */ | ||
1023 | u32 host_ctx_state; /* Starting State */ | ||
1024 | u32 num_fn_per_port; /* How many PCI fn share the port */ | ||
1025 | u16 num_rds_rings; /* Count of RDS rings */ | ||
1026 | u16 num_sds_rings; /* Count of SDS rings */ | ||
1027 | u16 context_id; /* Handle for context */ | ||
1028 | u8 phys_port; /* Physical id of port */ | ||
1029 | u8 virt_port; /* Virtual/Logical id of port */ | ||
1030 | u8 reserved[128]; /* save space for future expansion */ | ||
1031 | /* MUST BE 64-bit aligned. | ||
1032 | The following is packed: | ||
1033 | - N cardrsp_rds_rings | ||
1034 | - N cardrs_sds_rings */ | ||
1035 | char data[0]; | ||
1036 | } nx_cardrsp_rx_ctx_t; | ||
1037 | |||
1038 | #define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \ | ||
1039 | (sizeof(HOSTRQ_RX) + \ | ||
1040 | (rds_rings)*(sizeof(nx_hostrq_rds_ring_t)) + \ | ||
1041 | (sds_rings)*(sizeof(nx_hostrq_sds_ring_t))) | ||
1042 | |||
1043 | #define SIZEOF_CARDRSP_RX(CARDRSP_RX, rds_rings, sds_rings) \ | ||
1044 | (sizeof(CARDRSP_RX) + \ | ||
1045 | (rds_rings)*(sizeof(nx_cardrsp_rds_ring_t)) + \ | ||
1046 | (sds_rings)*(sizeof(nx_cardrsp_sds_ring_t))) | ||
1047 | |||
1048 | /* | ||
1049 | * Tx context | ||
1050 | */ | ||
1051 | |||
1052 | typedef struct { | ||
1053 | u64 host_phys_addr; /* Ring base addr */ | ||
1054 | u32 ring_size; /* Ring entries */ | ||
1055 | u32 rsvd; /* Padding */ | ||
1056 | } nx_hostrq_cds_ring_t; | ||
1057 | |||
1058 | typedef struct { | ||
1059 | u64 host_rsp_dma_addr; /* Response dma'd here */ | ||
1060 | u64 cmd_cons_dma_addr; /* */ | ||
1061 | u64 dummy_dma_addr; /* */ | ||
1062 | u32 capabilities[4]; /* Flag bit vector */ | ||
1063 | u32 host_int_crb_mode; /* Interrupt crb usage */ | ||
1064 | u32 rsvd1; /* Padding */ | ||
1065 | u16 rsvd2; /* Padding */ | ||
1066 | u16 interrupt_ctl; | ||
1067 | u16 msi_index; | ||
1068 | u16 rsvd3; /* Padding */ | ||
1069 | nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */ | ||
1070 | u8 reserved[128]; /* future expansion */ | ||
1071 | } nx_hostrq_tx_ctx_t; | ||
1072 | |||
1073 | typedef struct { | ||
1074 | u32 host_producer_crb; /* Crb to use */ | ||
1075 | u32 interrupt_crb; /* Crb to use */ | ||
1076 | } nx_cardrsp_cds_ring_t; | ||
1077 | |||
1078 | typedef struct { | ||
1079 | u32 host_ctx_state; /* Starting state */ | ||
1080 | u16 context_id; /* Handle for context */ | ||
1081 | u8 phys_port; /* Physical id of port */ | ||
1082 | u8 virt_port; /* Virtual/Logical id of port */ | ||
1083 | nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */ | ||
1084 | u8 reserved[128]; /* future expansion */ | ||
1085 | } nx_cardrsp_tx_ctx_t; | ||
1086 | |||
1087 | #define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) (sizeof(HOSTRQ_TX)) | ||
1088 | #define SIZEOF_CARDRSP_TX(CARDRSP_TX) (sizeof(CARDRSP_TX)) | ||
1089 | |||
1090 | /* CRB */ | ||
1091 | |||
1092 | #define NX_HOST_RDS_CRB_MODE_UNIQUE 0 | ||
1093 | #define NX_HOST_RDS_CRB_MODE_SHARED 1 | ||
1094 | #define NX_HOST_RDS_CRB_MODE_CUSTOM 2 | ||
1095 | #define NX_HOST_RDS_CRB_MODE_MAX 3 | ||
1096 | |||
1097 | #define NX_HOST_INT_CRB_MODE_UNIQUE 0 | ||
1098 | #define NX_HOST_INT_CRB_MODE_SHARED 1 | ||
1099 | #define NX_HOST_INT_CRB_MODE_NORX 2 | ||
1100 | #define NX_HOST_INT_CRB_MODE_NOTX 3 | ||
1101 | #define NX_HOST_INT_CRB_MODE_NORXTX 4 | ||
1102 | |||
1103 | |||
1104 | /* MAC */ | ||
1105 | |||
1106 | #define MC_COUNT_P2 16 | ||
1107 | #define MC_COUNT_P3 38 | ||
1108 | |||
1109 | #define NETXEN_MAC_NOOP 0 | ||
1110 | #define NETXEN_MAC_ADD 1 | ||
1111 | #define NETXEN_MAC_DEL 2 | ||
1112 | |||
1113 | typedef struct nx_mac_list_s { | ||
1114 | struct nx_mac_list_s *next; | ||
1115 | uint8_t mac_addr[MAX_ADDR_LEN]; | ||
1116 | } nx_mac_list_t; | ||
1117 | |||
1118 | typedef struct { | ||
1119 | u64 qhdr; | ||
1120 | u64 req_hdr; | ||
1121 | u64 words[6]; | ||
1122 | } nic_request_t; | ||
1123 | |||
1124 | typedef struct { | ||
1125 | u8 op; | ||
1126 | u8 tag; | ||
1127 | u8 mac_addr[6]; | ||
1128 | } nx_mac_req_t; | ||
1129 | |||
1130 | |||
874 | #define NETXEN_NIC_MSI_ENABLED 0x02 | 1131 | #define NETXEN_NIC_MSI_ENABLED 0x02 |
875 | #define NETXEN_NIC_MSIX_ENABLED 0x04 | 1132 | #define NETXEN_NIC_MSIX_ENABLED 0x04 |
876 | #define NETXEN_IS_MSI_FAMILY(adapter) \ | 1133 | #define NETXEN_IS_MSI_FAMILY(adapter) \ |
@@ -899,11 +1156,13 @@ struct netxen_adapter { | |||
899 | int mtu; | 1156 | int mtu; |
900 | int portnum; | 1157 | int portnum; |
901 | u8 physical_port; | 1158 | u8 physical_port; |
1159 | u16 tx_context_id; | ||
902 | 1160 | ||
903 | uint8_t mc_enabled; | 1161 | uint8_t mc_enabled; |
904 | uint8_t max_mc_count; | 1162 | uint8_t max_mc_count; |
905 | 1163 | ||
906 | struct netxen_legacy_intr_set legacy_intr; | 1164 | struct netxen_legacy_intr_set legacy_intr; |
1165 | u32 crb_intr_mask; | ||
907 | 1166 | ||
908 | struct work_struct watchdog_task; | 1167 | struct work_struct watchdog_task; |
909 | struct timer_list watchdog_timer; | 1168 | struct timer_list watchdog_timer; |
@@ -926,6 +1185,8 @@ struct netxen_adapter { | |||
926 | u32 max_jumbo_rx_desc_count; | 1185 | u32 max_jumbo_rx_desc_count; |
927 | u32 max_lro_rx_desc_count; | 1186 | u32 max_lro_rx_desc_count; |
928 | 1187 | ||
1188 | int max_rds_rings; | ||
1189 | |||
929 | u32 flags; | 1190 | u32 flags; |
930 | u32 irq; | 1191 | u32 irq; |
931 | int driver_mismatch; | 1192 | int driver_mismatch; |
@@ -1144,7 +1405,10 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, | |||
1144 | int netxen_process_cmd_ring(struct netxen_adapter *adapter); | 1405 | int netxen_process_cmd_ring(struct netxen_adapter *adapter); |
1145 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); | 1406 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); |
1146 | void netxen_nic_set_multi(struct net_device *netdev); | 1407 | void netxen_nic_set_multi(struct net_device *netdev); |
1408 | |||
1409 | u32 nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, u32 mtu); | ||
1147 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); | 1410 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); |
1411 | |||
1148 | int netxen_nic_set_mac(struct net_device *netdev, void *p); | 1412 | int netxen_nic_set_mac(struct net_device *netdev, void *p); |
1149 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev); | 1413 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev); |
1150 | 1414 | ||