Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  linux/drivers/net/ethernet/ibm/ehea/ehea_phyp.h
0004  *
0005  *  eHEA ethernet device driver for IBM eServer System p
0006  *
0007  *  (C) Copyright IBM Corp. 2006
0008  *
0009  *  Authors:
0010  *       Christoph Raisch <raisch@de.ibm.com>
0011  *       Jan-Bernd Themann <themann@de.ibm.com>
0012  *       Thomas Klein <tklein@de.ibm.com>
0013  */
0014 
0015 #ifndef __EHEA_PHYP_H__
0016 #define __EHEA_PHYP_H__
0017 
0018 #include <linux/delay.h>
0019 #include <asm/hvcall.h>
0020 #include "ehea.h"
0021 #include "ehea_hw.h"
0022 
0023 /* Some abbreviations used here:
0024  *
0025  * hcp_*  - structures, variables and functions releated to Hypervisor Calls
0026  */
0027 
0028 /* Number of pages which can be registered at once by H_REGISTER_HEA_RPAGES */
0029 #define EHEA_MAX_RPAGE 512
0030 
0031 /* Notification Event Queue (NEQ) Entry bit masks */
0032 #define NEQE_EVENT_CODE     EHEA_BMASK_IBM(2, 7)
0033 #define NEQE_PORTNUM        EHEA_BMASK_IBM(32, 47)
0034 #define NEQE_PORT_UP        EHEA_BMASK_IBM(16, 16)
0035 #define NEQE_EXTSWITCH_PORT_UP  EHEA_BMASK_IBM(17, 17)
0036 #define NEQE_EXTSWITCH_PRIMARY  EHEA_BMASK_IBM(18, 18)
0037 #define NEQE_PLID       EHEA_BMASK_IBM(16, 47)
0038 
0039 /* Notification Event Codes */
0040 #define EHEA_EC_PORTSTATE_CHG   0x30
0041 #define EHEA_EC_ADAPTER_MALFUNC 0x32
0042 #define EHEA_EC_PORT_MALFUNC    0x33
0043 
0044 /* Notification Event Log Register (NELR) bit masks */
0045 #define NELR_PORT_MALFUNC   EHEA_BMASK_IBM(61, 61)
0046 #define NELR_ADAPTER_MALFUNC    EHEA_BMASK_IBM(62, 62)
0047 #define NELR_PORTSTATE_CHG  EHEA_BMASK_IBM(63, 63)
0048 
0049 static inline void hcp_epas_ctor(struct h_epas *epas, u64 paddr_kernel,
0050                  u64 paddr_user)
0051 {
0052     /* To support 64k pages we must round to 64k page boundary */
0053     epas->kernel.addr = ioremap((paddr_kernel & PAGE_MASK), PAGE_SIZE) +
0054                 (paddr_kernel & ~PAGE_MASK);
0055     epas->user.addr = paddr_user;
0056 }
0057 
0058 static inline void hcp_epas_dtor(struct h_epas *epas)
0059 {
0060     if (epas->kernel.addr)
0061         iounmap((void __iomem *)((u64)epas->kernel.addr & PAGE_MASK));
0062 
0063     epas->user.addr = 0;
0064     epas->kernel.addr = 0;
0065 }
0066 
0067 struct hcp_modify_qp_cb0 {
0068     u64 qp_ctl_reg;     /* 00 */
0069     u32 max_swqe;       /* 02 */
0070     u32 max_rwqe;       /* 03 */
0071     u32 port_nb;        /* 04 */
0072     u32 reserved0;      /* 05 */
0073     u64 qp_aer;     /* 06 */
0074     u64 qp_tenure;      /* 08 */
0075 };
0076 
0077 /* Hcall Query/Modify Queue Pair Control Block 0 Selection Mask Bits */
0078 #define H_QPCB0_ALL             EHEA_BMASK_IBM(0, 5)
0079 #define H_QPCB0_QP_CTL_REG      EHEA_BMASK_IBM(0, 0)
0080 #define H_QPCB0_MAX_SWQE        EHEA_BMASK_IBM(1, 1)
0081 #define H_QPCB0_MAX_RWQE        EHEA_BMASK_IBM(2, 2)
0082 #define H_QPCB0_PORT_NB         EHEA_BMASK_IBM(3, 3)
0083 #define H_QPCB0_QP_AER          EHEA_BMASK_IBM(4, 4)
0084 #define H_QPCB0_QP_TENURE       EHEA_BMASK_IBM(5, 5)
0085 
0086 /* Queue Pair Control Register Status Bits */
0087 #define H_QP_CR_ENABLED         0x8000000000000000ULL /* QP enabled */
0088                               /* QP States: */
0089 #define H_QP_CR_STATE_RESET     0x0000010000000000ULL /*  Reset */
0090 #define H_QP_CR_STATE_INITIALIZED   0x0000020000000000ULL /*  Initialized */
0091 #define H_QP_CR_STATE_RDY2RCV       0x0000030000000000ULL /*  Ready to recv */
0092 #define H_QP_CR_STATE_RDY2SND       0x0000050000000000ULL /*  Ready to send */
0093 #define H_QP_CR_STATE_ERROR     0x0000800000000000ULL /*  Error */
0094 #define H_QP_CR_RES_STATE       0x0000007F00000000ULL /* Resultant state */
0095 
0096 struct hcp_modify_qp_cb1 {
0097     u32 qpn;        /* 00 */
0098     u32 qp_asyn_ev_eq_nb;   /* 01 */
0099     u64 sq_cq_handle;   /* 02 */
0100     u64 rq_cq_handle;   /* 04 */
0101     /* sgel = scatter gather element */
0102     u32 sgel_nb_sq;     /* 06 */
0103     u32 sgel_nb_rq1;    /* 07 */
0104     u32 sgel_nb_rq2;    /* 08 */
0105     u32 sgel_nb_rq3;    /* 09 */
0106 };
0107 
0108 /* Hcall Query/Modify Queue Pair Control Block 1 Selection Mask Bits */
0109 #define H_QPCB1_ALL             EHEA_BMASK_IBM(0, 7)
0110 #define H_QPCB1_QPN             EHEA_BMASK_IBM(0, 0)
0111 #define H_QPCB1_ASYN_EV_EQ_NB   EHEA_BMASK_IBM(1, 1)
0112 #define H_QPCB1_SQ_CQ_HANDLE    EHEA_BMASK_IBM(2, 2)
0113 #define H_QPCB1_RQ_CQ_HANDLE    EHEA_BMASK_IBM(3, 3)
0114 #define H_QPCB1_SGEL_NB_SQ      EHEA_BMASK_IBM(4, 4)
0115 #define H_QPCB1_SGEL_NB_RQ1     EHEA_BMASK_IBM(5, 5)
0116 #define H_QPCB1_SGEL_NB_RQ2     EHEA_BMASK_IBM(6, 6)
0117 #define H_QPCB1_SGEL_NB_RQ3     EHEA_BMASK_IBM(7, 7)
0118 
0119 struct hcp_query_ehea {
0120     u32 cur_num_qps;        /* 00 */
0121     u32 cur_num_cqs;        /* 01 */
0122     u32 cur_num_eqs;        /* 02 */
0123     u32 cur_num_mrs;        /* 03 */
0124     u32 auth_level;         /* 04 */
0125     u32 max_num_qps;        /* 05 */
0126     u32 max_num_cqs;        /* 06 */
0127     u32 max_num_eqs;        /* 07 */
0128     u32 max_num_mrs;        /* 08 */
0129     u32 reserved0;          /* 09 */
0130     u32 int_clock_freq;     /* 10 */
0131     u32 max_num_pds;        /* 11 */
0132     u32 max_num_addr_handles;   /* 12 */
0133     u32 max_num_cqes;       /* 13 */
0134     u32 max_num_wqes;       /* 14 */
0135     u32 max_num_sgel_rq1wqe;    /* 15 */
0136     u32 max_num_sgel_rq2wqe;    /* 16 */
0137     u32 max_num_sgel_rq3wqe;    /* 17 */
0138     u32 mr_page_size;       /* 18 */
0139     u32 reserved1;          /* 19 */
0140     u64 max_mr_size;        /* 20 */
0141     u64 reserved2;          /* 22 */
0142     u32 num_ports;          /* 24 */
0143     u32 reserved3;          /* 25 */
0144     u32 reserved4;          /* 26 */
0145     u32 reserved5;          /* 27 */
0146     u64 max_mc_mac;         /* 28 */
0147     u64 ehea_cap;           /* 30 */
0148     u32 max_isn_per_eq;     /* 32 */
0149     u32 max_num_neq;        /* 33 */
0150     u64 max_num_vlan_ids;       /* 34 */
0151     u32 max_num_port_group;     /* 36 */
0152     u32 max_num_phys_port;      /* 37 */
0153 
0154 };
0155 
0156 /* Hcall Query/Modify Port Control Block defines */
0157 #define H_PORT_CB0   0
0158 #define H_PORT_CB1   1
0159 #define H_PORT_CB2   2
0160 #define H_PORT_CB3   3
0161 #define H_PORT_CB4   4
0162 #define H_PORT_CB5   5
0163 #define H_PORT_CB6   6
0164 #define H_PORT_CB7   7
0165 
0166 struct hcp_ehea_port_cb0 {
0167     u64 port_mac_addr;
0168     u64 port_rc;
0169     u64 reserved0;
0170     u32 port_op_state;
0171     u32 port_speed;
0172     u32 ext_swport_op_state;
0173     u32 neg_tpf_prpf;
0174     u32 num_default_qps;
0175     u32 reserved1;
0176     u64 default_qpn_arr[16];
0177 };
0178 
0179 /* Hcall Query/Modify Port Control Block 0 Selection Mask Bits */
0180 #define H_PORT_CB0_ALL      EHEA_BMASK_IBM(0, 7)    /* Set all bits */
0181 #define H_PORT_CB0_MAC      EHEA_BMASK_IBM(0, 0)    /* MAC address */
0182 #define H_PORT_CB0_PRC      EHEA_BMASK_IBM(1, 1)    /* Port Recv Control */
0183 #define H_PORT_CB0_DEFQPNARRAY  EHEA_BMASK_IBM(7, 7)    /* Default QPN Array */
0184 
0185 /*  Hcall Query Port: Returned port speed values */
0186 #define H_SPEED_10M_H   1   /*  10 Mbps, Half Duplex */
0187 #define H_SPEED_10M_F   2   /*  10 Mbps, Full Duplex */
0188 #define H_SPEED_100M_H  3   /* 100 Mbps, Half Duplex */
0189 #define H_SPEED_100M_F  4   /* 100 Mbps, Full Duplex */
0190 #define H_SPEED_1G_F    6   /*   1 Gbps, Full Duplex */
0191 #define H_SPEED_10G_F   8   /*  10 Gbps, Full Duplex */
0192 
0193 /* Port Receive Control Status Bits */
0194 #define PXLY_RC_VALID           EHEA_BMASK_IBM(49, 49)
0195 #define PXLY_RC_VLAN_XTRACT     EHEA_BMASK_IBM(50, 50)
0196 #define PXLY_RC_TCP_6_TUPLE     EHEA_BMASK_IBM(51, 51)
0197 #define PXLY_RC_UDP_6_TUPLE     EHEA_BMASK_IBM(52, 52)
0198 #define PXLY_RC_TCP_3_TUPLE     EHEA_BMASK_IBM(53, 53)
0199 #define PXLY_RC_TCP_2_TUPLE     EHEA_BMASK_IBM(54, 54)
0200 #define PXLY_RC_LLC_SNAP        EHEA_BMASK_IBM(55, 55)
0201 #define PXLY_RC_JUMBO_FRAME     EHEA_BMASK_IBM(56, 56)
0202 #define PXLY_RC_FRAG_IP_PKT     EHEA_BMASK_IBM(57, 57)
0203 #define PXLY_RC_TCP_UDP_CHKSUM  EHEA_BMASK_IBM(58, 58)
0204 #define PXLY_RC_IP_CHKSUM       EHEA_BMASK_IBM(59, 59)
0205 #define PXLY_RC_MAC_FILTER      EHEA_BMASK_IBM(60, 60)
0206 #define PXLY_RC_UNTAG_FILTER    EHEA_BMASK_IBM(61, 61)
0207 #define PXLY_RC_VLAN_TAG_FILTER EHEA_BMASK_IBM(62, 63)
0208 
0209 #define PXLY_RC_VLAN_FILTER     2
0210 #define PXLY_RC_VLAN_PERM       0
0211 
0212 
0213 #define H_PORT_CB1_ALL          0x8000000000000000ULL
0214 
0215 struct hcp_ehea_port_cb1 {
0216     u64 vlan_filter[64];
0217 };
0218 
0219 #define H_PORT_CB2_ALL          0xFFE0000000000000ULL
0220 
0221 struct hcp_ehea_port_cb2 {
0222     u64 rxo;
0223     u64 rxucp;
0224     u64 rxufd;
0225     u64 rxuerr;
0226     u64 rxftl;
0227     u64 rxmcp;
0228     u64 rxbcp;
0229     u64 txo;
0230     u64 txucp;
0231     u64 txmcp;
0232     u64 txbcp;
0233 };
0234 
0235 struct hcp_ehea_port_cb3 {
0236     u64 vlan_bc_filter[64];
0237     u64 vlan_mc_filter[64];
0238     u64 vlan_un_filter[64];
0239     u64 port_mac_hash_array[64];
0240 };
0241 
0242 #define H_PORT_CB4_ALL          0xF000000000000000ULL
0243 #define H_PORT_CB4_JUMBO        0x1000000000000000ULL
0244 #define H_PORT_CB4_SPEED        0x8000000000000000ULL
0245 
0246 struct hcp_ehea_port_cb4 {
0247     u32 port_speed;
0248     u32 pause_frame;
0249     u32 ens_port_op_state;
0250     u32 jumbo_frame;
0251     u32 ens_port_wrap;
0252 };
0253 
0254 /* Hcall Query/Modify Port Control Block 5 Selection Mask Bits */
0255 #define H_PORT_CB5_RCU      0x0001000000000000ULL
0256 #define PXS_RCU         EHEA_BMASK_IBM(61, 63)
0257 
0258 struct hcp_ehea_port_cb5 {
0259     u64 prc;            /* 00 */
0260     u64 uaa;        /* 01 */
0261     u64 macvc;      /* 02 */
0262     u64 xpcsc;      /* 03 */
0263     u64 xpcsp;      /* 04 */
0264     u64 pcsid;      /* 05 */
0265     u64 xpcsst;     /* 06 */
0266     u64 pthlb;      /* 07 */
0267     u64 pthrb;      /* 08 */
0268     u64 pqu;        /* 09 */
0269     u64 pqd;        /* 10 */
0270     u64 prt;        /* 11 */
0271     u64 wsth;       /* 12 */
0272     u64 rcb;        /* 13 */
0273     u64 rcm;        /* 14 */
0274     u64 rcu;        /* 15 */
0275     u64 macc;       /* 16 */
0276     u64 pc;         /* 17 */
0277     u64 pst;        /* 18 */
0278     u64 ducqpn;     /* 19 */
0279     u64 mcqpn;      /* 20 */
0280     u64 mma;        /* 21 */
0281     u64 pmc0h;      /* 22 */
0282     u64 pmc0l;      /* 23 */
0283     u64 lbc;        /* 24 */
0284 };
0285 
0286 #define H_PORT_CB6_ALL  0xFFFFFE7FFFFF8000ULL
0287 
0288 struct hcp_ehea_port_cb6 {
0289     u64 rxo;        /* 00 */
0290     u64 rx64;       /* 01 */
0291     u64 rx65;       /* 02 */
0292     u64 rx128;      /* 03 */
0293     u64 rx256;      /* 04 */
0294     u64 rx512;      /* 05 */
0295     u64 rx1024;     /* 06 */
0296     u64 rxbfcs;     /* 07 */
0297     u64 rxime;      /* 08 */
0298     u64 rxrle;      /* 09 */
0299     u64 rxorle;     /* 10 */
0300     u64 rxftl;      /* 11 */
0301     u64 rxjab;      /* 12 */
0302     u64 rxse;       /* 13 */
0303     u64 rxce;       /* 14 */
0304     u64 rxrf;       /* 15 */
0305     u64 rxfrag;     /* 16 */
0306     u64 rxuoc;      /* 17 */
0307     u64 rxcpf;      /* 18 */
0308     u64 rxsb;       /* 19 */
0309     u64 rxfd;       /* 20 */
0310     u64 rxoerr;     /* 21 */
0311     u64 rxaln;      /* 22 */
0312     u64 ducqpn;     /* 23 */
0313     u64 reserved0;      /* 24 */
0314     u64 rxmcp;      /* 25 */
0315     u64 rxbcp;      /* 26 */
0316     u64 txmcp;      /* 27 */
0317     u64 txbcp;      /* 28 */
0318     u64 txo;        /* 29 */
0319     u64 tx64;       /* 30 */
0320     u64 tx65;       /* 31 */
0321     u64 tx128;      /* 32 */
0322     u64 tx256;      /* 33 */
0323     u64 tx512;      /* 34 */
0324     u64 tx1024;     /* 35 */
0325     u64 txbfcs;     /* 36 */
0326     u64 txcpf;      /* 37 */
0327     u64 txlf;       /* 38 */
0328     u64 txrf;       /* 39 */
0329     u64 txime;      /* 40 */
0330     u64 txsc;       /* 41 */
0331     u64 txmc;       /* 42 */
0332     u64 txsqe;      /* 43 */
0333     u64 txdef;      /* 44 */
0334     u64 txlcol;     /* 45 */
0335     u64 txexcol;        /* 46 */
0336     u64 txcse;      /* 47 */
0337     u64 txbor;      /* 48 */
0338 };
0339 
0340 #define H_PORT_CB7_DUCQPN 0x8000000000000000ULL
0341 
0342 struct hcp_ehea_port_cb7 {
0343     u64 def_uc_qpn;
0344 };
0345 
0346 u64 ehea_h_query_ehea_qp(const u64 adapter_handle,
0347              const u8 qp_category,
0348              const u64 qp_handle, const u64 sel_mask,
0349              void *cb_addr);
0350 
0351 u64 ehea_h_modify_ehea_qp(const u64 adapter_handle,
0352               const u8 cat,
0353               const u64 qp_handle,
0354               const u64 sel_mask,
0355               void *cb_addr,
0356               u64 *inv_attr_id,
0357               u64 *proc_mask, u16 *out_swr, u16 *out_rwr);
0358 
0359 u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
0360                  struct ehea_eq_attr *eq_attr, u64 *eq_handle);
0361 
0362 u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
0363                  struct ehea_cq_attr *cq_attr,
0364                  u64 *cq_handle, struct h_epas *epas);
0365 
0366 u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
0367                  struct ehea_qp_init_attr *init_attr,
0368                  const u32 pd,
0369                  u64 *qp_handle, struct h_epas *h_epas);
0370 
0371 #define H_REG_RPAGE_PAGE_SIZE          EHEA_BMASK_IBM(48, 55)
0372 #define H_REG_RPAGE_QT                 EHEA_BMASK_IBM(62, 63)
0373 
0374 u64 ehea_h_register_rpage(const u64 adapter_handle,
0375               const u8 pagesize,
0376               const u8 queue_type,
0377               const u64 resource_handle,
0378               const u64 log_pageaddr, u64 count);
0379 
0380 #define H_DISABLE_GET_EHEA_WQE_P  1
0381 #define H_DISABLE_GET_SQ_WQE_P    2
0382 #define H_DISABLE_GET_RQC         3
0383 
0384 u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle);
0385 
0386 #define FORCE_FREE 1
0387 #define NORMAL_FREE 0
0388 
0389 u64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle,
0390              u64 force_bit);
0391 
0392 u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr,
0393                  const u64 length, const u32 access_ctrl,
0394                  const u32 pd, u64 *mr_handle, u32 *lkey);
0395 
0396 u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
0397                  const u8 pagesize, const u8 queue_type,
0398                  const u64 log_pageaddr, const u64 count);
0399 
0400 u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
0401             const u64 vaddr_in, const u32 access_ctrl, const u32 pd,
0402             struct ehea_mr *mr);
0403 
0404 u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr);
0405 
0406 /* output param R5 */
0407 #define H_MEHEAPORT_CAT     EHEA_BMASK_IBM(40, 47)
0408 #define H_MEHEAPORT_PN      EHEA_BMASK_IBM(48, 63)
0409 
0410 u64 ehea_h_query_ehea_port(const u64 adapter_handle, const u16 port_num,
0411                const u8 cb_cat, const u64 select_mask,
0412                void *cb_addr);
0413 
0414 u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
0415                 const u8 cb_cat, const u64 select_mask,
0416                 void *cb_addr);
0417 
0418 #define H_REGBCMC_PN            EHEA_BMASK_IBM(48, 63)
0419 #define H_REGBCMC_REGTYPE       EHEA_BMASK_IBM(60, 63)
0420 #define H_REGBCMC_MACADDR       EHEA_BMASK_IBM(16, 63)
0421 #define H_REGBCMC_VLANID        EHEA_BMASK_IBM(52, 63)
0422 
0423 u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
0424               const u8 reg_type, const u64 mc_mac_addr,
0425               const u16 vlan_id, const u32 hcall_id);
0426 
0427 u64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle,
0428             const u64 event_mask);
0429 
0430 u64 ehea_h_error_data(const u64 adapter_handle, const u64 ressource_handle,
0431               void *rblock);
0432 
0433 #endif  /* __EHEA_PHYP_H__ */