qi.c (9e8238020c5beba64e7ffafbb7ea0fb02fe68270) qi.c (abd9875497ba47e198fb565f11d5f332eeb08ab3)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * CAAM/SEC 4.x QI transport/backend driver
4 * Queue Interface backend functionality
5 *
6 * Copyright 2013-2016 Freescale Semiconductor, Inc.
7 * Copyright 2016-2017, 2019-2020 NXP
8 */
9
10#include <linux/cpumask.h>
11#include <linux/kthread.h>
12#include <soc/fsl/qman.h>
13
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * CAAM/SEC 4.x QI transport/backend driver
4 * Queue Interface backend functionality
5 *
6 * Copyright 2013-2016 Freescale Semiconductor, Inc.
7 * Copyright 2016-2017, 2019-2020 NXP
8 */
9
10#include <linux/cpumask.h>
11#include <linux/kthread.h>
12#include <soc/fsl/qman.h>
13
14#include "debugfs.h"
14#include "regs.h"
15#include "qi.h"
16#include "desc.h"
17#include "intern.h"
18#include "desc_constr.h"
19
20#define PREHDR_RSLS_SHIFT 31
21#define PREHDR_ABS BIT(25)

--- 46 unchanged lines hidden (view full) ---

68
69/*
70 * This is written by only one core - the one that initialized the CGR - and
71 * read by multiple cores (all the others).
72 */
73bool caam_congested __read_mostly;
74EXPORT_SYMBOL(caam_congested);
75
15#include "regs.h"
16#include "qi.h"
17#include "desc.h"
18#include "intern.h"
19#include "desc_constr.h"
20
21#define PREHDR_RSLS_SHIFT 31
22#define PREHDR_ABS BIT(25)

--- 46 unchanged lines hidden (view full) ---

69
70/*
71 * This is written by only one core - the one that initialized the CGR - and
72 * read by multiple cores (all the others).
73 */
74bool caam_congested __read_mostly;
75EXPORT_SYMBOL(caam_congested);
76
76#ifdef CONFIG_DEBUG_FS
77/*
77/*
78 * This is a counter for the number of times the congestion group (where all
79 * the request and response queueus are) reached congestion. Incremented
80 * each time the congestion callback is called with congested == true.
81 */
82static u64 times_congested;
83#endif
84
85/*
86 * This is a a cache of buffers, from which the users of CAAM QI driver
87 * can allocate short (CAAM_QI_MEMCACHE_SIZE) buffers. It's faster than
88 * doing malloc on the hotpath.
89 * NOTE: A more elegant solution would be to have some headroom in the frames
90 * being processed. This could be added by the dpaa-ethernet driver.
91 * This would pose a problem for userspace application processing which
92 * cannot know of this limitation. So for now, this will work.
93 * NOTE: The memcache is SMP-safe. No need to handle spinlocks in-here

--- 445 unchanged lines hidden (view full) ---

539 kmem_cache_destroy(qi_cache);
540}
541
542static void cgr_cb(struct qman_portal *qm, struct qman_cgr *cgr, int congested)
543{
544 caam_congested = congested;
545
546 if (congested) {
78 * This is a a cache of buffers, from which the users of CAAM QI driver
79 * can allocate short (CAAM_QI_MEMCACHE_SIZE) buffers. It's faster than
80 * doing malloc on the hotpath.
81 * NOTE: A more elegant solution would be to have some headroom in the frames
82 * being processed. This could be added by the dpaa-ethernet driver.
83 * This would pose a problem for userspace application processing which
84 * cannot know of this limitation. So for now, this will work.
85 * NOTE: The memcache is SMP-safe. No need to handle spinlocks in-here

--- 445 unchanged lines hidden (view full) ---

531 kmem_cache_destroy(qi_cache);
532}
533
534static void cgr_cb(struct qman_portal *qm, struct qman_cgr *cgr, int congested)
535{
536 caam_congested = congested;
537
538 if (congested) {
547#ifdef CONFIG_DEBUG_FS
548 times_congested++;
549#endif
539 caam_debugfs_qi_congested();
540
550 pr_debug_ratelimited("CAAM entered congestion\n");
551
552 } else {
553 pr_debug_ratelimited("CAAM exited congestion\n");
554 }
555}
556
557static int caam_qi_napi_schedule(struct qman_portal *p, struct caam_napi *np)

--- 212 unchanged lines hidden (view full) ---

770 qi_cache = kmem_cache_create("caamqicache", CAAM_QI_MEMCACHE_SIZE, 0,
771 SLAB_CACHE_DMA, NULL);
772 if (!qi_cache) {
773 dev_err(qidev, "Can't allocate CAAM cache\n");
774 free_rsp_fqs();
775 return -ENOMEM;
776 }
777
541 pr_debug_ratelimited("CAAM entered congestion\n");
542
543 } else {
544 pr_debug_ratelimited("CAAM exited congestion\n");
545 }
546}
547
548static int caam_qi_napi_schedule(struct qman_portal *p, struct caam_napi *np)

--- 212 unchanged lines hidden (view full) ---

761 qi_cache = kmem_cache_create("caamqicache", CAAM_QI_MEMCACHE_SIZE, 0,
762 SLAB_CACHE_DMA, NULL);
763 if (!qi_cache) {
764 dev_err(qidev, "Can't allocate CAAM cache\n");
765 free_rsp_fqs();
766 return -ENOMEM;
767 }
768
778#ifdef CONFIG_DEBUG_FS
779 debugfs_create_file("qi_congested", 0444, ctrlpriv->ctl,
780 &times_congested, &caam_fops_u64_ro);
781#endif
769 caam_debugfs_qi_init(ctrlpriv);
782
783 err = devm_add_action_or_reset(qidev, caam_qi_shutdown, ctrlpriv);
784 if (err)
785 return err;
786
787 dev_info(qidev, "Linux CAAM Queue I/F driver initialised\n");
788 return 0;
789}
770
771 err = devm_add_action_or_reset(qidev, caam_qi_shutdown, ctrlpriv);
772 if (err)
773 return err;
774
775 dev_info(qidev, "Linux CAAM Queue I/F driver initialised\n");
776 return 0;
777}