linux/drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000/nfp6000.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2015-2017 Netronome Systems, Inc.
   3 *
   4 * This software is dual licensed under the GNU General License Version 2,
   5 * June 1991 as shown in the file COPYING in the top-level directory of this
   6 * source tree or the BSD 2-Clause License provided below.  You have the
   7 * option to license this software under the complete terms of either license.
   8 *
   9 * The BSD 2-Clause License:
  10 *
  11 *     Redistribution and use in source and binary forms, with or
  12 *     without modification, are permitted provided that the following
  13 *     conditions are met:
  14 *
  15 *      1. Redistributions of source code must retain the above
  16 *         copyright notice, this list of conditions and the following
  17 *         disclaimer.
  18 *
  19 *      2. Redistributions in binary form must reproduce the above
  20 *         copyright notice, this list of conditions and the following
  21 *         disclaimer in the documentation and/or other materials
  22 *         provided with the distribution.
  23 *
  24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31 * SOFTWARE.
  32 */
  33
  34#ifndef NFP6000_NFP6000_H
  35#define NFP6000_NFP6000_H
  36
  37#include <linux/errno.h>
  38#include <linux/types.h>
  39
  40/* CPP Target IDs */
  41#define NFP_CPP_TARGET_INVALID          0
  42#define NFP_CPP_TARGET_NBI              1
  43#define NFP_CPP_TARGET_QDR              2
  44#define NFP_CPP_TARGET_ILA              6
  45#define NFP_CPP_TARGET_MU               7
  46#define NFP_CPP_TARGET_PCIE             9
  47#define NFP_CPP_TARGET_ARM              10
  48#define NFP_CPP_TARGET_CRYPTO           12
  49#define NFP_CPP_TARGET_ISLAND_XPB       14      /* Shared with CAP */
  50#define NFP_CPP_TARGET_ISLAND_CAP       14      /* Shared with XPB */
  51#define NFP_CPP_TARGET_CT_XPB           14
  52#define NFP_CPP_TARGET_LOCAL_SCRATCH    15
  53#define NFP_CPP_TARGET_CLS              NFP_CPP_TARGET_LOCAL_SCRATCH
  54
  55#define NFP_ISL_EMEM0                   24
  56
  57#define NFP_MU_ADDR_ACCESS_TYPE_MASK    3ULL
  58#define NFP_MU_ADDR_ACCESS_TYPE_DIRECT  2ULL
  59
  60#define PUSHPULL(_pull, _push)          ((_pull) << 4 | (_push) << 0)
  61#define PUSH_WIDTH(_pushpull)           pushpull_width((_pushpull) >> 0)
  62#define PULL_WIDTH(_pushpull)           pushpull_width((_pushpull) >> 4)
  63
  64static inline int pushpull_width(int pp)
  65{
  66        pp &= 0xf;
  67
  68        if (pp == 0)
  69                return -EINVAL;
  70        return 2 << pp;
  71}
  72
  73static inline int nfp_cppat_mu_locality_lsb(int mode, bool addr40)
  74{
  75        switch (mode) {
  76        case 0 ... 3:
  77                return addr40 ? 38 : 30;
  78        default:
  79                return -EINVAL;
  80        }
  81}
  82
  83int nfp_target_pushpull(u32 cpp_id, u64 address);
  84int nfp_target_cpp(u32 cpp_island_id, u64 cpp_island_address,
  85                   u32 *cpp_target_id, u64 *cpp_target_address,
  86                   const u32 *imb_table);
  87
  88#endif /* NFP6000_NFP6000_H */
  89