2018-01-17 19:36:44 +03:00
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2017-03-13 22:02:02 +03:00
/*
* Copyright 2014 - 2016 Freescale Semiconductor Inc .
2019-12-12 20:01:13 +03:00
* Copyright 2017 - 2019 NXP
2017-03-13 22:02:02 +03:00
*
*/
# ifndef __FSL_DPAA2_IO_H
# define __FSL_DPAA2_IO_H
# include <linux/types.h>
# include <linux/cpumask.h>
2017-07-26 10:53:03 +03:00
# include <linux/irqreturn.h>
2017-03-13 22:02:02 +03:00
# include "dpaa2-fd.h"
# include "dpaa2-global.h"
struct dpaa2_io ;
struct dpaa2_io_store ;
struct device ;
/**
* DOC : DPIO Service
*
* The DPIO service provides APIs for users to interact with the datapath
* by enqueueing and dequeing frame descriptors .
*
* The following set of APIs can be used to enqueue and dequeue frames
* as well as producing notification callbacks when data is available
* for dequeue .
*/
2017-09-28 17:10:33 +03:00
# define DPAA2_IO_ANY_CPU -1
2017-03-13 22:02:02 +03:00
/**
* struct dpaa2_io_desc - The DPIO descriptor
* @ receives_notifications : Use notificaton mode . Non - zero if the DPIO
* has a channel .
* @ has_8prio : Set to non - zero for channel with 8 priority WQs . Ignored
* unless receives_notification is TRUE .
* @ cpu : The cpu index that at least interrupt handlers will
* execute on .
* @ stash_affinity : The stash affinity for this portal favour ' cpu '
* @ regs_cena : The cache enabled regs .
* @ regs_cinh : The cache inhibited regs
* @ dpio_id : The dpio index
* @ qman_version : The qman version
*
* Describes the attributes and features of the DPIO object .
*/
struct dpaa2_io_desc {
int receives_notifications ;
int has_8prio ;
int cpu ;
void * regs_cena ;
2018-03-27 21:13:31 +03:00
void __iomem * regs_cinh ;
2017-03-13 22:02:02 +03:00
int dpio_id ;
u32 qman_version ;
} ;
2018-12-10 19:50:18 +03:00
struct dpaa2_io * dpaa2_io_create ( const struct dpaa2_io_desc * desc ,
struct device * dev ) ;
2017-03-13 22:02:02 +03:00
void dpaa2_io_down ( struct dpaa2_io * d ) ;
irqreturn_t dpaa2_io_irq ( struct dpaa2_io * obj ) ;
2018-01-05 14:04:31 +03:00
struct dpaa2_io * dpaa2_io_service_select ( int cpu ) ;
2017-03-13 22:02:02 +03:00
/**
* struct dpaa2_io_notification_ctx - The DPIO notification context structure
* @ cb : The callback to be invoked when the notification arrives
* @ is_cdan : Zero for FQDAN , non - zero for CDAN
* @ id : FQID or channel ID , needed for rearm
2017-09-28 17:10:33 +03:00
* @ desired_cpu : The cpu on which the notifications will show up . Use
* DPAA2_IO_ANY_CPU if don ' t care
2017-03-13 22:02:02 +03:00
* @ dpio_id : The dpio index
* @ qman64 : The 64 - bit context value shows up in the FQDAN / CDAN .
* @ node : The list node
* @ dpio_private : The dpio object internal to dpio_service
*
* Used when a FQDAN / CDAN registration is made by drivers .
*/
struct dpaa2_io_notification_ctx {
2018-03-08 00:50:27 +03:00
void ( * cb ) ( struct dpaa2_io_notification_ctx * ctx ) ;
2017-03-13 22:02:02 +03:00
int is_cdan ;
u32 id ;
int desired_cpu ;
int dpio_id ;
u64 qman64 ;
struct list_head node ;
void * dpio_private ;
} ;
2018-12-04 14:20:29 +03:00
int dpaa2_io_get_cpu ( struct dpaa2_io * d ) ;
2017-03-13 22:02:02 +03:00
int dpaa2_io_service_register ( struct dpaa2_io * service ,
2018-12-10 19:50:19 +03:00
struct dpaa2_io_notification_ctx * ctx ,
struct device * dev ) ;
2017-03-13 22:02:02 +03:00
void dpaa2_io_service_deregister ( struct dpaa2_io * service ,
2018-12-10 19:50:19 +03:00
struct dpaa2_io_notification_ctx * ctx ,
struct device * dev ) ;
2017-03-13 22:02:02 +03:00
int dpaa2_io_service_rearm ( struct dpaa2_io * service ,
struct dpaa2_io_notification_ctx * ctx ) ;
2018-09-12 11:59:27 +03:00
int dpaa2_io_service_pull_fq ( struct dpaa2_io * d , u32 fqid ,
struct dpaa2_io_store * s ) ;
2017-03-13 22:02:02 +03:00
int dpaa2_io_service_pull_channel ( struct dpaa2_io * d , u32 channelid ,
struct dpaa2_io_store * s ) ;
2018-09-12 11:59:27 +03:00
int dpaa2_io_service_enqueue_fq ( struct dpaa2_io * d , u32 fqid ,
const struct dpaa2_fd * fd ) ;
2019-12-12 20:01:13 +03:00
int dpaa2_io_service_enqueue_multiple_fq ( struct dpaa2_io * d , u32 fqid ,
const struct dpaa2_fd * fd , int number_of_frame ) ;
int dpaa2_io_service_enqueue_multiple_desc_fq ( struct dpaa2_io * d , u32 * fqid ,
const struct dpaa2_fd * fd , int number_of_frame ) ;
2017-03-13 22:02:02 +03:00
int dpaa2_io_service_enqueue_qd ( struct dpaa2_io * d , u32 qdid , u8 prio ,
u16 qdbin , const struct dpaa2_fd * fd ) ;
2018-12-14 19:04:06 +03:00
int dpaa2_io_service_release ( struct dpaa2_io * d , u16 bpid ,
2017-03-13 22:02:02 +03:00
const u64 * buffers , unsigned int num_buffers ) ;
2018-12-14 19:04:06 +03:00
int dpaa2_io_service_acquire ( struct dpaa2_io * d , u16 bpid ,
2017-03-13 22:02:02 +03:00
u64 * buffers , unsigned int num_buffers ) ;
struct dpaa2_io_store * dpaa2_io_store_create ( unsigned int max_frames ,
struct device * dev ) ;
void dpaa2_io_store_destroy ( struct dpaa2_io_store * s ) ;
struct dpaa2_dq * dpaa2_io_store_next ( struct dpaa2_io_store * s , int * is_last ) ;
2018-12-18 18:23:01 +03:00
int dpaa2_io_query_fq_count ( struct dpaa2_io * d , u32 fqid ,
u32 * fcnt , u32 * bcnt ) ;
int dpaa2_io_query_bp_count ( struct dpaa2_io * d , u16 bpid ,
u32 * num ) ;
2017-03-13 22:02:02 +03:00
# endif /* __FSL_DPAA2_IO_H */