Linux Audio

Check our new training course

Linux BSP upgrade and security maintenance

Need help to get security updates for your Linux BSP?
Loading...
v4.17
  1/*
  2 * Copyright (C) 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 NFP_NET_REPR_H
 35#define NFP_NET_REPR_H
 36
 37struct metadata_dst;
 38struct nfp_app;
 39struct nfp_net;
 40struct nfp_port;
 41
 42#include <net/dst_metadata.h>
 43
 44/**
 45 * struct nfp_reprs - container for representor netdevs
 46 * @num_reprs:	Number of elements in reprs array
 47 * @reprs:	Array of representor netdevs
 48 */
 49struct nfp_reprs {
 50	unsigned int num_reprs;
 51	struct net_device __rcu *reprs[0];
 52};
 53
 54/**
 55 * struct nfp_repr_pcpu_stats
 56 * @rx_packets:	Received packets
 57 * @rx_bytes:	Received bytes
 58 * @tx_packets:	Transmitted packets
 59 * @tx_bytes:	Transmitted dropped
 60 * @tx_drops:	Packets dropped on transmit
 61 * @syncp:	Reference count
 62 */
 63struct nfp_repr_pcpu_stats {
 64	u64 rx_packets;
 65	u64 rx_bytes;
 66	u64 tx_packets;
 67	u64 tx_bytes;
 68	u64 tx_drops;
 69	struct u64_stats_sync syncp;
 70};
 71
 72/**
 73 * struct nfp_repr - priv data for representor netdevs
 74 * @netdev:	Back pointer to netdev
 75 * @dst:	Destination for packet TX
 76 * @port:	Port of representor
 77 * @app:	APP handle
 78 * @stats:	Statistic of packets hitting CPU
 
 79 */
 80struct nfp_repr {
 81	struct net_device *netdev;
 82	struct metadata_dst *dst;
 83	struct nfp_port *port;
 84	struct nfp_app *app;
 85	struct nfp_repr_pcpu_stats __percpu *stats;
 
 86};
 87
 88/**
 89 * enum nfp_repr_type - type of representor
 90 * @NFP_REPR_TYPE_PHYS_PORT:	external NIC port
 91 * @NFP_REPR_TYPE_PF:		physical function
 92 * @NFP_REPR_TYPE_VF:		virtual function
 93 * @__NFP_REPR_TYPE_MAX:	number of representor types
 94 */
 95enum nfp_repr_type {
 96	NFP_REPR_TYPE_PHYS_PORT,
 97	NFP_REPR_TYPE_PF,
 98	NFP_REPR_TYPE_VF,
 99
100	__NFP_REPR_TYPE_MAX,
101};
102#define NFP_REPR_TYPE_MAX (__NFP_REPR_TYPE_MAX - 1)
103
104extern const struct net_device_ops nfp_repr_netdev_ops;
105
106static inline bool nfp_netdev_is_nfp_repr(struct net_device *netdev)
107{
108	return netdev->netdev_ops == &nfp_repr_netdev_ops;
109}
110
111static inline int nfp_repr_get_port_id(struct net_device *netdev)
112{
113	struct nfp_repr *priv = netdev_priv(netdev);
114
115	return priv->dst->u.port_info.port_id;
116}
117
118struct net_device *
119nfp_repr_get_locked(struct nfp_app *app, struct nfp_reprs *set,
120		    unsigned int id);
121
122void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len);
 
 
123int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
124		  u32 cmsg_port_id, struct nfp_port *port,
125		  struct net_device *pf_netdev);
126struct net_device *nfp_repr_alloc(struct nfp_app *app);
 
 
 
127void nfp_reprs_clean_and_free(struct nfp_app *app, struct nfp_reprs *reprs);
128void nfp_reprs_clean_and_free_by_type(struct nfp_app *app,
129				      enum nfp_repr_type type);
130struct nfp_reprs *nfp_reprs_alloc(unsigned int num_reprs);
131int nfp_reprs_resync_phys_ports(struct nfp_app *app);
132
 
 
 
 
133#endif /* NFP_NET_REPR_H */
v6.13.7
  1/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
  2/* Copyright (C) 2017-2018 Netronome Systems, Inc. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  3
  4#ifndef NFP_NET_REPR_H
  5#define NFP_NET_REPR_H
  6
  7struct metadata_dst;
  8struct nfp_app;
  9struct nfp_net;
 10struct nfp_port;
 11
 12#include <net/dst_metadata.h>
 13
 14/**
 15 * struct nfp_reprs - container for representor netdevs
 16 * @num_reprs:	Number of elements in reprs array
 17 * @reprs:	Array of representor netdevs
 18 */
 19struct nfp_reprs {
 20	unsigned int num_reprs;
 21	struct net_device __rcu *reprs[] __counted_by(num_reprs);
 22};
 23
 24/**
 25 * struct nfp_repr_pcpu_stats
 26 * @rx_packets:	Received packets
 27 * @rx_bytes:	Received bytes
 28 * @tx_packets:	Transmitted packets
 29 * @tx_bytes:	Transmitted dropped
 30 * @tx_drops:	Packets dropped on transmit
 31 * @syncp:	Reference count
 32 */
 33struct nfp_repr_pcpu_stats {
 34	u64 rx_packets;
 35	u64 rx_bytes;
 36	u64 tx_packets;
 37	u64 tx_bytes;
 38	u64 tx_drops;
 39	struct u64_stats_sync syncp;
 40};
 41
 42/**
 43 * struct nfp_repr - priv data for representor netdevs
 44 * @netdev:	Back pointer to netdev
 45 * @dst:	Destination for packet TX
 46 * @port:	Port of representor
 47 * @app:	APP handle
 48 * @stats:	Statistic of packets hitting CPU
 49 * @app_priv:	Pointer for APP data
 50 */
 51struct nfp_repr {
 52	struct net_device *netdev;
 53	struct metadata_dst *dst;
 54	struct nfp_port *port;
 55	struct nfp_app *app;
 56	struct nfp_repr_pcpu_stats __percpu *stats;
 57	void *app_priv;
 58};
 59
 60/**
 61 * enum nfp_repr_type - type of representor
 62 * @NFP_REPR_TYPE_PHYS_PORT:	external NIC port
 63 * @NFP_REPR_TYPE_PF:		physical function
 64 * @NFP_REPR_TYPE_VF:		virtual function
 65 * @__NFP_REPR_TYPE_MAX:	number of representor types
 66 */
 67enum nfp_repr_type {
 68	NFP_REPR_TYPE_PHYS_PORT,
 69	NFP_REPR_TYPE_PF,
 70	NFP_REPR_TYPE_VF,
 71
 72	__NFP_REPR_TYPE_MAX,
 73};
 74#define NFP_REPR_TYPE_MAX (__NFP_REPR_TYPE_MAX - 1)
 75
 76extern const struct net_device_ops nfp_repr_netdev_ops;
 77
 78static inline bool nfp_netdev_is_nfp_repr(struct net_device *netdev)
 79{
 80	return netdev->netdev_ops == &nfp_repr_netdev_ops;
 81}
 82
 83static inline int nfp_repr_get_port_id(struct net_device *netdev)
 84{
 85	struct nfp_repr *priv = netdev_priv(netdev);
 86
 87	return priv->dst->u.port_info.port_id;
 88}
 89
 90struct net_device *
 91nfp_repr_get_locked(struct nfp_app *app, struct nfp_reprs *set,
 92		    unsigned int id);
 93
 94void nfp_repr_inc_rx_stats(struct net_device *netdev, unsigned int len);
 95void
 96nfp_repr_transfer_features(struct net_device *netdev, struct net_device *lower);
 97int nfp_repr_init(struct nfp_app *app, struct net_device *netdev,
 98		  u32 cmsg_port_id, struct nfp_port *port,
 99		  struct net_device *pf_netdev);
100void nfp_repr_free(struct net_device *netdev);
101struct net_device *
102nfp_repr_alloc_mqs(struct nfp_app *app, unsigned int txqs, unsigned int rxqs);
103void nfp_repr_clean_and_free(struct nfp_repr *repr);
104void nfp_reprs_clean_and_free(struct nfp_app *app, struct nfp_reprs *reprs);
105void nfp_reprs_clean_and_free_by_type(struct nfp_app *app,
106				      enum nfp_repr_type type);
107struct nfp_reprs *nfp_reprs_alloc(unsigned int num_reprs);
108int nfp_reprs_resync_phys_ports(struct nfp_app *app);
109
110static inline struct net_device *nfp_repr_alloc(struct nfp_app *app)
111{
112	return nfp_repr_alloc_mqs(app, 1, 1);
113}
114#endif /* NFP_NET_REPR_H */